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 19549a23d5cb262867155063472efa1355b72af3
Author: Chris Hajas <[email protected]>
AuthorDate: Mon Jul 24 13:46:17 2023 -0700

    Remove unused partition selector code from Orca (#16054)
    
    I'm not sure how long this has been unused, but it seems like a while.
---
 .../gpopt/operators/CLogicalPartitionSelector.h    | 201 ---------------------
 .../xforms/CXformImplementPartitionSelector.h      |  75 --------
 .../gporca/libgpopt/include/gpopt/xforms/xforms.h  |   1 -
 .../src/operators/CLogicalPartitionSelector.cpp    | 193 --------------------
 src/backend/gporca/libgpopt/src/operators/Makefile |   1 -
 .../gporca/libgpopt/src/xforms/CXformFactory.cpp   |   3 +-
 .../xforms/CXformImplementPartitionSelector.cpp    |  85 ---------
 .../libgpopt/src/xforms/CXformUpdate2DML.cpp       |   1 -
 src/backend/gporca/libgpopt/src/xforms/Makefile    |   1 -
 9 files changed, 1 insertion(+), 560 deletions(-)

diff --git 
a/src/backend/gporca/libgpopt/include/gpopt/operators/CLogicalPartitionSelector.h
 
b/src/backend/gporca/libgpopt/include/gpopt/operators/CLogicalPartitionSelector.h
deleted file mode 100644
index 3e24d9b4b9..0000000000
--- 
a/src/backend/gporca/libgpopt/include/gpopt/operators/CLogicalPartitionSelector.h
+++ /dev/null
@@ -1,201 +0,0 @@
-//---------------------------------------------------------------------------
-//     Greenplum Database
-//     Copyright (C) 2014 VMware, Inc. or its affiliates.
-//
-//     @filename:
-//             CLogicalPartitionSelector.h
-//
-//     @doc:
-//             Logical partition selector operator. This is used for DML
-//             on partitioned tables
-//---------------------------------------------------------------------------
-#ifndef GPOPT_CLogicalPartitionSelector_H
-#define GPOPT_CLogicalPartitionSelector_H
-
-#include "gpos/base.h"
-
-#include "gpopt/metadata/CPartConstraint.h"
-#include "gpopt/operators/CLogical.h"
-
-
-namespace gpopt
-{
-//---------------------------------------------------------------------------
-//     @class:
-//             CLogicalPartitionSelector
-//
-//     @doc:
-//             Logical partition selector operator
-//
-//---------------------------------------------------------------------------
-class CLogicalPartitionSelector : public CLogical
-{
-private:
-       // mdid of partitioned table
-       IMDId *m_mdid;
-
-       // filter expressions corresponding to various levels
-       CExpressionArray *m_pdrgpexprFilters;
-
-public:
-       CLogicalPartitionSelector(const CLogicalPartitionSelector &) = delete;
-
-       // ctors
-       explicit CLogicalPartitionSelector(CMemoryPool *mp);
-
-       CLogicalPartitionSelector(CMemoryPool *mp, IMDId *mdid,
-                                                         CExpressionArray 
*pdrgpexprFilters);
-
-       // dtor
-       ~CLogicalPartitionSelector() override;
-
-       // ident accessors
-       EOperatorId
-       Eopid() const override
-       {
-               return EopLogicalPartitionSelector;
-       }
-
-       // operator name
-       const CHAR *
-       SzId() const override
-       {
-               return "CLogicalPartitionSelector";
-       }
-
-       // partitioned table mdid
-       IMDId *
-       MDId() const
-       {
-               return m_mdid;
-       }
-
-       // number of partitioning levels
-       ULONG
-       UlPartLevels() const
-       {
-               return m_pdrgpexprFilters->Size();
-       }
-
-       // filter expression for a given level
-       CExpression *
-       PexprPartFilter(ULONG ulLevel) const
-       {
-               return (*m_pdrgpexprFilters)[ulLevel];
-       }
-
-       // match function
-       BOOL Matches(COperator *pop) const override;
-
-       // hash function
-       ULONG HashValue() const override;
-
-       // sensitivity to order of inputs
-       BOOL
-       FInputOrderSensitive() const override
-       {
-               // operator has one child
-               return false;
-       }
-
-       // return a copy of the operator with remapped columns
-       COperator *PopCopyWithRemappedColumns(CMemoryPool *mp,
-                                                                               
  UlongToColRefMap *colref_mapping,
-                                                                               
  BOOL must_exist) override;
-
-       
//-------------------------------------------------------------------------------------
-       // Derived Relational Properties
-       
//-------------------------------------------------------------------------------------
-
-       // derive output columns
-       CColRefSet *DeriveOutputColumns(CMemoryPool *mp,
-                                                                       
CExpressionHandle &exprhdl) override;
-
-       // derive constraint property
-       CPropConstraint *
-       DerivePropertyConstraint(CMemoryPool *,  //mp,
-                                                        CExpressionHandle 
&exprhdl) const override
-       {
-               return PpcDeriveConstraintPassThru(exprhdl, 0 /*ulChild*/);
-       }
-
-       // derive max card
-       CMaxCard DeriveMaxCard(CMemoryPool *mp,
-                                                  CExpressionHandle &exprhdl) 
const override;
-
-       // derive partition consumer info
-       CPartInfo *
-       DerivePartitionInfo(CMemoryPool *,      // mp,
-                                               CExpressionHandle &exprhdl) 
const override
-       {
-               return PpartinfoPassThruOuter(exprhdl);
-       }
-
-       // compute required stats columns of the n-th child
-       CColRefSet *
-       PcrsStat(CMemoryPool *,            // mp
-                        CExpressionHandle &,  // exprhdl
-                        CColRefSet *pcrsInput,
-                        ULONG  // child_index
-       ) const override
-       {
-               return PcrsStatsPassThru(pcrsInput);
-       }
-
-       
//-------------------------------------------------------------------------------------
-       // Transformations
-       
//-------------------------------------------------------------------------------------
-
-       // candidate set of xforms
-       CXformSet *PxfsCandidates(CMemoryPool *mp) const override;
-
-       // derive key collections
-       CKeyCollection *
-       DeriveKeyCollection(CMemoryPool *,      // mp
-                                               CExpressionHandle &exprhdl) 
const override
-       {
-               return PkcDeriveKeysPassThru(exprhdl, 0 /* ulChild */);
-       }
-
-
-       // derive statistics
-       IStatistics *
-       PstatsDerive(CMemoryPool *,      //mp,
-                                CExpressionHandle &exprhdl,
-                                IStatisticsArray *      //stats_ctxt
-       ) const override
-       {
-               return PstatsPassThruOuter(exprhdl);
-       }
-
-       // stat promise
-       EStatPromise
-       Esp(CExpressionHandle &) const override
-       {
-               return CLogical::EspHigh;
-       }
-
-       
//-------------------------------------------------------------------------------------
-       
//-------------------------------------------------------------------------------------
-       
//-------------------------------------------------------------------------------------
-
-       // conversion function
-       static CLogicalPartitionSelector *
-       PopConvert(COperator *pop)
-       {
-               GPOS_ASSERT(nullptr != pop);
-               GPOS_ASSERT(EopLogicalPartitionSelector == pop->Eopid());
-
-               return dynamic_cast<CLogicalPartitionSelector *>(pop);
-       }
-
-       // debug print
-       IOstream &OsPrint(IOstream &) const override;
-
-};     // class CLogicalPartitionSelector
-
-}  // namespace gpopt
-
-#endif // !GPOPT_CLogicalPartitionSelector_H
-
-// EOF
diff --git 
a/src/backend/gporca/libgpopt/include/gpopt/xforms/CXformImplementPartitionSelector.h
 
b/src/backend/gporca/libgpopt/include/gpopt/xforms/CXformImplementPartitionSelector.h
deleted file mode 100644
index cd75ba27c9..0000000000
--- 
a/src/backend/gporca/libgpopt/include/gpopt/xforms/CXformImplementPartitionSelector.h
+++ /dev/null
@@ -1,75 +0,0 @@
-//---------------------------------------------------------------------------
-//     Greenplum Database
-//     Copyright (C) 2014 VMware, Inc. or its affiliates.
-//
-//     @filename:
-//             CXformImplementPartitionSelector.h
-//
-//     @doc:
-//             Implement PartitionSelector
-//---------------------------------------------------------------------------
-#ifndef GPOPT_CXformImplementPartitionSelector_H
-#define GPOPT_CXformImplementPartitionSelector_H
-
-#include "gpos/base.h"
-
-#include "gpopt/xforms/CXformImplementation.h"
-
-namespace gpopt
-{
-using namespace gpos;
-
-//---------------------------------------------------------------------------
-//     @class:
-//             CXformImplementPartitionSelector
-//
-//     @doc:
-//             Implement PartitionSelector
-//
-//---------------------------------------------------------------------------
-class CXformImplementPartitionSelector : public CXformImplementation
-{
-private:
-public:
-       CXformImplementPartitionSelector(const CXformImplementPartitionSelector 
&) =
-               delete;
-
-       // ctor
-       explicit CXformImplementPartitionSelector(CMemoryPool *mp);
-
-       // dtor
-       ~CXformImplementPartitionSelector() override = default;
-
-       // ident accessors
-       EXformId
-       Exfid() const override
-       {
-               return ExfImplementPartitionSelector;
-       }
-
-       // xform name
-       const CHAR *
-       SzId() const override
-       {
-               return "CXformImplementPartitionSelector";
-       }
-
-       // compute xform promise for a given expression handle
-       EXformPromise
-       Exfp(CExpressionHandle &  //exprhdl
-       ) const override
-       {
-               return CXform::ExfpHigh;
-       }
-
-       // actual transform
-       void Transform(CXformContext *, CXformResult *,
-                                  CExpression *) const override;
-
-};     // class CXformImplementPartitionSelector
-
-}  // namespace gpopt
-
-#endif // !GPOPT_CXformImplementPartitionSelector_H
-
-// EOF
diff --git a/src/backend/gporca/libgpopt/include/gpopt/xforms/xforms.h 
b/src/backend/gporca/libgpopt/include/gpopt/xforms/xforms.h
index f673fb4f23..8f240a615d 100644
--- a/src/backend/gporca/libgpopt/include/gpopt/xforms/xforms.h
+++ b/src/backend/gporca/libgpopt/include/gpopt/xforms/xforms.h
@@ -66,7 +66,6 @@
 #include "gpopt/xforms/CXformImplementLeftSemiCorrelatedApply.h"
 #include "gpopt/xforms/CXformImplementLeftSemiCorrelatedApplyIn.h"
 #include "gpopt/xforms/CXformImplementLimit.h"
-#include "gpopt/xforms/CXformImplementPartitionSelector.h"
 #include "gpopt/xforms/CXformImplementSequence.h"
 #include "gpopt/xforms/CXformImplementSequenceProject.h"
 #include "gpopt/xforms/CXformImplementSplit.h"
diff --git 
a/src/backend/gporca/libgpopt/src/operators/CLogicalPartitionSelector.cpp 
b/src/backend/gporca/libgpopt/src/operators/CLogicalPartitionSelector.cpp
deleted file mode 100644
index 6d256080a3..0000000000
--- a/src/backend/gporca/libgpopt/src/operators/CLogicalPartitionSelector.cpp
+++ /dev/null
@@ -1,193 +0,0 @@
-//---------------------------------------------------------------------------
-//     Greenplum Database
-//     Copyright (C) 2014 VMware, Inc. or its affiliates.
-//
-//     @filename:
-//             CLogicalPartitionSelector.cpp
-//
-//     @doc:
-//             Implementation of Logical partition selector
-//---------------------------------------------------------------------------
-
-#include "gpopt/operators/CLogicalPartitionSelector.h"
-
-#include "gpos/base.h"
-
-#include "gpopt/base/CDistributionSpecAny.h"
-#include "gpopt/base/COptCtxt.h"
-#include "gpopt/base/CUtils.h"
-#include "gpopt/operators/CExpressionHandle.h"
-
-using namespace gpopt;
-
-//---------------------------------------------------------------------------
-//     @function:
-//             CLogicalPartitionSelector::CLogicalPartitionSelector
-//
-//     @doc:
-//             Ctor - for pattern
-//
-//---------------------------------------------------------------------------
-CLogicalPartitionSelector::CLogicalPartitionSelector(CMemoryPool *mp)
-       : CLogical(mp), m_mdid(nullptr), m_pdrgpexprFilters(nullptr)
-{
-       m_fPattern = true;
-}
-
-//---------------------------------------------------------------------------
-//     @function:
-//             CLogicalPartitionSelector::CLogicalPartitionSelector
-//
-//     @doc:
-//             Ctor
-//
-//---------------------------------------------------------------------------
-CLogicalPartitionSelector::CLogicalPartitionSelector(
-       CMemoryPool *mp, IMDId *mdid, CExpressionArray *pdrgpexprFilters)
-       : CLogical(mp), m_mdid(mdid), m_pdrgpexprFilters(pdrgpexprFilters)
-{
-       GPOS_ASSERT(mdid->IsValid());
-       GPOS_ASSERT(nullptr != pdrgpexprFilters);
-       GPOS_ASSERT(0 < pdrgpexprFilters->Size());
-}
-
-//---------------------------------------------------------------------------
-//     @function:
-//             CLogicalPartitionSelector::~CLogicalPartitionSelector
-//
-//     @doc:
-//             Dtor
-//
-//---------------------------------------------------------------------------
-CLogicalPartitionSelector::~CLogicalPartitionSelector()
-{
-       CRefCount::SafeRelease(m_mdid);
-       CRefCount::SafeRelease(m_pdrgpexprFilters);
-}
-
-//---------------------------------------------------------------------------
-//     @function:
-//             CLogicalPartitionSelector::Matches
-//
-//     @doc:
-//             Match operators
-//
-//---------------------------------------------------------------------------
-BOOL
-CLogicalPartitionSelector::Matches(COperator *pop) const
-{
-       if (Eopid() != pop->Eopid())
-       {
-               return false;
-       }
-
-       CLogicalPartitionSelector *popPartSelector =
-               CLogicalPartitionSelector::PopConvert(pop);
-
-       return popPartSelector->MDId()->Equals(m_mdid) &&
-                  
popPartSelector->m_pdrgpexprFilters->Equals(m_pdrgpexprFilters);
-}
-
-//---------------------------------------------------------------------------
-//     @function:
-//             CLogicalPartitionSelector::HashValue
-//
-//     @doc:
-//             Hash operator
-//
-//---------------------------------------------------------------------------
-ULONG
-CLogicalPartitionSelector::HashValue() const
-{
-       return gpos::CombineHashes(Eopid(), m_mdid->HashValue());
-}
-
-//---------------------------------------------------------------------------
-//     @function:
-//             CLogicalPartitionSelector::PopCopyWithRemappedColumns
-//
-//     @doc:
-//             Return a copy of the operator with remapped columns
-//
-//---------------------------------------------------------------------------
-COperator *
-CLogicalPartitionSelector::PopCopyWithRemappedColumns(
-       CMemoryPool *mp, UlongToColRefMap *colref_mapping, BOOL /* must_exist 
*/)
-{
-       CExpressionArray *pdrgpexpr =
-               CUtils::PdrgpexprRemap(mp, m_pdrgpexprFilters, colref_mapping);
-
-       m_mdid->AddRef();
-
-       return GPOS_NEW(mp) CLogicalPartitionSelector(mp, m_mdid, pdrgpexpr);
-}
-
-//---------------------------------------------------------------------------
-//     @function:
-//             CLogicalPartitionSelector::DeriveOutputColumns
-//
-//     @doc:
-//             Derive output columns
-//
-//---------------------------------------------------------------------------
-CColRefSet *
-CLogicalPartitionSelector::DeriveOutputColumns(CMemoryPool *mp,
-                                                                               
           CExpressionHandle &exprhdl)
-{
-       CColRefSet *pcrsOutput = GPOS_NEW(mp) CColRefSet(mp);
-
-       pcrsOutput->Union(exprhdl.DeriveOutputColumns(0));
-
-       return pcrsOutput;
-}
-
-//---------------------------------------------------------------------------
-//     @function:
-//             CLogicalPartitionSelector::DeriveMaxCard
-//
-//     @doc:
-//             Derive max card
-//
-//---------------------------------------------------------------------------
-CMaxCard
-CLogicalPartitionSelector::DeriveMaxCard(CMemoryPool *,         // mp
-                                                                               
 CExpressionHandle &exprhdl) const
-{
-       // pass on max card of first child
-       return exprhdl.DeriveMaxCard(0);
-}
-
-//---------------------------------------------------------------------------
-//     @function:
-//             CLogicalPartitionSelector::PxfsCandidates
-//
-//     @doc:
-//             Get candidate xforms
-//
-//---------------------------------------------------------------------------
-CXformSet *
-CLogicalPartitionSelector::PxfsCandidates(CMemoryPool *mp) const
-{
-       CXformSet *xform_set = GPOS_NEW(mp) CXformSet(mp);
-       (void) xform_set->ExchangeSet(CXform::ExfImplementPartitionSelector);
-       return xform_set;
-}
-
-//---------------------------------------------------------------------------
-//     @function:
-//             CLogicalPartitionSelector::OsPrint
-//
-//     @doc:
-//             Debug print
-//
-//---------------------------------------------------------------------------
-IOstream &
-CLogicalPartitionSelector::OsPrint(IOstream &os) const
-{
-       os << SzId() << ", Part Table: ";
-       m_mdid->OsPrint(os);
-
-       return os;
-}
-
-// EOF
diff --git a/src/backend/gporca/libgpopt/src/operators/Makefile 
b/src/backend/gporca/libgpopt/src/operators/Makefile
index 68872f0e85..56543be11b 100644
--- a/src/backend/gporca/libgpopt/src/operators/Makefile
+++ b/src/backend/gporca/libgpopt/src/operators/Makefile
@@ -64,7 +64,6 @@ OBJS        = CExpression.o \
               CLogicalMaxOneRow.o \
               CLogicalDynamicForeignGet.o \
               CLogicalNAryJoin.o \
-              CLogicalPartitionSelector.o \
               CLogicalProject.o \
               CLogicalRightOuterJoin.o \
               CLogicalSelect.o \
diff --git a/src/backend/gporca/libgpopt/src/xforms/CXformFactory.cpp 
b/src/backend/gporca/libgpopt/src/xforms/CXformFactory.cpp
index 93653c3a98..ccd8070e99 100644
--- a/src/backend/gporca/libgpopt/src/xforms/CXformFactory.cpp
+++ b/src/backend/gporca/libgpopt/src/xforms/CXformFactory.cpp
@@ -270,8 +270,7 @@ CXformFactory::Instantiate()
        Add(GPOS_NEW(m_mp) CXformLeftSemiApplyIn2LeftSemiJoin(m_mp));
        Add(GPOS_NEW(m_mp) 
CXformLeftSemiApplyInWithExternalCorrs2InnerJoin(m_mp));
        Add(GPOS_NEW(m_mp) 
CXformLeftSemiApplyIn2LeftSemiJoinNoCorrelations(m_mp));
-       SkipUnused(1);
-       Add(GPOS_NEW(m_mp) CXformImplementPartitionSelector(m_mp));
+       SkipUnused(2);
        Add(GPOS_NEW(m_mp) CXformMaxOneRow2Assert(m_mp));
        SkipUnused(6);
        Add(GPOS_NEW(m_mp) CXformGbAggWithMDQA2Join(m_mp));
diff --git 
a/src/backend/gporca/libgpopt/src/xforms/CXformImplementPartitionSelector.cpp 
b/src/backend/gporca/libgpopt/src/xforms/CXformImplementPartitionSelector.cpp
deleted file mode 100644
index 5dc18715b5..0000000000
--- 
a/src/backend/gporca/libgpopt/src/xforms/CXformImplementPartitionSelector.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-//---------------------------------------------------------------------------
-//     Greenplum Database
-//     Copyright (C) 2014 VMware, Inc. or its affiliates.
-//
-//     @filename:
-//             CXformImplementPartitionSelector.cpp
-//
-//     @doc:
-//             Implementation of transform
-//---------------------------------------------------------------------------
-
-#include "gpopt/xforms/CXformImplementPartitionSelector.h"
-
-#include "gpos/base.h"
-
-#include "gpopt/operators/CLogicalPartitionSelector.h"
-#include "gpopt/operators/CPatternLeaf.h"
-
-using namespace gpopt;
-
-
-//---------------------------------------------------------------------------
-//     @function:
-//             
CXformImplementPartitionSelector::CXformImplementPartitionSelector
-//
-//     @doc:
-//             Ctor
-//
-//---------------------------------------------------------------------------
-CXformImplementPartitionSelector::CXformImplementPartitionSelector(
-       CMemoryPool *mp)
-       :  // pattern
-         CXformImplementation(GPOS_NEW(mp) CExpression(
-                 mp, GPOS_NEW(mp) CLogicalPartitionSelector(mp),
-                 GPOS_NEW(mp) CExpression(
-                         mp, GPOS_NEW(mp) CPatternLeaf(mp))  // relational 
child
-                 ))
-{
-}
-
-//---------------------------------------------------------------------------
-//     @function:
-//             CXformImplementPartitionSelector::Transform
-//
-//     @doc:
-//             Actual transformation
-//
-//---------------------------------------------------------------------------
-void
-CXformImplementPartitionSelector::Transform(CXformContext *pxfctxt,
-                                                                               
        CXformResult *pxfres GPOS_UNUSED,
-                                                                               
        CExpression *pexpr) const
-{
-       GPOS_ASSERT(nullptr != pxfctxt);
-       GPOS_ASSERT(FPromising(pxfctxt->Pmp(), this, pexpr));
-       GPOS_ASSERT(FCheckPattern(pexpr));
-
-       CMemoryPool *mp = pxfctxt->Pmp();
-
-       // extract components
-       CLogicalPartitionSelector *popSelector =
-               CLogicalPartitionSelector::PopConvert(pexpr->Pop());
-       CExpression *pexprRelational = (*pexpr)[0];
-
-       IMDId *mdid = popSelector->MDId();
-
-       // addref all components
-       pexprRelational->AddRef();
-       mdid->AddRef();
-
-       UlongToExprMap *phmulexprFilter = GPOS_NEW(mp) UlongToExprMap(mp);
-
-       const ULONG ulLevels = popSelector->UlPartLevels();
-       for (ULONG ul = 0; ul < ulLevels; ul++)
-       {
-               CExpression *pexprFilter = popSelector->PexprPartFilter(ul);
-               GPOS_ASSERT(nullptr != pexprFilter);
-               pexprFilter->AddRef();
-               BOOL fInserted GPOS_ASSERTS_ONLY =
-                       phmulexprFilter->Insert(GPOS_NEW(mp) ULONG(ul), 
pexprFilter);
-               GPOS_ASSERT(fInserted);
-       }
-}
-
-// EOF
diff --git a/src/backend/gporca/libgpopt/src/xforms/CXformUpdate2DML.cpp 
b/src/backend/gporca/libgpopt/src/xforms/CXformUpdate2DML.cpp
index c5c13694fb..63828cffb2 100644
--- a/src/backend/gporca/libgpopt/src/xforms/CXformUpdate2DML.cpp
+++ b/src/backend/gporca/libgpopt/src/xforms/CXformUpdate2DML.cpp
@@ -14,7 +14,6 @@
 #include "gpos/base.h"
 
 #include "gpopt/metadata/CTableDescriptor.h"
-#include "gpopt/operators/CLogicalPartitionSelector.h"
 #include "gpopt/operators/CLogicalSplit.h"
 #include "gpopt/operators/CLogicalUpdate.h"
 #include "gpopt/operators/CPatternLeaf.h"
diff --git a/src/backend/gporca/libgpopt/src/xforms/Makefile 
b/src/backend/gporca/libgpopt/src/xforms/Makefile
index f73a9303ef..5e93862ea7 100644
--- a/src/backend/gporca/libgpopt/src/xforms/Makefile
+++ b/src/backend/gporca/libgpopt/src/xforms/Makefile
@@ -55,7 +55,6 @@ OBJS        = CDecorrelator.o \
               CXformImplementDynamicBitmapTableGet.o \
               CXformImplementFullOuterMergeJoin.o \
               CXformImplementLimit.o \
-              CXformImplementPartitionSelector.o \
               CXformImplementSequence.o \
               CXformImplementSequenceProject.o \
               CXformImplementSplit.o \


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to