本文整理汇总了C++中SeqScanPlanNode类的典型用法代码示例。如果您正苦于以下问题:C++ SeqScanPlanNode类的具体用法?C++ SeqScanPlanNode怎么用?C++ SeqScanPlanNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SeqScanPlanNode类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: VOLT_TRACE
bool SeqScanExecutor::p_init(AbstractPlanNode* abstract_node,
TempTableLimits* limits)
{
VOLT_TRACE("init SeqScan Executor");
SeqScanPlanNode* node = dynamic_cast<SeqScanPlanNode*>(abstract_node);
assert(node);
assert(node->getTargetTable());
//
// OPTIMIZATION: If there is no predicate for this SeqScan,
// then we want to just set our OutputTable pointer to be the
// pointer of our TargetTable. This prevents us from just
// reading through the entire TargetTable and copying all of
// the tuples. We are guarenteed that no Executor will ever
// modify an input table, so this operation is safe
//
if (!this->needsOutputTableClear())
{
node->setOutputTable(node->getTargetTable());
}
//
// Otherwise create a new temp table that mirrors the
// output schema specified in the plan (which should mirror
// the output schema for any inlined projection)
//
else
{
// Create output table based on output schema from the plan
setTempOutputTable(limits, node->getTargetTable()->name());
}
return true;
}
示例2: needsOutputTableClear
bool SeqScanExecutor::needsOutputTableClear() {
// clear the temporary output table only when it has a predicate.
// if it doesn't have a predicate, it's the original persistent table
// and we don't have to (and must not) clear it.
SeqScanPlanNode* node = dynamic_cast<SeqScanPlanNode*>(m_abstractNode);
assert(node);
return node->needsOutputTableClear();
}
示例3: VOLT_TRACE
bool SeqScanExecutor::p_init(AbstractPlanNode* abstract_node,
TempTableLimits* limits)
{
VOLT_TRACE("init SeqScan Executor");
SeqScanPlanNode* node = dynamic_cast<SeqScanPlanNode*>(abstract_node);
assert(node);
assert(node->getTargetTable());
//
// OPTIMIZATION: If there is no predicate for this SeqScan,
// then we want to just set our OutputTable pointer to be the
// pointer of our TargetTable. This prevents us from just
// reading through the entire TargetTable and copying all of
// the tuples. We are guarenteed that no Executor will ever
// modify an input table, so this operation is safe
//
if (!this->needsOutputTableClear())
{
node->setOutputTable(node->getTargetTable());
}
//
// Otherwise create a new temp table that mirrors the
// output schema specified in the plan (which should mirror
// the output schema for any inlined projection)
//
else
{
TupleSchema* schema = node->generateTupleSchema(true);
int column_count = static_cast<int>(node->getOutputSchema().size());
std::string* column_names = new std::string[column_count];
for (int ctr = 0; ctr < column_count; ctr++)
{
column_names[ctr] = node->getOutputSchema()[ctr]->getColumnName();
}
node->setOutputTable(TableFactory::getTempTable(node->databaseId(),
node->getTargetTable()->name(),
schema,
column_names,
limits));
delete[] column_names;
}
return true;
}
示例4: VOLT_TRACE
bool SeqScanExecutor::p_init(AbstractPlanNode* abstract_node,
TempTableLimits* limits)
{
VOLT_TRACE("init SeqScan Executor");
SeqScanPlanNode* node = dynamic_cast<SeqScanPlanNode*>(abstract_node);
assert(node);
bool isSubquery = node->isSubQuery();
assert(isSubquery || node->getTargetTable());
assert((! isSubquery) || (node->getChildren().size() == 1));
//
// OPTIMIZATION: If there is no predicate for this SeqScan,
// then we want to just set our OutputTable pointer to be the
// pointer of our TargetTable. This prevents us from just
// reading through the entire TargetTable and copying all of
// the tuples. We are guarenteed that no Executor will ever
// modify an input table, so this operation is safe
//
if (node->getPredicate() != NULL || node->getInlinePlanNodes().size() > 0) {
// Create output table based on output schema from the plan
const std::string& temp_name = (node->isSubQuery()) ?
node->getChildren()[0]->getOutputTable()->name():
node->getTargetTable()->name();
setTempOutputTable(limits, temp_name);
}
//
// Otherwise create a new temp table that mirrors the
// output schema specified in the plan (which should mirror
// the output schema for any inlined projection)
//
else {
node->setOutputTable(isSubquery ?
node->getChildren()[0]->getOutputTable() :
node->getTargetTable());
}
// Inline aggregation can be serial, partial or hash
m_aggExec = voltdb::getInlineAggregateExecutor(node);
return true;
}
示例5: p_execute
bool SeqScanExecutor::p_execute(const NValueArray ¶ms) {
SeqScanPlanNode* node = dynamic_cast<SeqScanPlanNode*>(m_abstractNode);
assert(node);
Table* output_table = node->getOutputTable();
assert(output_table);
Table* input_table = (node->isSubQuery()) ?
node->getChildren()[0]->getOutputTable():
node->getTargetTable();
assert(input_table);
//* for debug */std::cout << "SeqScanExecutor: node id " << node->getPlanNodeId() <<
//* for debug */ " input table " << (void*)input_table <<
//* for debug */ " has " << input_table->activeTupleCount() << " tuples " << std::endl;
VOLT_TRACE("Sequential Scanning table :\n %s",
input_table->debug().c_str());
VOLT_DEBUG("Sequential Scanning table : %s which has %d active, %d"
" allocated",
input_table->name().c_str(),
(int)input_table->activeTupleCount(),
(int)input_table->allocatedTupleCount());
//
// OPTIMIZATION: NESTED PROJECTION
//
// Since we have the input params, we need to call substitute to
// change any nodes in our expression tree to be ready for the
// projection operations in execute
//
int num_of_columns = -1;
ProjectionPlanNode* projection_node = dynamic_cast<ProjectionPlanNode*>(node->getInlinePlanNode(PLAN_NODE_TYPE_PROJECTION));
if (projection_node != NULL) {
num_of_columns = static_cast<int> (projection_node->getOutputColumnExpressions().size());
}
//
// OPTIMIZATION: NESTED LIMIT
// How nice! We can also cut off our scanning with a nested limit!
//
LimitPlanNode* limit_node = dynamic_cast<LimitPlanNode*>(node->getInlinePlanNode(PLAN_NODE_TYPE_LIMIT));
//
// OPTIMIZATION:
//
// If there is no predicate and no Projection for this SeqScan,
// then we have already set the node's OutputTable to just point
// at the TargetTable. Therefore, there is nothing we more we need
// to do here
//
if (node->getPredicate() != NULL || projection_node != NULL ||
limit_node != NULL || m_aggExec != NULL)
{
//
// Just walk through the table using our iterator and apply
// the predicate to each tuple. For each tuple that satisfies
// our expression, we'll insert them into the output table.
//
TableTuple tuple(input_table->schema());
TableIterator iterator = input_table->iteratorDeletingAsWeGo();
AbstractExpression *predicate = node->getPredicate();
if (predicate)
{
VOLT_TRACE("SCAN PREDICATE A:\n%s\n", predicate->debug(true).c_str());
}
int limit = -1;
int offset = -1;
if (limit_node) {
limit_node->getLimitAndOffsetByReference(params, limit, offset);
}
int tuple_ctr = 0;
int tuple_skipped = 0;
TempTable* output_temp_table = dynamic_cast<TempTable*>(output_table);
ProgressMonitorProxy pmp(m_engine, this, node->isSubQuery() ? NULL : input_table);
TableTuple temp_tuple;
if (m_aggExec != NULL) {
const TupleSchema * inputSchema = input_table->schema();
if (projection_node != NULL) {
inputSchema = projection_node->getOutputTable()->schema();
}
temp_tuple = m_aggExec->p_execute_init(params, &pmp,
inputSchema, output_temp_table);
} else {
temp_tuple = output_temp_table->tempTuple();
}
while ((limit == -1 || tuple_ctr < limit) && iterator.next(tuple))
{
VOLT_TRACE("INPUT TUPLE: %s, %d/%d\n",
tuple.debug(input_table->name()).c_str(), tuple_ctr,
(int)input_table->activeTupleCount());
pmp.countdownProgress();
//
// For each tuple we need to evaluate it against our predicate
//
if (predicate == NULL || predicate->eval(&tuple, NULL).isTrue())
{
//.........这里部分代码省略.........
示例6: p_execute
bool SeqScanExecutor::p_execute(const NValueArray ¶ms) {
SeqScanPlanNode* node = dynamic_cast<SeqScanPlanNode*>(m_abstractNode);
assert(node);
Table* output_table = node->getOutputTable();
assert(output_table);
Table* target_table = dynamic_cast<Table*>(node->getTargetTable());
assert(target_table);
//cout << "SeqScanExecutor: node id" << node->getPlanNodeId() << endl;
VOLT_TRACE("Sequential Scanning table :\n %s",
target_table->debug().c_str());
VOLT_DEBUG("Sequential Scanning table : %s which has %d active, %d"
" allocated, %d used tuples",
target_table->name().c_str(),
(int)target_table->activeTupleCount(),
(int)target_table->allocatedTupleCount(),
(int)target_table->usedTupleCount());
//
// OPTIMIZATION: NESTED PROJECTION
//
// Since we have the input params, we need to call substitute to
// change any nodes in our expression tree to be ready for the
// projection operations in execute
//
int num_of_columns = (int)output_table->columnCount();
ProjectionPlanNode* projection_node = dynamic_cast<ProjectionPlanNode*>(node->getInlinePlanNode(PLAN_NODE_TYPE_PROJECTION));
if (projection_node != NULL) {
for (int ctr = 0; ctr < num_of_columns; ctr++) {
assert(projection_node->getOutputColumnExpressions()[ctr]);
projection_node->getOutputColumnExpressions()[ctr]->substitute(params);
}
}
//
// OPTIMIZATION: NESTED LIMIT
// How nice! We can also cut off our scanning with a nested limit!
//
int limit = -1;
int offset = -1;
LimitPlanNode* limit_node = dynamic_cast<LimitPlanNode*>(node->getInlinePlanNode(PLAN_NODE_TYPE_LIMIT));
if (limit_node != NULL) {
limit_node->getLimitAndOffsetByReference(params, limit, offset);
}
//
// OPTIMIZATION:
//
// If there is no predicate and no Projection for this SeqScan,
// then we have already set the node's OutputTable to just point
// at the TargetTable. Therefore, there is nothing we more we need
// to do here
//
if (node->getPredicate() != NULL || projection_node != NULL ||
limit_node != NULL)
{
//
// Just walk through the table using our iterator and apply
// the predicate to each tuple. For each tuple that satisfies
// our expression, we'll insert them into the output table.
//
TableTuple tuple(target_table->schema());
TableIterator iterator = target_table->iterator();
AbstractExpression *predicate = node->getPredicate();
VOLT_TRACE("SCAN PREDICATE A:\n%s\n", predicate->debug(true).c_str());
if (predicate)
{
predicate->substitute(params);
assert(predicate != NULL);
VOLT_DEBUG("SCAN PREDICATE B:\n%s\n",
predicate->debug(true).c_str());
}
int tuple_ctr = 0;
int tuple_skipped = 0;
while (iterator.next(tuple))
{
VOLT_TRACE("INPUT TUPLE: %s, %d/%d\n",
tuple.debug(target_table->name()).c_str(), tuple_ctr,
(int)target_table->activeTupleCount());
//
// For each tuple we need to evaluate it against our predicate
//
if (predicate == NULL || predicate->eval(&tuple, NULL).isTrue())
{
// Check if we have to skip this tuple because of offset
if (tuple_skipped < offset) {
tuple_skipped++;
continue;
}
//
// Nested Projection
// Project (or replace) values from input tuple
//
if (projection_node != NULL)
{
TableTuple &temp_tuple = output_table->tempTuple();
for (int ctr = 0; ctr < num_of_columns; ctr++)
{
//.........这里部分代码省略.........
示例7: VOLT_TRACE
bool SeqScanExecutor::p_init(AbstractPlanNode *abstract_node,
const catalog::Database* catalog_db,
int* tempTableMemoryInBytes) {
VOLT_TRACE("init SeqScan Executor");
SeqScanPlanNode* node = dynamic_cast<SeqScanPlanNode*>(abstract_node);
assert(node);
assert(node->getTargetTable());
//
// NESTED PROJECTION
//
if (node->getInlinePlanNode(PLAN_NODE_TYPE_PROJECTION) != NULL) {
//std::cout << "Inline node:" << node->getInlinePlanNode(PLAN_NODE_TYPE_PROJECTION)->debug() << std::endl;
ProjectionPlanNode* projection_node = static_cast<ProjectionPlanNode*>(node->getInlinePlanNode(PLAN_NODE_TYPE_PROJECTION));
assert(projection_node);
//
// The internal node will already be initialized for us
//
// We just need to use the internal node's output table which
// has been formatted correctly based on the projection
// information as our own output table
//
assert(projection_node->getOutputTable());
node->setOutputTable(projection_node->getOutputTable());
//
// FULL TABLE SCHEMA
//
} else {
//
// OPTIMIZATION: If there is no predicate for this SeqScan,
// then we want to just set our OutputTable pointer to be the
// pointer of our TargetTable. This prevents us from just
// reading through the entire TargetTable and copying all of
// the tuples. We are guarenteed that no Executor will ever
// modify an input table, so this operation is safe
//
if (!this->needsOutputTableClear()) {
node->setOutputTable(node->getTargetTable());
//
// Otherwise create a new temp table that mirrors the
// TargetTable so that we can just copy the tuples right into
// it. For now we are always use all of the columns, but in
// the future we may want to have a projection work right
// inside of the SeqScan
//
} else {
node->setOutputTable(TableFactory::getCopiedTempTable(node->databaseId(),
node->getTargetTable()->name(),
node->getTargetTable(),
tempTableMemoryInBytes));
}
}
return true;
}
示例8: TEST_F
TEST_F(CommonTableExpressionTest, verifyPlan) {
UniqueEngine engine = UniqueEngineBuilder().build();
bool success = engine->loadCatalog(0, catalogPayload);
ASSERT_TRUE(success);
auto ev = ExecutorVector::fromJsonPlan(engine.get(), jsonPlan, 0);
ASSERT_NE(NULL, ev.get());
// Verify the outer query
auto execList = ev->getExecutorList(0);
ASSERT_EQ(2, execList.size());
SeqScanPlanNode* seqScanNode = dynamic_cast<SeqScanPlanNode*>(execList[0]->getPlanNode());
ASSERT_NE(NULL, seqScanNode);
ASSERT_TRUE(seqScanNode->isCteScan());
ASSERT_EQ(1, seqScanNode->getCteStmtId());
ASSERT_EQ("EMP_PATH", seqScanNode->getTargetTableName());
ASSERT_NE(std::string::npos, seqScanNode->debugInfo("").find("TargetTable[EMP_PATH], scanType[CTE_SCAN]"));
OrderByPlanNode* obNode = dynamic_cast<OrderByPlanNode*>(execList[1]->getPlanNode());
ASSERT_NE(NULL, obNode);
// verify the common table executor node and the base case
execList = ev->getExecutorList(1);
ASSERT_EQ(2, execList.size());
seqScanNode = dynamic_cast<SeqScanPlanNode*>(execList[0]->getPlanNode());
ASSERT_NE(NULL, seqScanNode);
ASSERT_TRUE(seqScanNode->isPersistentTableScan());
ASSERT_EQ(-1, seqScanNode->getCteStmtId());
ASSERT_EQ("EMPLOYEES", seqScanNode->getTargetTableName());
ASSERT_NE(std::string::npos,
seqScanNode->debugInfo("").find("TargetTable[EMPLOYEES], scanType[PERSISTENT_TABLE_SCAN]"));
CommonTablePlanNode* ctPlanNode = dynamic_cast<CommonTablePlanNode*>(execList[1]->getPlanNode());
ASSERT_NE(NULL, ctPlanNode);
ASSERT_EQ(2, ctPlanNode->getRecursiveStmtId());
ASSERT_EQ("EMP_PATH", ctPlanNode->getCommonTableName());
ASSERT_NE(std::string::npos,
ctPlanNode->debugInfo("").find("CommonTable[EMP_PATH], with recursive stmt id[2]"));
// verify the recursive query
execList = ev->getExecutorList(2);
ASSERT_EQ(4, execList.size());
// LHS of join is a normal scan of EMPLOYEES
seqScanNode = dynamic_cast<SeqScanPlanNode*>(execList[0]->getPlanNode());
ASSERT_NE(NULL, seqScanNode);
ASSERT_TRUE(seqScanNode->isPersistentTableScan());
ASSERT_EQ(-1, seqScanNode->getCteStmtId());
ASSERT_EQ("EMPLOYEES", seqScanNode->getTargetTableName());
// RHS of join is the intermediate result of the recursive CTE
seqScanNode = dynamic_cast<SeqScanPlanNode*>(execList[1]->getPlanNode());
ASSERT_NE(NULL, seqScanNode);
ASSERT_TRUE(seqScanNode->isCteScan());
ASSERT_EQ(1, seqScanNode->getCteStmtId());
ASSERT_EQ("EMP_PATH", seqScanNode->getTargetTableName());
ASSERT_NE(std::string::npos, seqScanNode->debugInfo("").find("TargetTable[EMP_PATH], scanType[CTE_SCAN]"));
AbstractJoinPlanNode* joinNode = dynamic_cast<AbstractJoinPlanNode*>(execList[2]->getPlanNode());
ASSERT_NE(NULL, joinNode);
ProjectionPlanNode* projNode = dynamic_cast<ProjectionPlanNode*>(execList[3]->getPlanNode());
ASSERT_NE(NULL, projNode);
}