This is an automated email from the ASF dual-hosted git repository. reshke pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/cloudberry.git
commit f56a70d47ac1a31da7fb4f581515fffd5ac1d991 Author: Chris Hajas <[email protected]> AuthorDate: Wed Aug 23 08:31:11 2023 -0700 Remove unused partitioning code in Orca (#16274) This code was leftover from the partitioning refactor and isn't used anywhere --- .../gpopt/translate/CTranslatorRelcacheToDXL.cpp | 84 ------------ .../naucrates/dxl/parser/CParseHandlerMDIndex.h | 1 - .../naucrates/dxl/parser/CParseHandlerMDRelation.h | 1 - .../include/naucrates/md/CMDPartConstraintGPDB.h | 88 ------------- .../libnaucrates/src/md/CMDPartConstraintGPDB.cpp | 143 --------------------- src/backend/gporca/libnaucrates/src/md/Makefile | 1 - .../gpopt/translate/CTranslatorRelcacheToDXL.h | 16 --- 7 files changed, 334 deletions(-) diff --git a/src/backend/gpopt/translate/CTranslatorRelcacheToDXL.cpp b/src/backend/gpopt/translate/CTranslatorRelcacheToDXL.cpp index 6fd7c7793e..c8e884d585 100644 --- a/src/backend/gpopt/translate/CTranslatorRelcacheToDXL.cpp +++ b/src/backend/gpopt/translate/CTranslatorRelcacheToDXL.cpp @@ -64,7 +64,6 @@ extern "C" { #include "naucrates/md/CMDIdRelStats.h" #include "naucrates/md/CMDIdScCmp.h" #include "naucrates/md/CMDIndexGPDB.h" -#include "naucrates/md/CMDPartConstraintGPDB.h" #include "naucrates/md/CMDScCmpGPDB.h" #include "naucrates/md/CMDTypeBoolGPDB.h" #include "naucrates/md/CMDTypeGenericGPDB.h" @@ -2836,50 +2835,6 @@ CTranslatorRelcacheToDXL::IsIndexSupported(Relation index_rel) return false; } -//--------------------------------------------------------------------------- -// @function: -// CTranslatorRelcacheToDXL::RetrievePartConstraintForIndex -// -// @doc: -// Retrieve part constraint for index -// -//--------------------------------------------------------------------------- -CMDPartConstraintGPDB * -CTranslatorRelcacheToDXL::RetrievePartConstraintForIndex( - CMemoryPool *mp, CMDAccessor *md_accessor, const IMDRelation *md_rel, - Node *part_constraint, ULongPtrArray *level_with_default_part_array, - BOOL is_unbounded) -{ - CDXLColDescrArray *dxl_col_descr_array = GPOS_NEW(mp) CDXLColDescrArray(mp); - const ULONG num_columns = md_rel->ColumnCount(); - - for (ULONG ul = 0; ul < num_columns; ul++) - { - const IMDColumn *md_col = md_rel->GetMdCol(ul); - CMDName *md_colname = - GPOS_NEW(mp) CMDName(mp, md_col->Mdname().GetMDName()); - CMDIdGPDB *mdid_col_type = CMDIdGPDB::CastMdid(md_col->MdidType()); - mdid_col_type->AddRef(); - - // create a column descriptor for the column - CDXLColDescr *dxl_col_descr = GPOS_NEW(mp) CDXLColDescr( - md_colname, - ul + 1, // colid - md_col->AttrNum(), mdid_col_type, md_col->TypeModifier(), - false // fColDropped - ); - dxl_col_descr_array->Append(dxl_col_descr); - } - - CMDPartConstraintGPDB *mdpart_constraint = RetrievePartConstraintFromNode( - mp, md_accessor, dxl_col_descr_array, part_constraint, - level_with_default_part_array, is_unbounded); - - dxl_col_descr_array->Release(); - - return mdpart_constraint; -} - //--------------------------------------------------------------------------- // @function: // CTranslatorRelcacheToDXL::RetrievePartConstraintForRel @@ -2940,45 +2895,6 @@ CTranslatorRelcacheToDXL::RetrievePartConstraintForRel( return scalar_dxlnode; } - -//--------------------------------------------------------------------------- -// @function: -// CTranslatorRelcacheToDXL::RetrievePartConstraintFromNode -// -// @doc: -// Retrieve part constraint from GPDB node -// -//--------------------------------------------------------------------------- -CMDPartConstraintGPDB * -CTranslatorRelcacheToDXL::RetrievePartConstraintFromNode( - CMemoryPool *mp, CMDAccessor *md_accessor, - CDXLColDescrArray *dxl_col_descr_array, Node *part_constraints, - ULongPtrArray *level_with_default_part_array, BOOL is_unbounded) -{ - if (nullptr == part_constraints) - { - return nullptr; - } - - // generate a mock mapping between var to column information - CMappingVarColId *var_colid_mapping = GPOS_NEW(mp) CMappingVarColId(mp); - - var_colid_mapping->LoadColumns(0 /*query_level */, 1 /* rteIndex */, - dxl_col_descr_array); - - // translate the check constraint expression - CDXLNode *scalar_dxlnode = - CTranslatorScalarToDXL::TranslateStandaloneExprToDXL( - mp, md_accessor, var_colid_mapping, (Expr *) part_constraints); - - // cleanup - GPOS_DELETE(var_colid_mapping); - - level_with_default_part_array->AddRef(); - return GPOS_NEW(mp) CMDPartConstraintGPDB(mp, level_with_default_part_array, - is_unbounded, scalar_dxlnode); -} - //--------------------------------------------------------------------------- // @function: // CTranslatorRelcacheToDXL::RelHasSystemColumns diff --git a/src/backend/gporca/libnaucrates/include/naucrates/dxl/parser/CParseHandlerMDIndex.h b/src/backend/gporca/libnaucrates/include/naucrates/dxl/parser/CParseHandlerMDIndex.h index 7bead5f0ba..9a969fa88b 100644 --- a/src/backend/gporca/libnaucrates/include/naucrates/dxl/parser/CParseHandlerMDIndex.h +++ b/src/backend/gporca/libnaucrates/include/naucrates/dxl/parser/CParseHandlerMDIndex.h @@ -15,7 +15,6 @@ #include "gpos/base.h" #include "naucrates/dxl/parser/CParseHandlerMetadataObject.h" -#include "naucrates/md/CMDPartConstraintGPDB.h" #include "naucrates/md/IMDIndex.h" namespace gpdxl diff --git a/src/backend/gporca/libnaucrates/include/naucrates/dxl/parser/CParseHandlerMDRelation.h b/src/backend/gporca/libnaucrates/include/naucrates/dxl/parser/CParseHandlerMDRelation.h index 14a2cc7b4c..8be0aca760 100644 --- a/src/backend/gporca/libnaucrates/include/naucrates/dxl/parser/CParseHandlerMDRelation.h +++ b/src/backend/gporca/libnaucrates/include/naucrates/dxl/parser/CParseHandlerMDRelation.h @@ -16,7 +16,6 @@ #include "naucrates/dxl/parser/CParseHandlerMetadataObject.h" #include "naucrates/dxl/xml/dxltokens.h" -#include "naucrates/md/CMDPartConstraintGPDB.h" #include "naucrates/md/CMDRelationGPDB.h" namespace gpdxl diff --git a/src/backend/gporca/libnaucrates/include/naucrates/md/CMDPartConstraintGPDB.h b/src/backend/gporca/libnaucrates/include/naucrates/md/CMDPartConstraintGPDB.h deleted file mode 100644 index 056270bc2e..0000000000 --- a/src/backend/gporca/libnaucrates/include/naucrates/md/CMDPartConstraintGPDB.h +++ /dev/null @@ -1,88 +0,0 @@ -//--------------------------------------------------------------------------- -// Greenplum Database -// Copyright (C) 2012 EMC Corp. -// -// @filename: -// CMDPartConstraintGPDB.h -// -// @doc: -// Class representing a GPDB partition constraint in the MD cache -//--------------------------------------------------------------------------- - -#ifndef GPMD_CMDPartConstraintGPDB_H -#define GPMD_CMDPartConstraintGPDB_H - -#include "gpos/base.h" -#include "gpos/string/CWStringDynamic.h" - -#include "naucrates/md/CMDName.h" -#include "naucrates/md/IMDPartConstraint.h" - -// fwd decl -namespace gpdxl -{ -class CXMLSerializer; -} - -namespace gpopt -{ -class CExpression; -class CMDAccessor; -} // namespace gpopt - -namespace gpmd -{ -using namespace gpos; -using namespace gpdxl; - -//--------------------------------------------------------------------------- -// @class: -// CMDPartConstraintGPDB -// -// @doc: -// Class representing a GPDB partition constraint in the MD cache -// -//--------------------------------------------------------------------------- -class CMDPartConstraintGPDB : public IMDPartConstraint -{ -private: - // memory pool - CMemoryPool *m_mp; - - // included default partitions - ULongPtrArray *m_level_with_default_part_array; - - // is constraint unbounded - BOOL m_is_unbounded; - - // the DXL representation of the part constraint - CDXLNode *m_dxl_node; - -public: - // ctor - CMDPartConstraintGPDB(CMemoryPool *mp, - ULongPtrArray *level_with_default_part_array, - BOOL is_unbounded, CDXLNode *dxlnode); - - // dtor - ~CMDPartConstraintGPDB() override; - - // serialize constraint in DXL format - void Serialize(CXMLSerializer *xml_serializer) const override; - - // the scalar expression of the part constraint - CExpression *GetPartConstraintExpr( - CMemoryPool *mp, CMDAccessor *md_accessor, - CColRefArray *colref_array) const override; - - // included default partitions - ULongPtrArray *GetDefaultPartsArray() const override; - - // is constraint unbounded - BOOL IsConstraintUnbounded() const override; -}; -} // namespace gpmd - -#endif // !GPMD_CMDPartConstraintGPDB_H - -// EOF diff --git a/src/backend/gporca/libnaucrates/src/md/CMDPartConstraintGPDB.cpp b/src/backend/gporca/libnaucrates/src/md/CMDPartConstraintGPDB.cpp deleted file mode 100644 index 9583e20491..0000000000 --- a/src/backend/gporca/libnaucrates/src/md/CMDPartConstraintGPDB.cpp +++ /dev/null @@ -1,143 +0,0 @@ -//--------------------------------------------------------------------------- -// Greenplum Database -// Copyright (C) 2012 EMC Corp. -// -// @filename: -// CMDPartConstraintGPDB.cpp -// -// @doc: -// Implementation of part constraints in the MD cache -//--------------------------------------------------------------------------- - -#include "naucrates/md/CMDPartConstraintGPDB.h" - -#include "gpopt/translate/CTranslatorDXLToExpr.h" -#include "naucrates/dxl/CDXLUtils.h" -#include "naucrates/dxl/xml/CXMLSerializer.h" - -using namespace gpdxl; -using namespace gpmd; -using namespace gpopt; - -//--------------------------------------------------------------------------- -// @function: -// CMDPartConstraintGPDB::CMDPartConstraintGPDB -// -// @doc: -// Ctor -// -//--------------------------------------------------------------------------- -CMDPartConstraintGPDB::CMDPartConstraintGPDB( - CMemoryPool *mp, ULongPtrArray *level_with_default_part_array, - BOOL is_unbounded, CDXLNode *dxlnode) - : m_mp(mp), - m_level_with_default_part_array(level_with_default_part_array), - m_is_unbounded(is_unbounded), - m_dxl_node(dxlnode) -{ - GPOS_ASSERT(nullptr != level_with_default_part_array); -} - -//--------------------------------------------------------------------------- -// @function: -// CMDPartConstraintGPDB::~CMDPartConstraintGPDB -// -// @doc: -// Dtor -// -//--------------------------------------------------------------------------- -CMDPartConstraintGPDB::~CMDPartConstraintGPDB() -{ - CRefCount::SafeRelease(m_dxl_node); - m_level_with_default_part_array->Release(); -} - -//--------------------------------------------------------------------------- -// @function: -// CMDPartConstraintGPDB::GetPartConstraintExpr -// -// @doc: -// Scalar expression of the check constraint -// -//--------------------------------------------------------------------------- -CExpression * -CMDPartConstraintGPDB::GetPartConstraintExpr(CMemoryPool *mp, - CMDAccessor *md_accessor, - CColRefArray *colref_array) const -{ - GPOS_ASSERT(nullptr != colref_array); - - // translate the DXL representation of the part constraint expression - CTranslatorDXLToExpr dxltr(mp, md_accessor); - return dxltr.PexprTranslateScalar(m_dxl_node, colref_array); -} - -//--------------------------------------------------------------------------- -// @function: -// CMDPartConstraintGPDB::GetDefaultPartsArray -// -// @doc: -// Included default partitions -// -//--------------------------------------------------------------------------- -ULongPtrArray * -CMDPartConstraintGPDB::GetDefaultPartsArray() const -{ - return m_level_with_default_part_array; -} - -//--------------------------------------------------------------------------- -// @function: -// CMDPartConstraintGPDB::IsConstraintUnbounded -// -// @doc: -// Is constraint unbounded -// -//--------------------------------------------------------------------------- -BOOL -CMDPartConstraintGPDB::IsConstraintUnbounded() const -{ - return m_is_unbounded; -} - -//--------------------------------------------------------------------------- -// @function: -// CMDPartConstraintGPDB::Serialize -// -// @doc: -// Serialize part constraint in DXL format -// -//--------------------------------------------------------------------------- -void -CMDPartConstraintGPDB::Serialize(CXMLSerializer *xml_serializer) const -{ - xml_serializer->OpenElement( - CDXLTokens::GetDXLTokenStr(EdxltokenNamespacePrefix), - CDXLTokens::GetDXLTokenStr(EdxltokenPartConstraint)); - - // serialize default parts - CWStringDynamic *default_part_array = - CDXLUtils::Serialize(m_mp, m_level_with_default_part_array); - xml_serializer->AddAttribute( - CDXLTokens::GetDXLTokenStr(EdxltokenDefaultPartition), - default_part_array); - GPOS_DELETE(default_part_array); - - xml_serializer->AddAttribute( - CDXLTokens::GetDXLTokenStr(EdxltokenPartConstraintUnbounded), - m_is_unbounded); - - // serialize the scalar expression - if (nullptr != m_dxl_node) - { - m_dxl_node->SerializeToDXL(xml_serializer); - } - - xml_serializer->CloseElement( - CDXLTokens::GetDXLTokenStr(EdxltokenNamespacePrefix), - CDXLTokens::GetDXLTokenStr(EdxltokenPartConstraint)); - - GPOS_CHECK_ABORT; -} - -// EOF diff --git a/src/backend/gporca/libnaucrates/src/md/Makefile b/src/backend/gporca/libnaucrates/src/md/Makefile index 9d6c521789..84a2baa9fb 100644 --- a/src/backend/gporca/libnaucrates/src/md/Makefile +++ b/src/backend/gporca/libnaucrates/src/md/Makefile @@ -33,7 +33,6 @@ OBJS = CDXLBucket.o \ CMDIndexGPDB.o \ CMDIndexInfo.o \ CMDName.o \ - CMDPartConstraintGPDB.o \ CMDProviderGeneric.o \ CMDProviderMemory.o \ CMDRelationCtasGPDB.o \ diff --git a/src/include/gpopt/translate/CTranslatorRelcacheToDXL.h b/src/include/gpopt/translate/CTranslatorRelcacheToDXL.h index 50ff3fa2ea..16c486f197 100644 --- a/src/include/gpopt/translate/CTranslatorRelcacheToDXL.h +++ b/src/include/gpopt/translate/CTranslatorRelcacheToDXL.h @@ -34,7 +34,6 @@ extern "C" { #include "naucrates/md/CMDAggregateGPDB.h" #include "naucrates/md/CMDCheckConstraintGPDB.h" #include "naucrates/md/CMDFunctionGPDB.h" -#include "naucrates/md/CMDPartConstraintGPDB.h" #include "naucrates/md/CMDRelationGPDB.h" #include "naucrates/md/CMDScalarOpGPDB.h" #include "naucrates/md/IMDExtStats.h" @@ -245,27 +244,12 @@ private: // check if index is supported static BOOL IsIndexSupported(Relation index_rel); - // is given level included in the default partitions - static BOOL LevelHasDefaultPartition(List *default_levels, ULONG level); - - // retrieve part constraint for index - static CMDPartConstraintGPDB *RetrievePartConstraintForIndex( - CMemoryPool *mp, CMDAccessor *md_accessor, const IMDRelation *md_rel, - Node *part_constraint, ULongPtrArray *level_with_default_part_array, - BOOL is_unbounded); - // retrieve part constraint for relation static CDXLNode *RetrievePartConstraintForRel(CMemoryPool *mp, CMDAccessor *md_accessor, Relation rel, CMDColumnArray *mdcol_array); - // retrieve part constraint from a GPDB node - static CMDPartConstraintGPDB *RetrievePartConstraintFromNode( - CMemoryPool *mp, CMDAccessor *md_accessor, - CDXLColDescrArray *dxl_col_descr_array, Node *part_constraint, - ULongPtrArray *level_with_default_part_array, BOOL is_unbounded); - // return relation name static CMDName *GetRelName(CMemoryPool *mp, Relation rel); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
