//--------------------------------------------------------------------------- // @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; }
//--------------------------------------------------------------------------- // @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 *mp, const CHAR *dxl_filename, BOOL fValidate ) { CWStringDynamic str(mp); COstreamString oss(&str); // read DXL file CHAR *dxl_string = CDXLUtils::Read(mp, dxl_filename); GPOS_CHECK_ABORT; const CHAR *szValidationPath = NULL; if (fValidate) { szValidationPath = CTestUtils::m_szXSDPath; } // the root of the parsed DXL tree ULLONG plan_id = gpos::ullong_max; ULLONG plan_space_size = gpos::ullong_max; CDXLNode *root_dxl_node = CDXLUtils::GetPlanDXLNode(mp, dxl_string, szValidationPath, &plan_id, &plan_space_size); GPOS_CHECK_ABORT; oss << "Serializing parsed tree" << std::endl; CWStringDynamic strPlan(mp); COstreamString osPlan(&strPlan); CDXLUtils::SerializePlan(mp, osPlan, root_dxl_node, plan_id, plan_space_size, true /*serialize_header_footer*/, true /*indentation*/); GPOS_CHECK_ABORT; CWStringDynamic dstrExpected(mp); dstrExpected.AppendFormat(GPOS_WSZ_LIT("%s"), dxl_string); if (!dstrExpected.Equals(&strPlan)) { GPOS_TRACE(dstrExpected.GetBuffer()); GPOS_TRACE(strPlan.GetBuffer()); GPOS_ASSERT(!"Not matching"); } // cleanup root_dxl_node->Release(); GPOS_DELETE_ARRAY(dxl_string); return GPOS_OK; }