当前位置: 首页>>代码示例>>C++>>正文


C++ Catalog::getTable方法代码示例

本文整理汇总了C++中Catalog::getTable方法的典型用法代码示例。如果您正苦于以下问题:C++ Catalog::getTable方法的具体用法?C++ Catalog::getTable怎么用?C++ Catalog::getTable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Catalog的用法示例。


在下文中一共展示了Catalog::getTable方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: init_tt_environment

// For testing
static void init_tt_environment() {
  Environment::getInstance(true);
  sleep(1);
  ResourceManagerMaster* rmms =
      Environment::getInstance()->getResourceManagerMaster();
  Catalog* catalog = Environment::getInstance()->getCatalog();

  // num int not null, s int, ss int primary key, c char, vc varchar(10)
  TableDescriptor* table_1 = new TableDescriptor("tt", 2);
  table_1->addAttribute("row_id", data_type(t_u_long));  // 0
  table_1->addAttribute("num", data_type(t_int));
  table_1->addAttribute("s", data_type(t_int));
  table_1->addAttribute("ss", data_type(t_int));
  table_1->addAttribute("c", data_type(t_string), 4);
  table_1->addAttribute("vc", data_type(t_string), 10);  // 5

  vector<ColumnOffset> proj_0;
  proj_0.push_back(0);
  proj_0.push_back(1);
  proj_0.push_back(2);
  proj_0.push_back(3);
  proj_0.push_back(4);
  proj_0.push_back(5);
  const int partition_key_index_1 = 1;
  table_1->createHashPartitionedProjection(proj_0, "num", 1);  // G0

  catalog->add_table(table_1);

  for (unsigned i = 0;
       i < table_1->getProjectoin(0)->getPartitioner()->getNumberOfPartitions();
       i++) {
    catalog->getTable(2)->getProjectoin(0)->getPartitioner()->RegisterPartition(
        i, 1);
  }
}
开发者ID:JolyZhang,项目名称:CLAIMS,代码行数:36,代码来源:test_IndexManager_serialize.cpp

示例2: init_single_node_tpc_h_envoriment_ing

static void init_single_node_tpc_h_envoriment_ing(bool master = true) {
  Environment::getInstance(master);
  printf("Press any key to continue!\n");
  int input;
  scanf("%d", &input);
  ResourceManagerMaster* rmms =
      Environment::getInstance()->getResourceManagerMaster();
  Catalog* catalog = Environment::getInstance()->getCatalog();

  /////////////////////////////// LINEITEM TABLE
  /////////////////////////////////////
  TableDescriptor* table_1 = new TableDescriptor("LINEITEM", 0);
  table_1->addAttribute("row_id", data_type(t_u_long));
  table_1->addAttribute("L_ORDERKEY", data_type(t_u_long));  // 0
  table_1->addAttribute("L_PARTKEY", data_type(t_u_long));
  table_1->addAttribute("L_SUPPKEY", data_type(t_u_long));
  table_1->addAttribute("L_LINENUMBER", data_type(t_u_long));
  table_1->addAttribute("L_QUANTITY", data_type(t_decimal));
  table_1->addAttribute("L_EXTENDEDPRICE", data_type(t_decimal));
  table_1->addAttribute("L_DISCOUNT", data_type(t_decimal));
  table_1->addAttribute("L_TEX", data_type(t_decimal));
  table_1->addAttribute("L_RETURNFLAG", data_type(t_string), 1);
  table_1->addAttribute("L_LINESTATUS", data_type(t_string), 1);
  table_1->addAttribute("L_SHIPDATE", data_type(t_date));
  table_1->addAttribute("L_COMMITDATE", data_type(t_date));
  table_1->addAttribute("L_RECEIPTDATE", data_type(t_date));
  table_1->addAttribute("L_SHIPINSTRUCT", data_type(t_string), 25);
  table_1->addAttribute("L_SHIPMODE", data_type(t_string), 10);
  table_1->addAttribute("L_COMMENT", data_type(t_string), 44);

  table_1->createHashPartitionedProjectionOnAllAttribute(
      table_1->getAttribute(1).getName(), 1);

  catalog->add_table(table_1);

  for (unsigned i = 0;
       i < table_1->getProjectoin(0)->getPartitioner()->getNumberOfPartitions();
       i++) {
    catalog->getTable(0)->getProjectoin(0)->getPartitioner()->RegisterPartition(
        i, 1);
  }
}
开发者ID:JolyZhang,项目名称:CLAIMS,代码行数:42,代码来源:issue27ing.cpp

示例3: init_poc_environment

static void init_poc_environment() {
  Environment::getInstance(true);
  sleep(1);
  ResourceManagerMaster* rmms =
      Environment::getInstance()->getResourceManagerMaster();
  Catalog* catalog = Environment::getInstance()->getCatalog();

  TableDescriptor* table_1 = new TableDescriptor(
      "cj",
      Environment::getInstance()->getCatalog()->allocate_unique_table_id());
  table_1->addAttribute("row_id", data_type(t_u_long));  // 0
  table_1->addAttribute("trade_date", data_type(t_int));
  table_1->addAttribute("order_no", data_type(t_u_long));
  table_1->addAttribute("sec_code", data_type(t_int));
  table_1->addAttribute("trade_dir", data_type(t_int));
  table_1->addAttribute("order_type", data_type(t_int));  // 5

  vector<ColumnOffset> cj_proj0_index;
  cj_proj0_index.push_back(0);
  cj_proj0_index.push_back(1);
  cj_proj0_index.push_back(2);
  cj_proj0_index.push_back(3);
  cj_proj0_index.push_back(4);
  cj_proj0_index.push_back(5);
  const int partition_key_index_1 = 2;
  table_1->createHashPartitionedProjection(cj_proj0_index, "order_no",
                                           1);  // G0

  catalog->add_table(table_1);

  for (unsigned i = 0;
       i < table_1->getProjectoin(0)->getPartitioner()->getNumberOfPartitions();
       i++) {
    catalog->getTable(0)->getProjectoin(0)->getPartitioner()->RegisterPartition(
        i, 2);
  }
}
开发者ID:JolyZhang,项目名称:CLAIMS,代码行数:37,代码来源:test_IndexManager_serialize.cpp

示例4: 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();
}
开发者ID:egraldlo,项目名称:CLAIMS,代码行数:80,代码来源:Analyzer.cpp

示例5: 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;
}
开发者ID:yestodaylee,项目名称:CLAIMS,代码行数:84,代码来源:Analyzer.cpp


注:本文中的Catalog::getTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。