//---------------------------------------------------------------------------
//	@function:
//		CDXLPhysicalRandomMotion::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured 
//
//---------------------------------------------------------------------------
void
CDXLPhysicalRandomMotion::AssertValid
	(
	const CDXLNode *pdxln,
	BOOL fValidateChildren
	) const
{
	// assert proj list and filter are valid
	CDXLPhysical::AssertValid(pdxln, fValidateChildren);

	GPOS_ASSERT(m_pdrgpiInputSegIds != NULL);
	GPOS_ASSERT(0 < m_pdrgpiInputSegIds->UlLength());
	GPOS_ASSERT(m_pdrgpiOutputSegIds != NULL);
	GPOS_ASSERT(0 < m_pdrgpiOutputSegIds->UlLength());

	GPOS_ASSERT(EdxlrandommIndexSentinel == pdxln->UlArity());
	
	CDXLNode *pdxlnChild = (*pdxln)[EdxlrandommIndexChild];
	GPOS_ASSERT(EdxloptypePhysical == pdxlnChild->Pdxlop()->Edxloperatortype());
	
	if (fValidateChildren)
	{
		pdxlnChild->Pdxlop()->AssertValid(pdxlnChild, fValidateChildren);
	}
}
//---------------------------------------------------------------------------
//	@function:
//		CDXLScalarWindowFrameEdge::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured
//
//---------------------------------------------------------------------------
void
CDXLScalarWindowFrameEdge::AssertValid
(
    const CDXLNode *pdxln,
    BOOL fValidateChildren
)
const
{
    const ULONG ulArity = pdxln->UlArity();
    GPOS_ASSERT(1 >= ulArity);

    GPOS_ASSERT_IMP((m_edxlfb == EdxlfbBoundedPreceding || m_edxlfb == EdxlfbBoundedFollowing
                     || m_edxlfb == EdxlfbDelayedBoundedPreceding || m_edxlfb == EdxlfbDelayedBoundedFollowing), 1 == ulArity);
    GPOS_ASSERT_IMP((m_edxlfb == EdxlfbUnboundedPreceding || m_edxlfb == EdxlfbUnboundedFollowing || m_edxlfb == EdxlfbCurrentRow), 0 == ulArity);

    for (ULONG ul = 0; ul < ulArity; ++ul)
    {
        CDXLNode *pdxlnArg = (*pdxln)[ul];
        GPOS_ASSERT(EdxloptypeScalar == pdxlnArg->Pdxlop()->Edxloperatortype());

        if (fValidateChildren)
        {
            pdxlnArg->Pdxlop()->AssertValid(pdxlnArg, fValidateChildren);
        }
    }
}
//---------------------------------------------------------------------------
//	@function:
//		CDXLScalarBitmapBoolOp::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured
//
//---------------------------------------------------------------------------
void
CDXLScalarBitmapBoolOp::AssertValid
	(
	const CDXLNode *pdxln,
	BOOL fValidateChildren
	) 
	const
{
	EdxlBitmapBoolOp edxlbitmapboolop = ((CDXLScalarBitmapBoolOp *) pdxln->Pdxlop())->Edxlbitmapboolop();

	GPOS_ASSERT( (edxlbitmapboolop == EdxlbitmapAnd) || (edxlbitmapboolop == EdxlbitmapOr));

	ULONG ulArity = pdxln->UlArity();
	GPOS_ASSERT(2 == ulArity);
	

	for (ULONG ul = 0; ul < ulArity; ++ul)
	{
		CDXLNode *pdxlnArg = (*pdxln)[ul];
		Edxlopid edxlop = pdxlnArg->Pdxlop()->Edxlop();
		
		GPOS_ASSERT(EdxlopScalarBitmapBoolOp == edxlop || EdxlopScalarBitmapIndexProbe == edxlop);
		
		if (fValidateChildren)
		{
			pdxlnArg->Pdxlop()->AssertValid(pdxlnArg, fValidateChildren);
		}
	}
}
Esempio n. 4
0
//---------------------------------------------------------------------------
//	@function:
//		CDXLPhysicalLimit::SerializeToDXL
//
//	@doc:
//		Serialize operator in DXL format
//
//---------------------------------------------------------------------------
void
CDXLPhysicalLimit::SerializeToDXL
	(
	CXMLSerializer *pxmlser,
	const CDXLNode *pdxln
	)
	const
{
	const CWStringConst *pstrElemName = PstrOpName();

	pxmlser->OpenElement(CDXLTokens::PstrToken(EdxltokenNamespacePrefix), pstrElemName);

	// serialize properties
	pdxln->SerializePropertiesToDXL(pxmlser);

	// serialize children nodes

	const DrgPdxln *pdrgpdxln = pdxln->PdrgpdxlnChildren();

	GPOS_ASSERT(4 == pdxln->UlArity());
	// serialize the first two children: target-list and plan
	for (ULONG i = 0; i < 4; i++)
	{
		CDXLNode *pdxlnChild = (*pdrgpdxln)[i];
		pdxlnChild->SerializeToDXL(pxmlser);
	}

	pxmlser->CloseElement(CDXLTokens::PstrToken(EdxltokenNamespacePrefix), pstrElemName);
}
//---------------------------------------------------------------------------
//	@function:
//		CParseHandlerQueryOutput::EndElement
//
//	@doc:
//		Invoked by Xerces to process a closing tag
//
//---------------------------------------------------------------------------
void
CParseHandlerQueryOutput::EndElement
	(
	const XMLCh* const, // element_uri,
	const XMLCh* const element_local_name,
	const XMLCh* const // element_qname
	)
{
	if(0 != XMLString::compareString(CDXLTokens::XmlstrToken(EdxltokenQueryOutput), element_local_name))
	{
		CWStringDynamic *str = CDXLUtils::CreateDynamicStringFromXMLChArray(m_parse_handler_mgr->GetDXLMemoryManager(), element_local_name);
		GPOS_RAISE(gpdxl::ExmaDXL, gpdxl::ExmiDXLUnexpectedTag, str->GetBuffer());
	}

	const ULONG size = this->Length();
	for (ULONG ul = 0; ul < size; ul++)
	{
		CParseHandlerScalarIdent *child_parse_handler = dynamic_cast<CParseHandlerScalarIdent *>((*this)[ul]);

		GPOS_ASSERT(NULL != child_parse_handler);

		CDXLNode *pdxlnIdent = child_parse_handler->CreateDXLNode();
		pdxlnIdent->AddRef();
		m_dxl_array->Append(pdxlnIdent);
	}

	// deactivate handler
	m_parse_handler_mgr->DeactivateHandler();
}
Esempio n. 6
0
//---------------------------------------------------------------------------
//	@function:
//		CDXLScalarBoolExpr::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured
//
//---------------------------------------------------------------------------
void
CDXLScalarBoolExpr::AssertValid
	(
	const CDXLNode *pdxln,
	BOOL fValidateChildren
	) 
	const
{
	EdxlBoolExprType edxlbooltype = ((CDXLScalarBoolExpr *) pdxln->Pdxlop())->EdxlBoolType();

	GPOS_ASSERT( (edxlbooltype == Edxlnot) || (edxlbooltype == Edxlor) || (edxlbooltype == Edxland));

	const ULONG ulArity = pdxln->UlArity();
	if(edxlbooltype == Edxlnot)
	{
		GPOS_ASSERT(1 == ulArity);
	}
	else
	{
		GPOS_ASSERT(2 <= ulArity);
	}

	for (ULONG ul = 0; ul < ulArity; ++ul)
	{
		CDXLNode *pdxlnArg = (*pdxln)[ul];
		GPOS_ASSERT(EdxloptypeScalar == pdxlnArg->Pdxlop()->Edxloperatortype());
		
		if (fValidateChildren)
		{
			pdxlnArg->Pdxlop()->AssertValid(pdxlnArg, fValidateChildren);
		}
	}
}
//---------------------------------------------------------------------------
//	@function:
//		CDXLPhysicalIndexScan::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured
//
//---------------------------------------------------------------------------
void
CDXLPhysicalIndexScan::AssertValid
	(
	const CDXLNode *pdxln,
	BOOL fValidateChildren
	)
	const
{
	// assert proj list and filter are valid
	CDXLPhysical::AssertValid(pdxln, fValidateChildren);

	// index scan has only 3 children
	GPOS_ASSERT(3 == pdxln->UlArity());

	// assert validity of the index descriptor
	GPOS_ASSERT(NULL != m_pdxlid);
	GPOS_ASSERT(NULL != m_pdxlid->Pmdname());
	GPOS_ASSERT(m_pdxlid->Pmdname()->Pstr()->FValid());

	// assert validity of the table descriptor
	GPOS_ASSERT(NULL != m_pdxltabdesc);
	GPOS_ASSERT(NULL != m_pdxltabdesc->Pmdname());
	GPOS_ASSERT(m_pdxltabdesc->Pmdname()->Pstr()->FValid());

	CDXLNode *pdxlnIndexConds = (*pdxln)[EdxlisIndexCondition];

	// assert children are of right type (physical/scalar)
	GPOS_ASSERT(EdxlopScalarIndexCondList == pdxlnIndexConds->Pdxlop()->Edxlop());

	if (fValidateChildren)
	{
		pdxlnIndexConds->Pdxlop()->AssertValid(pdxlnIndexConds, fValidateChildren);
	}
}
Esempio n. 8
0
//---------------------------------------------------------------------------
//	@function:
//		CParseHandlerTest::EresParseAndSerializePlan
//
//	@doc:
//		Verifies that after parsing the given DXL file into a DXL tree,
//		it will be serialized back to the same string.
//
//---------------------------------------------------------------------------
GPOS_RESULT
CParseHandlerTest::EresParseAndSerializePlan
	(
	IMemoryPool *pmp,
	const CHAR *szDXLFileName,
	BOOL fValidate
	)
{
	CWStringDynamic str(pmp);
	COstreamString oss(&str);
	
	// read DXL file
	CHAR *szDXL = CDXLUtils::SzRead(pmp, szDXLFileName);

	GPOS_CHECK_ABORT;
		
	const CHAR *szValidationPath = NULL;
	
	if (fValidate)
	{  
	   szValidationPath = CTestUtils::m_szXSDPath;
	}

	// the root of the parsed DXL tree
	ULLONG ullPlanId = ULLONG_MAX;
	ULLONG ullPlanSpaceSize = ULLONG_MAX;
	CDXLNode *pdxlnRoot = CDXLUtils::PdxlnParsePlan(pmp, szDXL, szValidationPath, &ullPlanId, &ullPlanSpaceSize);
	
	GPOS_CHECK_ABORT;

	oss << "Serializing parsed tree" << std::endl;

	CWStringDynamic strPlan(pmp);
	COstreamString osPlan(&strPlan);

	CDXLUtils::SerializePlan(pmp, osPlan, pdxlnRoot, ullPlanId, ullPlanSpaceSize, true /*fSerializeHeaderFooter*/, true /*fIndent*/);

	GPOS_CHECK_ABORT;

	CWStringDynamic dstrExpected(pmp);
	dstrExpected.AppendFormat(GPOS_WSZ_LIT("%s"), szDXL);

	if (!dstrExpected.FEquals(&strPlan))
	{
		GPOS_TRACE(dstrExpected.Wsz());
		GPOS_TRACE(strPlan.Wsz());

		GPOS_ASSERT(!"Not matching");
	}
	
	// cleanup
	pdxlnRoot->Release();
	GPOS_DELETE_ARRAY(szDXL);
	
	return GPOS_OK;
}
Esempio n. 9
0
//---------------------------------------------------------------------------
//	@function:
//		CDXLPhysicalNLJoin::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured 
//
//---------------------------------------------------------------------------
void
CDXLPhysicalNLJoin::AssertValid
	(
	const CDXLNode *pdxln,
	BOOL fValidateChildren
	) 
	const
{
	// assert proj list and filter are valid
	CDXLPhysical::AssertValid(pdxln, fValidateChildren);
	
	GPOS_ASSERT(EdxlnljIndexSentinel == pdxln->UlArity());
	GPOS_ASSERT(EdxljtSentinel > Edxltype());
	
	CDXLNode *pdxlnJoinFilter = (*pdxln)[EdxlnljIndexJoinFilter];
	CDXLNode *pdxlnLeft = (*pdxln)[EdxlnljIndexLeftChild];
	CDXLNode *pdxlnRight = (*pdxln)[EdxlnljIndexRightChild];
	
	// assert children are of right type (physical/scalar)
	GPOS_ASSERT(EdxlopScalarJoinFilter == pdxlnJoinFilter->Pdxlop()->Edxlop());
	GPOS_ASSERT(EdxloptypePhysical == pdxlnLeft->Pdxlop()->Edxloperatortype());
	GPOS_ASSERT(EdxloptypePhysical == pdxlnRight->Pdxlop()->Edxloperatortype());
	
	if (fValidateChildren)
	{
		pdxlnJoinFilter->Pdxlop()->AssertValid(pdxlnJoinFilter, fValidateChildren);
		pdxlnLeft->Pdxlop()->AssertValid(pdxlnLeft, fValidateChildren);
		pdxlnRight->Pdxlop()->AssertValid(pdxlnRight, fValidateChildren);
	}
}
Esempio n. 10
0
//---------------------------------------------------------------------------
//	@function:
//		CDXLLogicalWindow::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured
//
//---------------------------------------------------------------------------
void
CDXLLogicalWindow::AssertValid
	(
	const CDXLNode *pdxln,
	BOOL fValidateChildren
	) const
{
	GPOS_ASSERT(2 == pdxln->UlArity());

	CDXLNode *pdxlnProjList = (*pdxln)[0];
	CDXLNode *pdxlnChild = (*pdxln)[1];

	GPOS_ASSERT(EdxlopScalarProjectList == pdxlnProjList->Pdxlop()->Edxlop());
	GPOS_ASSERT(EdxloptypeLogical == pdxlnChild->Pdxlop()->Edxloperatortype());

	if (fValidateChildren)
	{
		pdxlnProjList->Pdxlop()->AssertValid(pdxlnProjList, fValidateChildren);
		pdxlnChild->Pdxlop()->AssertValid(pdxlnChild, fValidateChildren);
	}

	const ULONG ulArity = pdxlnProjList->UlArity();
	for (ULONG ul = 0; ul < ulArity; ++ul)
	{
		CDXLNode *pdxlnPrEl = (*pdxlnProjList)[ul];
		GPOS_ASSERT(EdxlopScalarIdent != pdxlnPrEl->Pdxlop()->Edxlop());
	}

	GPOS_ASSERT(NULL != m_pdrgpdxlws);
	GPOS_ASSERT(0 < m_pdrgpdxlws->UlLength());
}
Esempio n. 11
0
//---------------------------------------------------------------------------
//	@function:
//		CParseHandlerTest::EresParseAndSerializeScalarExpr
//
//	@doc:
//      Parses a ScalarExpr and verifies that the serialization is identical
//      to the original input.
//
//---------------------------------------------------------------------------
GPOS_RESULT
CParseHandlerTest::EresParseAndSerializeScalarExpr
	(
	IMemoryPool *pmp,
	const CHAR *szDXLFileName,
	BOOL fValidate
	)
{
	// read DXL file
	CHAR *szDXL = CDXLUtils::SzRead(pmp, szDXLFileName);
	GPOS_CHECK_ABORT;

	const CHAR *szValidationPath = NULL;
	if (fValidate)
	{
		szValidationPath = CTestUtils::m_szXSDPath;
	}

	// the root of the parsed DXL tree
	CDXLNode *pdxlnRoot = CDXLUtils::PdxlnParseScalarExpr(pmp, szDXL, szValidationPath);
	GPOS_CHECK_ABORT;

	CWStringDynamic str(pmp);
	COstreamString oss(&str);
	oss << "Serializing parsed tree" << std::endl;
	CWStringDynamic *pstr = CDXLUtils::PstrSerializeScalarExpr(pmp, pdxlnRoot, true /*fSerializeHeaderFooter*/, true /*fIndent*/);
	GPOS_CHECK_ABORT;

	CWStringDynamic dstrExpected(pmp);
	dstrExpected.AppendFormat(GPOS_WSZ_LIT("%s"), szDXL);

	GPOS_RESULT eres = GPOS_OK;
	if (!dstrExpected.FEquals(pstr))
	{
		GPOS_TRACE(dstrExpected.Wsz());
		GPOS_TRACE(pstr->Wsz());

		GPOS_ASSERT(!"Not matching");
		eres = GPOS_FAILED;
	}

	// cleanup
	pdxlnRoot->Release();
	GPOS_DELETE(pstr);
	GPOS_DELETE_ARRAY(szDXL);

	return eres;
}
Esempio n. 12
0
//---------------------------------------------------------------------------
//	@function:
//		CParseHandlerOp::AddChildFromParseHandler
//
//	@doc:
//		Extracts the node constructed from the given parse handler and adds it
//		to children array of the current node. Child nodes are ref-counted before
//		being added to the array.
//
//---------------------------------------------------------------------------
void
CParseHandlerOp::AddChildFromParseHandler
	(
	const CParseHandlerOp *pph
	)
{
	GPOS_ASSERT(NULL != m_pdxln);
	GPOS_ASSERT(NULL != pph);
	
	// extract constructed element
	CDXLNode *pdxlnChild = pph->Pdxln();
	GPOS_ASSERT(NULL != pdxlnChild);
	
	pdxlnChild->AddRef();
	m_pdxln->AddChild(pdxlnChild);
}
Esempio n. 13
0
//---------------------------------------------------------------------------
//	@function:
//		CDXLPhysicalDML::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured
//
//---------------------------------------------------------------------------
void
CDXLPhysicalDML::AssertValid
	(
	const CDXLNode *pdxln,
	BOOL fValidateChildren
	) 
	const
{
	GPOS_ASSERT(2 == pdxln->UlArity());
	CDXLNode *pdxlnChild = (*pdxln)[1];
	GPOS_ASSERT(EdxloptypePhysical == pdxlnChild->Pdxlop()->Edxloperatortype());

	if (fValidateChildren)
	{
		pdxlnChild->Pdxlop()->AssertValid(pdxlnChild, fValidateChildren);
	}
}
Esempio n. 14
0
//---------------------------------------------------------------------------
//	@function:
//		CDXLScalarCoerceViaIO::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured
//
//---------------------------------------------------------------------------
void
CDXLScalarCoerceViaIO::AssertValid
	(
	const CDXLNode *pdxln,
	BOOL fValidateChildren
	) const
{
	GPOS_ASSERT(1 == pdxln->UlArity());

	CDXLNode *pdxlnChild = (*pdxln)[0];
	GPOS_ASSERT(EdxloptypeScalar == pdxlnChild->Pdxlop()->Edxloperatortype());

	if (fValidateChildren)
	{
		pdxlnChild->Pdxlop()->AssertValid(pdxlnChild, fValidateChildren);
	}
}
Esempio n. 15
0
//---------------------------------------------------------------------------
//	@function:
//		CDXLLogicalDelete::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured
//
//---------------------------------------------------------------------------
void
CDXLLogicalDelete::AssertValid
	(
	const CDXLNode *pdxln,
	BOOL fValidateChildren
	)
	const
{
	GPOS_ASSERT(1 == pdxln->UlArity());

	CDXLNode *pdxlnChild = (*pdxln)[0];
	GPOS_ASSERT(EdxloptypeLogical == pdxlnChild->Pdxlop()->Edxloperatortype());

	if (fValidateChildren)
	{
		pdxlnChild->Pdxlop()->AssertValid(pdxlnChild, fValidateChildren);
	}
}
//---------------------------------------------------------------------------
//	@function:
//		CDXLPhysicalCTEConsumer::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured
//
//---------------------------------------------------------------------------
void
CDXLPhysicalCTEConsumer::AssertValid
	(
	const CDXLNode *pdxln,
	BOOL fValidateChildren
	) const
{
	GPOS_ASSERT(1 == pdxln->UlArity());

	CDXLNode *pdxlnPrL = (*pdxln)[0];
	GPOS_ASSERT(EdxlopScalarProjectList == pdxlnPrL->Pdxlop()->Edxlop());

	if (fValidateChildren)
	{
		pdxlnPrL->Pdxlop()->AssertValid(pdxlnPrL, fValidateChildren);
	}

}
//---------------------------------------------------------------------------
//	@function:
//		CDXLPhysicalMaterialize::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured
//
//---------------------------------------------------------------------------
void
CDXLPhysicalMaterialize::AssertValid
	(
	const CDXLNode *pdxln,
	BOOL fValidateChildren
	) 
	const
{
	GPOS_ASSERT(EdxlspoolNone == m_edxlsptype || EdxlspoolMaterialize == m_edxlsptype);
	GPOS_ASSERT(EdxlmatIndexSentinel == pdxln->UlArity());

	CDXLNode *pdxlnChild = (*pdxln)[EdxlmatIndexChild];
	GPOS_ASSERT(EdxloptypePhysical == pdxlnChild->Pdxlop()->Edxloperatortype());

	if (fValidateChildren)
	{
		pdxlnChild->Pdxlop()->AssertValid(pdxlnChild, fValidateChildren);
	}
}
Esempio n. 18
0
//---------------------------------------------------------------------------
//	@function:
//		CDXLPhysicalWindow::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured
//
//---------------------------------------------------------------------------
void
CDXLPhysicalWindow::AssertValid
	(
	const CDXLNode *pdxln,
	BOOL fValidateChildren
	)
	const
{
	// assert proj list and filter are valid
	CDXLPhysical::AssertValid(pdxln, fValidateChildren);
	GPOS_ASSERT(NULL != m_pdrgpulPartCols);
	GPOS_ASSERT(NULL != m_pdrgpdxlwk);
	GPOS_ASSERT(EdxlwindowIndexSentinel == pdxln->UlArity());
	CDXLNode *pdxlnChild = (*pdxln)[EdxlwindowIndexChild];
	if (fValidateChildren)
	{
		pdxlnChild->Pdxlop()->AssertValid(pdxlnChild, fValidateChildren);
	}
}
Esempio n. 19
0
//---------------------------------------------------------------------------
//	@function:
//		CDXLNode::SerializeChildrenToDXL
//
//	@doc:
//		Serializes the node's children in DXL format
//
//---------------------------------------------------------------------------
void
CDXLNode::SerializeChildrenToDXL
	(
	CXMLSerializer *pxmlser
	)
	const
{
	// serialize children nodes
	const ULONG ulArity = UlArity();
	for (ULONG i = 0; i < ulArity; i++)
	{
		GPOS_CHECK_ABORT;

		CDXLNode *pdxlnChild = (*m_pdrgpdxln)[i];
		pdxlnChild->SerializeToDXL(pxmlser);

		GPOS_CHECK_ABORT;
	}
}
Esempio n. 20
0
//---------------------------------------------------------------------------
//	@function:
//		CDXLNode::AssertValid
//
//	@doc:
//		Checks whether node is well-structured 
//
//---------------------------------------------------------------------------
void
CDXLNode::AssertValid
	(
	BOOL fValidateChildren
	) 
	const
{
	if (!fValidateChildren)
	{
		return;
	}
	
	const ULONG ulArity = UlArity();
	for (ULONG ul = 0; ul < ulArity; ul++)
	{
		CDXLNode *pdxlnChild = (*this)[ul];
		pdxlnChild->Pdxlop()->AssertValid(pdxlnChild, fValidateChildren);
	}
}
Esempio n. 21
0
//---------------------------------------------------------------------------
//	@function:
//		CDXLScalarSortColList::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured 
//
//---------------------------------------------------------------------------
void
CDXLScalarSortColList::AssertValid
	(
	const CDXLNode *pdxln,
	BOOL fValidateChildren
	) 
	const
{
	const ULONG ulArity = pdxln->UlArity();
	for (ULONG ul = 0; ul < ulArity; ul++)
	{
		CDXLNode *pdxlnChild = (*pdxln)[ul];
		GPOS_ASSERT(EdxlopScalarSortCol == pdxlnChild->Pdxlop()->Edxlop());
		
		if (fValidateChildren)
		{
			pdxlnChild->Pdxlop()->AssertValid(pdxlnChild, fValidateChildren);
		}
	}
}
Esempio n. 22
0
//---------------------------------------------------------------------------
//	@function:
//		CDXLUtilsTest::EresUnittest_SerializePlan
//
//	@doc:
//		Testing serialization of plans in DXL
//
//---------------------------------------------------------------------------
GPOS_RESULT
CDXLUtilsTest::EresUnittest_SerializePlan()
{
	// create memory pool
	CAutoMemoryPool amp;
	IMemoryPool *pmp = amp.Pmp();
	
	// read DXL file
	CHAR *szDXL = CDXLUtils::SzRead(pmp, szPlanFile);

	ULLONG ullPlanId = ULLONG_MAX;
	ULLONG ullPlanSpaceSize = ULLONG_MAX;
	CDXLNode *pdxln = CDXLUtils::PdxlnParsePlan(pmp, szDXL, NULL /*szXSDPath*/, &ullPlanId, &ullPlanSpaceSize);
	
	// serialize with document header
	BOOL rgfIndentation[] = {true, false};
	BOOL rgfHeaders[] = {true, false};
	
	CWStringDynamic str(pmp);
	COstreamString oss(&str);

	for (ULONG ulHeaders = 0; ulHeaders < GPOS_ARRAY_SIZE(rgfHeaders); ulHeaders++)
	{
		for (ULONG ulIndent = 0; ulIndent < GPOS_ARRAY_SIZE(rgfIndentation); ulIndent++)
		{
			CWStringDynamic *pstr = CDXLUtils::PstrSerializePlan(pmp, pdxln, ullPlanId, ullPlanSpaceSize, rgfHeaders[ulHeaders], rgfIndentation[ulIndent]);
			oss << "Headers: " << rgfHeaders[ulHeaders] << ", indentation: " << rgfIndentation[ulIndent] << std::endl;
			oss << pstr->Wsz() << std::endl;
			GPOS_DELETE(pstr);
		}
	}
	
	
	GPOS_TRACE(str.Wsz());

	// cleanup
	pdxln->Release();
	GPOS_DELETE_ARRAY(szDXL);
	
	return GPOS_OK;
}
//---------------------------------------------------------------------------
//	@function:
//		CDXLScalarIndexCondList::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured
//
//---------------------------------------------------------------------------
void
CDXLScalarIndexCondList::AssertValid
	(
	const CDXLNode *pdxln,
	BOOL fValidateChildren
	)
	const
{
	GPOS_ASSERT(NULL != pdxln);

	if (fValidateChildren)
	{
		const ULONG ulArity = pdxln->UlArity();
		for (ULONG ul = 0; ul < ulArity; ul++)
		{
			CDXLNode *pdxlnChild = (*pdxln)[ul];
			GPOS_ASSERT(EdxloptypeScalar == pdxlnChild->Pdxlop()->Edxloperatortype());
			pdxlnChild->Pdxlop()->AssertValid(pdxlnChild, fValidateChildren);
		}
	}
}
Esempio n. 24
0
//---------------------------------------------------------------------------
//	@function:
//		CDXLPhysicalResult::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured
//
//---------------------------------------------------------------------------
void
CDXLPhysicalResult::AssertValid
	(
	const CDXLNode *pdxln,
	BOOL fValidateChildren
	) 
	const
{

	GPOS_ASSERT(EdxlresultIndexSentinel >= pdxln->UlArity());
	
	// check that one time filter is valid
	CDXLNode *pdxlnOneTimeFilter = (*pdxln)[EdxlresultIndexOneTimeFilter];
	GPOS_ASSERT(EdxlopScalarOneTimeFilter == pdxlnOneTimeFilter->Pdxlop()->Edxlop());
	
	if (fValidateChildren)
	{
		pdxlnOneTimeFilter->Pdxlop()->AssertValid(pdxlnOneTimeFilter, fValidateChildren);
	}
	
	if (EdxlresultIndexSentinel == pdxln->UlArity())
	{
		CDXLNode *pdxlnChild = (*pdxln)[EdxlresultIndexChild];
		GPOS_ASSERT(EdxloptypePhysical == pdxlnChild->Pdxlop()->Edxloperatortype());

		if (fValidateChildren)
		{
			pdxlnChild->Pdxlop()->AssertValid(pdxlnChild, fValidateChildren);
		}
	}

}
Esempio n. 25
0
//---------------------------------------------------------------------------
//	@function:
//		CDXLPhysicalHashJoin::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured 
//
//---------------------------------------------------------------------------
void
CDXLPhysicalHashJoin::AssertValid
	(
	const CDXLNode *node,
	BOOL validate_children
	) const
{
	// assert proj list and filter are valid
	CDXLPhysical::AssertValid(node, validate_children);
	
	GPOS_ASSERT(EdxlhjIndexSentinel == node->Arity());
	GPOS_ASSERT(EdxljtSentinel > GetJoinType());
	
	CDXLNode *join_filter = (*node)[EdxlhjIndexJoinFilter];
	CDXLNode *hash_clauses = (*node)[EdxlhjIndexHashCondList];
	CDXLNode *left = (*node)[EdxlhjIndexHashLeft];
	CDXLNode *right = (*node)[EdxlhjIndexHashRight];

	// assert children are of right type (physical/scalar)
	GPOS_ASSERT(EdxlopScalarJoinFilter == join_filter->GetOperator()->GetDXLOperator());
	GPOS_ASSERT(EdxlopScalarHashCondList == hash_clauses->GetOperator()->GetDXLOperator());
	GPOS_ASSERT(EdxloptypePhysical == left->GetOperator()->GetDXLOperatorType());
	GPOS_ASSERT(EdxloptypePhysical == right->GetOperator()->GetDXLOperatorType());

	if (validate_children)
	{
		join_filter->GetOperator()->AssertValid(join_filter, validate_children);
		hash_clauses->GetOperator()->AssertValid(hash_clauses, validate_children);
		left->GetOperator()->AssertValid(left, validate_children);
		right->GetOperator()->AssertValid(right, validate_children);
	}
}
Esempio n. 26
0
//---------------------------------------------------------------------------
//	@function:
//		CDXLScalarIfStmt::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured
//
//---------------------------------------------------------------------------
void
CDXLScalarIfStmt::AssertValid
(
    const CDXLNode *pdxln,
    BOOL fValidateChildren
)
const
{
    const ULONG ulArity = pdxln->UlArity();
    GPOS_ASSERT(3 == ulArity);

    for (ULONG ul = 0; ul < ulArity; ++ul)
    {
        CDXLNode *pdxlnArg = (*pdxln)[ul];
        GPOS_ASSERT(EdxloptypeScalar == pdxlnArg->Pdxlop()->Edxloperatortype());

        if (fValidateChildren)
        {
            pdxlnArg->Pdxlop()->AssertValid(pdxlnArg, fValidateChildren);
        }
    }
}
Esempio n. 27
0
//---------------------------------------------------------------------------
//	@function:
//		CDXLScalarSubPlan::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured
//
//---------------------------------------------------------------------------
void
CDXLScalarSubPlan::AssertValid
	(
	const CDXLNode *pdxln,
	BOOL fValidateChildren
	) 
	const
{
	GPOS_ASSERT(EdxlSubPlanIndexSentinel == pdxln->UlArity());

	// assert child plan is a physical plan and is valid

	CDXLNode *pdxlnChild = (*pdxln)[EdxlSubPlanIndexChildPlan];
	GPOS_ASSERT(NULL != pdxlnChild);
	GPOS_ASSERT(EdxloptypePhysical == pdxlnChild->Pdxlop()->Edxloperatortype());
	GPOS_ASSERT_IMP(NULL != m_pdxlnTestExpr, EdxloptypeScalar == m_pdxlnTestExpr->Pdxlop()->Edxloperatortype());

	if (fValidateChildren)
	{
		pdxlnChild->Pdxlop()->AssertValid(pdxlnChild, fValidateChildren);
	}
}
Esempio n. 28
0
//---------------------------------------------------------------------------
//	@function:
//		CDXLPhysicalAppend::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured 
//
//---------------------------------------------------------------------------
void
CDXLPhysicalAppend::AssertValid
	(
	const CDXLNode *pdxln,
	BOOL fValidateChildren
	) const
{
	// assert proj list and filter are valid
	CDXLPhysical::AssertValid(pdxln, fValidateChildren);
	
	const ULONG ulChildren = pdxln->UlArity();
	for (ULONG ul = EdxlappendIndexFirstChild; ul < ulChildren; ul++)
	{
		CDXLNode *pdxlnChild = (*pdxln)[ul];
		GPOS_ASSERT(EdxloptypePhysical == pdxlnChild->Pdxlop()->Edxloperatortype());
		
		if (fValidateChildren)
		{
			pdxlnChild->Pdxlop()->AssertValid(pdxlnChild, fValidateChildren);
		}
	}
	
}
Esempio n. 29
0
//---------------------------------------------------------------------------
//	@function:
//		CTranslatorDXLToQuery::TranslateProjList
//
//	@doc:
//		Translates a DXL projection list
//
//---------------------------------------------------------------------------
void
CTranslatorDXLToQuery::TranslateProjList
	(
	const CDXLNode *pdxlnPrL,
	CStateDXLToQuery *pstatedxltoquery,
	CMappingColIdVarQuery *pmapcidvarquery,
	ULONG ulTargetEntryIndex
	)
{
	if (NULL != pdxlnPrL)
	{
		// translate each DXL project element into a target entry
		const ULONG ulArity = pdxlnPrL->UlArity();
		for (ULONG ul = 0; ul < ulArity; ++ul)
		{
			CDXLNode *pdxlnPrEl = (*pdxlnPrL)[ul];
			CDXLScalarProjElem *pdxlopPrEl = CDXLScalarProjElem::PdxlopConvert(pdxlnPrEl->Pdxlop());

			GPOS_ASSERT(1 == pdxlnPrEl->UlArity());
			// translate proj element expression
			CDXLNode *pdxlnExpr = (*pdxlnPrEl)[0];

			Expr *pexpr = m_pdxlsctranslator->PexprFromDXLNodeScalar(pdxlnExpr, pmapcidvarquery);

			GPOS_ASSERT(NULL != pexpr);

			TargetEntry *pte = MakeNode(TargetEntry);
			pte->expr = pexpr;
			pte->resname = CTranslatorUtils::SzFromWsz(pdxlopPrEl->PmdnameAlias()->Pstr()->Wsz());
			pte->resno = (AttrNumber) (ulTargetEntryIndex + ul + 1);

			pstatedxltoquery->AddOutputColumnEntry(pte, pte->resname, pdxlopPrEl->UlId());
			//save mapping col id -> Var in the query translation context
			pmapcidvarquery->FInsertMapping(pdxlopPrEl->UlId(), pte);
		}
	}
}
Esempio n. 30
0
//---------------------------------------------------------------------------
//	@function:
//		CDXLPhysicalTVF::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured
//
//---------------------------------------------------------------------------
void
CDXLPhysicalTVF::AssertValid
	(
	const CDXLNode *pdxln,
	BOOL fValidateChildren
	)
	const
{
	// assert validity of function id and return type
	GPOS_ASSERT(NULL != m_pmdidFunc);
	GPOS_ASSERT(NULL != m_pmdidRetType);

	const ULONG ulArity = pdxln->UlArity();
	for (ULONG ul = 0; ul < ulArity; ++ul)
	{
		CDXLNode *pdxlnArg = (*pdxln)[ul];
		GPOS_ASSERT(EdxloptypeScalar == pdxlnArg->Pdxlop()->Edxloperatortype());

		if (fValidateChildren)
		{
			pdxlnArg->Pdxlop()->AssertValid(pdxlnArg, fValidateChildren);
		}
	}
}