本文整理汇总了C++中TableDescriptor::getNumberOfProjection方法的典型用法代码示例。如果您正苦于以下问题:C++ TableDescriptor::getNumberOfProjection方法的具体用法?C++ TableDescriptor::getNumberOfProjection怎么用?C++ TableDescriptor::getNumberOfProjection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TableDescriptor
的用法示例。
在下文中一共展示了TableDescriptor::getNumberOfProjection方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SemanticAnalisys
RetCode AstLoadTable::SemanticAnalisys(SemanticContext* sem_cnxt) {
RetCode ret = rSuccess;
TableDescriptor* table =
Environment::getInstance()->getCatalog()->getTable(table_name_);
if (NULL == table) {
sem_cnxt->error_msg_ =
"the table " + table_name_ + " does not exist during loading!";
ret = rTableNotExisted;
return ret;
}
if (0 == table->getNumberOfProjection()) {
sem_cnxt->error_msg_ = "the table has not been created a projection!";
ret = rNoProjection;
return ret;
}
return ret;
}
示例2: analyse
void Analyzer::analyse(const AttributeID &attrID) {
Catalog *catalog = Catalog::getInstance();
TableDescriptor* table = catalog->getTable(attrID.table_id);
ProjectionDescriptor * projection = NULL;
unsigned pidSize = table->getNumberOfProjection();
const Attribute attr = table->getAttribute(attrID.offset);
for (unsigned i = 0; i < pidSize; ++i) {
if (table->getProjectoin(i)->hasAttribute(attr)) {
projection = table->getProjectoin(i);
break;
}
}
std::vector<Attribute> group_by_attributes;
std::vector<Attribute> aggregation_attributes;
group_by_attributes.push_back(attr);
aggregation_attributes.push_back(attr);
std::vector<BlockStreamAggregationIterator::State::aggregation> aggregation_function;
aggregation_function.push_back(
BlockStreamAggregationIterator::State::count);
LogicalOperator* sb_payload_scan = new LogicalScan(projection);
LogicalOperator* aggregation = new Aggregation(group_by_attributes,
aggregation_attributes, aggregation_function, sb_payload_scan);
const NodeID collector_node_id = 0;
LogicalOperator* root = new LogicalQueryPlanRoot(collector_node_id,
aggregation, LogicalQueryPlanRoot::RESULTCOLLECTOR);
BlockStreamIteratorBase* collector = root->getIteratorTree(
1024 * 64 - sizeof(unsigned));
collector->open();
collector->next(0);
collector->close();
ResultSet* resultset = collector->getResultSet();
ResultSet::Iterator it = resultset->createIterator();
BlockStreamBase* block;
void* tuple;
BlockStreamBase::BlockStreamTraverseIterator *block_it;
unsigned long valueCount = resultset->getNumberOftuples();
unsigned long tupleCount = 0;
TuplePtr *list = new TuplePtr[valueCount];
unsigned long i = 0;
while (block = (BlockStreamBase*) it.atomicNextBlock()) {
block_it = block->createIterator();
while (tuple = block_it->nextTuple()) {
list[i++] = tuple;
tupleCount += getFrequency(tuple, attr.attrType);
}
}
int magicNumber = 100;
StatisticOnTable *stat = new StatisticOnTable(magicNumber);
stat->setValueCount(valueCount);
stat->setTupleCount(tupleCount);
qsort_r(list, valueCount, sizeof(void *), compare,
(void *) (attr.attrType->operate));
mcvAnalyse(list, valueCount, attr, (Histogram *) stat);
equiDepthAnalyse(list, valueCount, attr, (Histogram *) stat);
// StatManager::getInstance()->addStat(attrID, stat);
StatManager::getInstance()->getTableStatistic(attrID.table_id);
delete list;
resultset->destory();
}
示例3: computeHistogram
Histogram* Analyzer::computeHistogram(const AttributeID& attr_id,
const unsigned nbuckets) {
printf("Compute for histogram for attribute %s (%d buckets)\n",
Catalog::getInstance()
->getTable(attr_id.table_id)
->getAttribute(attr_id.offset)
.attrName.c_str(),
nbuckets);
Catalog* catalog = Catalog::getInstance();
TableDescriptor* table = catalog->getTable(attr_id.table_id);
ProjectionDescriptor* projection = NULL;
unsigned pidSize = table->getNumberOfProjection();
const Attribute attr = table->getAttribute(attr_id.offset);
for (unsigned i = 0; i < pidSize; ++i) {
if (table->getProjectoin(i)->hasAttribute(attr)) {
projection = table->getProjectoin(i);
break;
}
}
std::vector<Attribute> group_by_attributes;
std::vector<Attribute> aggregation_attributes;
group_by_attributes.push_back(attr);
aggregation_attributes.push_back(attr);
std::vector<PhysicalAggregation::State::Aggregation> aggregation_function;
aggregation_function.push_back(PhysicalAggregation::State::kCount);
LogicalOperator* sb_payload_scan = new LogicalScan(projection);
LogicalOperator* aggregation =
new LogicalAggregation(group_by_attributes, aggregation_attributes,
aggregation_function, sb_payload_scan);
const NodeID collector_node_id = 0;
LogicalOperator* root = new LogicalQueryPlanRoot(
collector_node_id, aggregation, LogicalQueryPlanRoot::kResultCollector);
PhysicalOperatorBase* collector =
root->GetPhysicalPlan(1024 * 64 - sizeof(unsigned));
collector->Open();
collector->Next(0);
collector->Close();
ResultSet* resultset = collector->GetResultSet();
ResultSet::Iterator it = resultset->createIterator();
BlockStreamBase* block;
void* tuple;
BlockStreamBase::BlockStreamTraverseIterator* block_it;
unsigned long valueCount = resultset->getNumberOftuples();
unsigned long tupleCount = 0;
TuplePtr* list = new TuplePtr[valueCount];
unsigned long i = 0;
while (block = (BlockStreamBase*)it.atomicNextBlock()) {
block_it = block->createIterator();
while (tuple = block_it->nextTuple()) {
list[i++] = tuple;
tupleCount += getFrequency(tuple, attr.attrType);
}
}
Histogram* stat = new Histogram(nbuckets);
stat->setValueCount(valueCount);
stat->setTupleCount(tupleCount);
qsort_r(list, valueCount, sizeof(void*), compare,
(void*)(attr.attrType->operate));
mcvAnalyse(list, valueCount, attr, (Histogram*)stat);
equiDepthAnalyse(list, valueCount, attr, (Histogram*)stat);
// StatManager::getInstance()->addStat(attrID, stat);
// StatManager::getInstance()->getTableStatistic(attrID.table_id)
delete list;
resultset->destory();
return stat;
}