提交 b446ece5 编写于 作者: D Dhanashree Kashid 提交者: GitHub

Merge pull request #129 from greenplum-db/wip_dbgprint

Included DbgPrint for CCostContext, CGroupExpression & COptimizationContext
......@@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(gpopt LANGUAGES CXX C)
set(GPORCA_VERSION_MAJOR 1)
set(GPORCA_VERSION_MINOR 696)
set(GPORCA_VERSION_MINOR 697)
set(GPORCA_VERSION_STRING ${GPORCA_VERSION_MAJOR}.${GPORCA_VERSION_MINOR})
# Whenever an ABI-breaking change is made to GPORCA, this should be incremented.
......
......@@ -10,7 +10,7 @@ BLD_TOP := $(shell sh -c pwd)
include make/gpo.mk
LIB_NAME = optimizer
LIB_VERSION = 1.696
LIB_VERSION = 1.697
## ----------------------------------------------------------------------
## top level variables; only used in this makefile
## ----------------------------------------------------------------------
......
......@@ -307,6 +307,11 @@ namespace gpopt
virtual
IOstream &OsPrint(IOstream &os) const;
#ifdef GPOS_DEBUG
// debug print; for interactive debugging sessions only
void DbgPrint();
#endif
}; // class CCostContext
......
......@@ -18,6 +18,7 @@
#include "gpopt/base/CReqdPropPlan.h"
#include "gpopt/search/CJobQueue.h"
#include "naucrates/statistics/IStatistics.h"
#include "gpos/task/CAutoTraceFlag.h"
#define GPOPT_INVALID_OPTCTXT_ID ULONG_MAX
......@@ -64,6 +65,9 @@ namespace gpopt
private:
// memory pool
IMemoryPool *m_pmp;
// private copy ctor
COptimizationContext(const COptimizationContext &);
......@@ -103,6 +107,7 @@ namespace gpopt
// private dummy ctor; used for creating invalid context
COptimizationContext()
:
m_pmp(NULL),
m_ulId(GPOPT_INVALID_OPTCTXT_ID),
m_pgroup(NULL),
m_prpp(NULL),
......@@ -135,6 +140,7 @@ namespace gpopt
// ctor
COptimizationContext
(
IMemoryPool *pmp,
CGroup *pgroup,
CReqdPropPlan *prpp,
CReqdPropRelational *prprel, // required relational props -- used during stats derivation
......@@ -142,6 +148,7 @@ namespace gpopt
ULONG ulSearchStageIndex
)
:
m_pmp(pmp),
m_ulId(GPOPT_INVALID_OPTCTXT_ID),
m_pgroup(pgroup),
m_prpp(prpp),
......@@ -265,7 +272,8 @@ namespace gpopt
// debug print
virtual
IOstream &OsPrint(IOstream &os, const CHAR *szPrefix) const;
IOstream &OsPrint(IOstream &os,
const CHAR *szPrefix) const;
// check equality of optimization contexts
static
......@@ -361,6 +369,11 @@ namespace gpopt
static
const OPTCTXT_PTR m_pocInvalid;
#ifdef GPOS_DEBUG
// debug print; for interactive debugging sessions only
void DbgPrint();
#endif // GPOS_DEBUG
}; // class COptimizationContext
}
......
......@@ -299,9 +299,6 @@ namespace gpopt
// debug print; for interactive debugging sessions only
void DbgPrint() const;
// debug print; for interactive debugging sessions only
void DbgPrintProps() const;
#endif // GPOS_DEBUG
// check if the expression satisfies given required properties
......
......@@ -625,6 +625,10 @@ namespace gpopt
// slink for group list in memo
SLink m_link;
#ifdef GPOS_DEBUG
// debug print; for interactive debugging sessions only
void DbgPrint();
#endif
}; // class CGroup
......
......@@ -44,6 +44,11 @@ namespace gpopt
public:
#ifdef GPOS_DEBUG
// debug print; for interactive debugging sessions only
void DbgPrint();
#endif // GPOS_DEBUG
// states of a group expression
enum EState
{
......@@ -67,6 +72,9 @@ namespace gpopt
private:
// memory pool
IMemoryPool *m_pmp;
// definition of context hash table accessor
typedef
CSyncHashtableAccessByKey<
......@@ -189,6 +197,7 @@ namespace gpopt
//private dummy ctor; used for creating invalid gexpr
CGroupExpression()
:
m_pmp(NULL),
m_ulId(GPOPT_INVALID_GEXPR_ID),
m_pop(NULL),
m_pdrgpgroup(NULL),
......
......@@ -672,5 +672,14 @@ CCostContext::OsPrint
return os << std::endl;
}
#ifdef GPOS_DEBUG
void
CCostContext::DbgPrint()
{
CAutoTrace at(m_pmp);
(void) this->OsPrint(at.Os());
}
#endif // GPOS_DEBUG
// EOF
......@@ -33,6 +33,7 @@ const COptimizationContext COptimizationContext::m_ocInvalid;
const OPTCTXT_PTR COptimizationContext::m_pocInvalid = NULL;
//---------------------------------------------------------------------------
// @function:
// COptimizationContext::~COptimizationContext
......@@ -475,6 +476,7 @@ COptimizationContext::OsPrint
)
const
{
os << szPrefix << m_ulId << " (stage " << m_ulSearchStageIndex << "): (" << *m_prpp << ") => Best Expr:";
if (NULL != PgexprBest())
{
......@@ -485,5 +487,15 @@ COptimizationContext::OsPrint
return os;
}
#ifdef GPOS_DEBUG
void
COptimizationContext::DbgPrint()
{
CAutoTraceFlag atf(EopttracePrintOptCtxt, true);
CAutoTrace at(m_pmp);
(void) this->OsPrint(at.Os(), " ");
}
#endif // GPOS_DEBUG
// EOF
......@@ -691,6 +691,7 @@ CEngine::Pmemotmap()
m_pqc->Prpp()->AddRef();
COptimizationContext *poc = GPOS_NEW(m_pmp) COptimizationContext
(
m_pmp,
PgroupRoot(),
m_pqc->Prpp(),
GPOS_NEW(m_pmp) CReqdPropRelational(GPOS_NEW(m_pmp) CColRefSet(m_pmp)), // pass empty required relational properties initially
......@@ -961,6 +962,7 @@ CEngine::PocChild
COptimizationContext *pocChild =
GPOS_NEW(m_pmp) COptimizationContext
(
m_pmp,
pgroupChild,
exprhdlPlan.Prpp(ulChildIndex),
prprel,
......@@ -1343,6 +1345,7 @@ CEngine::RecursiveOptimize()
COptimizationContext *poc =
GPOS_NEW(m_pmp) COptimizationContext
(
m_pmp,
PgroupRoot(),
m_pqc->Prpp(),
GPOS_NEW(m_pmp) CReqdPropRelational(GPOS_NEW(m_pmp) CColRefSet(m_pmp)), // pass empty required relational properties initially
......@@ -1727,6 +1730,7 @@ CEngine::MainThreadOptimize()
m_pqc->Prpp()->AddRef();
COptimizationContext *poc = GPOS_NEW(m_pmp) COptimizationContext
(
m_pmp,
PgroupRoot(),
m_pqc->Prpp(),
GPOS_NEW(m_pmp) CReqdPropRelational(GPOS_NEW(m_pmp) CColRefSet(m_pmp)), // pass empty required relational properties initially
......@@ -1791,6 +1795,7 @@ CEngine::MultiThreadedOptimize
m_pqc->Prpp()->AddRef();
COptimizationContext *poc = GPOS_NEW(m_pmp) COptimizationContext
(
m_pmp,
PgroupRoot(),
m_pqc->Prpp(),
GPOS_NEW(m_pmp) CReqdPropRelational(GPOS_NEW(m_pmp) CColRefSet(m_pmp)), // pass empty required relational properties initially
......
......@@ -1201,24 +1201,6 @@ CExpression::DbgPrint() const
(void) this->OsPrint(at.Os());
}
//---------------------------------------------------------------------------
// @function:
// CExpression::DbgPrintProps
//
// @doc:
// Print driving function for use in interactive debugging;
// always prints to stderr;
// the output includes properties and stats
//
//---------------------------------------------------------------------------
void
CExpression::DbgPrintProps() const
{
CAutoTraceFlag atf(EopttracePrintExprProps, true);
CAutoTrace at(m_pmp);
(void) this->OsPrint(at.Os());
}
#endif // GPOS_DEBUG
//---------------------------------------------------------------------------
......
......@@ -11,9 +11,9 @@
#include "gpos/base.h"
#include "gpos/task/CAutoSuspendAbort.h"
#include "gpos/task/CAutoTraceFlag.h"
#include "gpos/task/CWorker.h"
#include "gpopt/base/CDrvdProp.h"
#include "gpopt/base/CDrvdPropCtxtPlan.h"
#include "gpopt/base/CDrvdPropCtxtRelational.h"
......@@ -288,7 +288,7 @@ CGroup::CleanupContexts()
}
#ifdef GPOS_DEBUG
CWorker::PwrkrSelf()->ResetTimeSlice();
CWorker::PwrkrSelf()->ResetTimeSlice();
#endif // GPOS_DEBUG
}
......@@ -353,6 +353,7 @@ CGroup::PocLookup
prpp->AddRef();
COptimizationContext *poc = GPOS_NEW(pmp) COptimizationContext
(
pmp,
this,
prpp,
GPOS_NEW(pmp) CReqdPropRelational(GPOS_NEW(pmp) CColRefSet(pmp)), // required relational props is not used when looking up contexts
......@@ -1111,6 +1112,7 @@ CGroup::CreateDummyCostContext()
COptimizationContext *poc = GPOS_NEW(m_pmp) COptimizationContext
(
m_pmp,
this,
CReqdPropPlan::PrppEmpty(m_pmp),
GPOS_NEW(m_pmp) CReqdPropRelational(GPOS_NEW(m_pmp) CColRefSet(m_pmp)),
......@@ -2186,6 +2188,24 @@ CGroup::CostLowerBound
return costLowerBound;
}
#ifdef GPOS_DEBUG
//---------------------------------------------------------------------------
// @function:
// CGroup::DbgPrint
//
// @doc:
// Print driving function for use in interactive debugging;
// always prints to stderr;
//
//---------------------------------------------------------------------------
void
CGroup::DbgPrint()
{
CAutoTraceFlag atf(EopttracePrintGrpProps, true);
CAutoTrace at(m_pmp);
(void) this->OsPrint(at.Os());
}
#endif
// EOF
......@@ -54,6 +54,7 @@ CGroupExpression::CGroupExpression
BOOL fIntermediate
)
:
m_pmp(pmp),
m_ulId(GPOPT_INVALID_GEXPR_ID),
m_pgexprDuplicate(NULL),
m_pop(pop),
......@@ -1186,5 +1187,23 @@ CGroupExpression::OsPrint
return os;
}
#ifdef GPOS_DEBUG
//---------------------------------------------------------------------------
// @function:
// CGroupExpression::DbgPrint
//
// @doc:
// Print driving function for use in interactive debugging;
// always prints to stderr;
//
//---------------------------------------------------------------------------
void
CGroupExpression::DbgPrint()
{
CAutoTraceFlag atf(EopttracePrintGrpProps, true);
CAutoTrace at(m_pmp);
(void) this->OsPrint(at.Os());
}
#endif // GPOS_DEBUG
// EOF
......@@ -421,6 +421,7 @@ CJobGroupExpressionOptimization::ScheduleChildGroupsJobs
// schedule optimization job for current child group
COptimizationContext *pocChild = GPOS_NEW(psc->PmpGlobal()) COptimizationContext
(
psc->PmpGlobal(),
pgroupChild,
m_pexprhdlPlan->Prpp(m_ulChildIndex),
prprel,
......
......@@ -92,6 +92,7 @@ COptimizationJobsTest::EresUnittest_StateMachine()
pqc->Prpp()->AddRef();
COptimizationContext *poc = GPOS_NEW(pmp) COptimizationContext
(
pmp,
pgroup,
pqc->Prpp(),
GPOS_NEW(pmp) CReqdPropRelational(GPOS_NEW(pmp) CColRefSet(pmp)),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册