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


C++ TableDescriptor::getAttribute方法代码示例

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


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

示例1: bulk_test_logical_index_scan

static void bulk_test_logical_index_scan() {
  vector<IndexScanIterator::query_range> q_range;
  int count = 1022;
  ifstream infile("/home/scdong/code/sec_code", ios::in);
  ofstream outfile("/home/scdong/code/fail_log.dat", ios::out);
  unsigned long int value = 0;
  unsigned long int expect_num;
  TableDescriptor* table = Catalog::getInstance()->getTable("cj");
  IndexScanIterator::query_range q2;
  while (count > 0) {
    q_range.clear();
    infile >> value >> expect_num;

    q2.value_low = malloc(sizeof(int));  // newmalloc
    q2.value_low = (void*)(&value);
    q2.comp_low = EQ;
    q2.value_high = malloc(sizeof(int));  // newmalloc
    q2.value_high = (void*)(&value);
    q2.comp_high = EQ;
    q2.c_type.type = t_int;
    q2.c_type.operate = new OperateInt();
    q_range.push_back(q2);

    LogicalOperator* index_scan =
        new LogicalIndexScan(table->getProjectoin(0)->getProjectionID(),
                             table->getAttribute("sec_code"), q_range);
    const NodeID collector_node_id = 0;

    LogicalOperator* root = new LogicalQueryPlanRoot(
        collector_node_id, index_scan, LogicalQueryPlanRoot::kResultCollector);
    PhysicalOperatorBase* executable_query_plan =
        root->GetPhysicalPlan(1024 * 64);
    executable_query_plan->Open();
    while (executable_query_plan->Next(0))
      ;
    executable_query_plan->Close();

    ResultSet* result_set = executable_query_plan->getResultSet();

    const unsigned long int number_of_tuples = result_set->getNumberOftuples();
    executable_query_plan->~PhysicalOperatorBase();
    root->~LogicalOperator();
    cout << 1022 - count << ": Sec_code: " << value
         << "\t Result: " << number_of_tuples << endl;
    if (!print_test_name_result(number_of_tuples == expect_num, "Index Scan")) {
      printf("\tIndex Scan sec_code = %d, Expected:%d actual: %d\n", value,
             expect_num, number_of_tuples);
      outfile << "Index Scan sec_code = " << value << "\tFAIL!\n";
      outfile << "\tExcepted: " << expect_num
              << "\tActual: " << number_of_tuples << endl;
    }
    count--;
  }
}
开发者ID:JolyZhang,项目名称:CLAIMS,代码行数:54,代码来源:test_IndexManager_serialize.cpp

示例2: test_scan_filter_performance

static void test_scan_filter_performance(int value) {
  unsigned long long int start = curtick();
  TableDescriptor* table = Catalog::getInstance()->getTable("cj");
  LogicalOperator* cj_scan = new LogicalScan(table->getProjectoin(0));

  LogicalFilter::Condition filter_condition_1;
  filter_condition_1.add(table->getAttribute(3), AttributeComparator::GEQ,
                         std::string("10107"));
  filter_condition_1.add(table->getAttribute(3), AttributeComparator::L,
                         (void*)&value);
  LogicalOperator* filter_1 = new LogicalFilter(filter_condition_1, cj_scan);

  const NodeID collector_node_id = 0;
  LogicalOperator* root = new LogicalQueryPlanRoot(
      collector_node_id, filter_1, LogicalQueryPlanRoot::PERFORMANCE);

  PerformanceMonitor* executable_query_plan =
      (PerformanceMonitor*)root->GetPhysicalPlan(1024 * 64);
  //	executable_query_plan->print();
  executable_query_plan->Open();
  while (executable_query_plan->Next(0))
    ;
  executable_query_plan->Close();

  //	ResultSet *result_set=executable_query_plan->getResultSet();

  const unsigned long int number_of_tuples =
      executable_query_plan->GetNumberOfTuples();
  printf("execution time: %4.4f seconds.\n", getSecond(start));
  if (!print_test_name_result(number_of_tuples == 26820,
                              "Low selectivity filter")) {
    printf("\tExpected:26695 actual: %d\n", number_of_tuples);
  }
  //	result_set->~ResultSet();
  delete executable_query_plan;
  root->~LogicalOperator();
}
开发者ID:JolyZhang,项目名称:CLAIMS,代码行数:37,代码来源:test_IndexManager_serialize.cpp

示例3: test_index_filter_performance

static void test_index_filter_performance(int value_high) {
  unsigned long long int start = curtick();
  vector<IndexScanIterator::query_range> q_range;
  q_range.clear();
  int value_low = 10107;
  //	int value_high = 600257;
  TableDescriptor* table = Catalog::getInstance()->getTable("cj");

  IndexScanIterator::query_range q;
  q.value_low = malloc(sizeof(int));  // newmalloc
  q.value_low = (void*)(&value_low);
  q.comp_low = GEQ;
  q.value_high = malloc(sizeof(int));  // newmalloc
  q.value_high = (void*)(&value_high);
  q.comp_high = L;
  q.c_type.type = t_int;
  q.c_type.operate = new OperateInt();
  q_range.push_back(q);

  LogicalOperator* index_scan =
      new LogicalIndexScan(table->getProjectoin(0)->getProjectionID(),
                           table->getAttribute("sec_code"), q_range);
  const NodeID collector_node_id = 0;
  LogicalOperator* root = new LogicalQueryPlanRoot(
      collector_node_id, index_scan, LogicalQueryPlanRoot::PERFORMANCE);
  //	root->print();

  PerformanceMonitor* executable_query_plan =
      (PerformanceMonitor*)root->GetPhysicalPlan(1024 * 64);
  executable_query_plan->Open();
  while (executable_query_plan->Next(0))
    ;
  executable_query_plan->Close();

  //	ResultSet* result_set = executable_query_plan->getResultSet();

  const unsigned long int number_of_tuples =
      executable_query_plan->GetNumberOfTuples();
  delete executable_query_plan;
  root->~LogicalOperator();
  //	cout << "Sec_code: " << value_low << "\t Result: " << number_of_tuples
  //<< endl;
  printf("execution time: %4.4f seconds.\n", getSecond(start));
  if (!print_test_name_result(number_of_tuples == 26820, "Index Scan")) {
    printf("\tIndex Scan sec_code = %d, Expected:%d actual: %d\n", value_low,
           26820, number_of_tuples);
  }
}
开发者ID:JolyZhang,项目名称:CLAIMS,代码行数:48,代码来源:test_IndexManager_serialize.cpp

示例4: test_logical_index_building

static void test_logical_index_building() {
  TableDescriptor* table = Catalog::getInstance()->getTable("cj");
  LogicalOperator* csb_building =
      new LogicalCSBIndexBuilding(table->getProjectoin(0)->getProjectionID(),
                                  table->getAttribute(3), "sec_code_index");
  const NodeID collector_node_id = 0;
  LogicalOperator* root = new LogicalQueryPlanRoot(
      collector_node_id, csb_building, LogicalQueryPlanRoot::kResultCollector);
  root->Print();
  PhysicalOperatorBase* executable_query_plan =
      root->GetPhysicalPlan(1024 * 64);
  executable_query_plan->Open();
  while (executable_query_plan->Next(0))
    ;
  executable_query_plan->Close();

  //	ResultSet* result_set = executable_query_plan->getResultSet();

  executable_query_plan->~PhysicalOperatorBase();
  root->~LogicalOperator();
  cout << "index building finished!\n";
}
开发者ID:JolyZhang,项目名称:CLAIMS,代码行数:22,代码来源:test_IndexManager_serialize.cpp

示例5: test_logical_index_scan

static void test_logical_index_scan() {
  vector<IndexScanIterator::query_range> q_range;
  TableDescriptor* table = Catalog::getInstance()->getTable("cj");
  IndexScanIterator::query_range q;
  int value = 0;
  while (true) {
    q_range.clear();
    cout << "Input the search sec_code: ";
    cin >> value;

    q.value_low = malloc(sizeof(int));  // newmalloc
    q.value_low = (void*)(&value);
    q.comp_low = EQ;
    q.value_high = malloc(sizeof(int));  // newmalloc
    q.value_high = (void*)(&value);
    q.comp_high = EQ;
    q.c_type.type = t_int;
    q.c_type.operate = new OperateInt();
    q_range.push_back(q);

    LogicalOperator* index_scan =
        new LogicalIndexScan(table->getProjectoin(0)->getProjectionID(),
                             table->getAttribute("sec_code"), q_range);
    const NodeID collector_node_id = 0;

    LogicalOperator* root = new LogicalQueryPlanRoot(
        collector_node_id, index_scan, LogicalQueryPlanRoot::kPrint);
    PhysicalOperatorBase* executable_query_plan =
        root->GetPhysicalPlan(1024 * 64);
    executable_query_plan->Open();
    while (executable_query_plan->Next(0))
      ;
    executable_query_plan->Close();
    executable_query_plan->~PhysicalOperatorBase();
    root->~LogicalOperator();
  }
}
开发者ID:JolyZhang,项目名称:CLAIMS,代码行数:37,代码来源:test_IndexManager_serialize.cpp

示例6: query_select_aggregation


//.........这里部分代码省略.........
  expr1.push_back(ei1_5);

  //	expr1.push_back(ei1_6);
  //	expr1.push_back(ei1_7);
  //	expr1.push_back(ei1_8);
  //	expr1.push_back(ei1_9);
  //	expr1.push_back(ei1);

  expr2.push_back(ei1_1);
  expr2.push_back(ei1_2);
  expr2.push_back(ei1_3);
  expr2.push_back(ei1_4);
  expr2.push_back(ei1_5);
  expr2.push_back(ei1_6);
  expr2.push_back(ei1_7);
  expr2.push_back(ei1_8);
  expr2.push_back(ei1_9);

  expr3.push_back(ei1_2);
  expr3.push_back(ei1_3);
  expr3.push_back(ei1_4);

  //	expr3.push_back(ei3);
  expr4.push_back(ei4);
  expr5.push_back(ei5);
  expr6.push_back(ei6);
  expr7.push_back(ei7);
  expr8.push_back(ei8);
  expr9.push_back(ei9);
  expr10.push_back(ei10);
  expr11.push_back(ei11);
  expr12.push_back(ei12);
  expr13.push_back(ei13);
  expr14.push_back(ei14);
  expr15.push_back(ei15);
  expr16.push_back(ei16);
  expr17.push_back(ei17);

  expr_list1.push_back(expr10);
  expr_list1.push_back(expr11);
  expr_list1.push_back(expr6);
  expr_list1.push_back(expr7);
  expr_list1.push_back(expr1);
  expr_list1.push_back(expr2);
  expr_list1.push_back(expr8);
  expr_list1.push_back(expr3);
  expr_list1.push_back(expr10);
  expr_list1.push_back(expr11);

  //	expr_list1.push_back(expr3);
  //	expr_list1.push_back(expr4);
  //	expr_list1.push_back(expr5);
  //	expr_list1.push_back(expr8);
  //	expr_list1.push_back(expr9);
  //	expr_list1.push_back(expr12);
  //	expr_list1.push_back(expr13);
  //	expr_list1.push_back(expr14);
  //	expr_list1.push_back(expr15);
  //	expr_list1.push_back(expr16);
  //	expr_list1.push_back(expr17);

  LogicalOperator* project1 = new LogicalProject(scan, expr_list1);

  //========================aggregation=======================
  std::vector<Attribute> group_by_attributes;
  group_by_attributes.push_back(table->getAttribute("L_RETURNFLAG"));
  group_by_attributes.push_back(table->getAttribute("L_LINESTATUS"));
  std::vector<Attribute> aggregation_attributes;
  aggregation_attributes.push_back(table->getAttribute("L_QUANTITY"));
  aggregation_attributes.push_back(table->getAttribute("L_EXTENDEDPRICE"));
  aggregation_attributes.push_back(table->getAttribute("L_DISCOUNT"));
  aggregation_attributes.push_back(Attribute(ATTRIBUTE_ANY));
  std::vector<BlockStreamAggregationIterator::State::aggregation>
      aggregation_function;

  aggregation_function.push_back(BlockStreamAggregationIterator::State::sum);
  aggregation_function.push_back(BlockStreamAggregationIterator::State::sum);
  aggregation_function.push_back(BlockStreamAggregationIterator::State::sum);
  aggregation_function.push_back(BlockStreamAggregationIterator::State::count);
  LogicalOperator* aggregation =
      new LogicalAggregation(group_by_attributes, aggregation_attributes,
                             aggregation_function, project1);

  //==========================project=========================
  vector<vector<ExpressionItem> > expr_list2;
  LogicalOperator* project2 = new LogicalProject(aggregation, expr_list2);
  //===========================root===========================
  LogicalOperator* root =
      new LogicalQueryPlanRoot(0, project1, LogicalQueryPlanRoot::PERFORMANCE);

  cout << "performance is ok!" << endl;
  PhysicalOperatorBase* physical_iterator_tree =
      root->GetPhysicalPlan(64 * 1024);
  //	physical_iterator_tree->print();
  physical_iterator_tree->Open();
  while (physical_iterator_tree->Next(0))
    ;
  physical_iterator_tree->Close();
  printf("Q1: execution time: %4.4f second.\n", getSecond(start));
}
开发者ID:JolyZhang,项目名称:CLAIMS,代码行数:101,代码来源:issue27.cpp

示例7: 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

示例8: query_select_fzh

static void query_select_fzh() {
  /*
   * select sum(a+1)+count(a),b
   * from T
   * group by b
   *
   * notation: p a p s
   * */
  unsigned long long int start = curtick();
  TableDescriptor* table =
      Environment::getInstance()->getCatalog()->getTable("LINEITEM");
  //===========================scan===========================
  LogicalOperator* scan = new LogicalScan(table->getProjectoin(0));

  //==========================project=========================
  vector<vector<ExpressionItem> > expr_list1;

  vector<ExpressionItem> expr1;
  vector<ExpressionItem> expr2;
  vector<ExpressionItem> expr3;
  vector<ExpressionItem> expr4;
  vector<ExpressionItem> expr5;
  vector<ExpressionItem> expr6;
  vector<ExpressionItem> expr7;
  vector<ExpressionItem> expr8;
  vector<ExpressionItem> expr9;
  vector<ExpressionItem> expr10;
  vector<ExpressionItem> expr11;
  vector<ExpressionItem> expr12;
  vector<ExpressionItem> expr13;
  vector<ExpressionItem> expr14;
  vector<ExpressionItem> expr15;
  vector<ExpressionItem> expr16;
  vector<ExpressionItem> expr17;

  ExpressionItem ei1;
  ExpressionItem ei1_1;
  ExpressionItem ei1_2;
  ExpressionItem ei1_3;
  ExpressionItem ei1_4;
  ExpressionItem ei1_5;
  ExpressionItem ei1_6;
  ExpressionItem ei1_7;
  ExpressionItem ei1_8;
  ExpressionItem ei1_9;
  ExpressionItem ei2;
  ExpressionItem ei3;
  ExpressionItem ei4;
  ExpressionItem ei5;
  ExpressionItem ei6;
  ExpressionItem ei7;
  ExpressionItem ei8;
  ExpressionItem ei9;
  ExpressionItem ei10;
  ExpressionItem ei11;
  ExpressionItem ei12;
  ExpressionItem ei13;
  ExpressionItem ei14;
  ExpressionItem ei15;
  ExpressionItem ei16;
  ExpressionItem ei17;

  ei1_1.setVariable("LINEITEM.row_id");
  //	ei1_2.setVariable("LINEITEM.L_ORDERKEY");
  ei1_2.setIntValue("1");
  ei1_3.setOperator("+");

  expr1.push_back(ei1_1);
  expr1.push_back(ei1_2);
  expr1.push_back(ei1_3);

  expr_list1.push_back(expr1);

  LogicalOperator* project1 = new LogicalProject(scan, expr_list1);

  //========================aggregation=======================
  std::vector<Attribute> group_by_attributes;
  group_by_attributes.push_back(table->getAttribute("L_RETURNFLAG"));
  group_by_attributes.push_back(table->getAttribute("L_LINESTATUS"));
  std::vector<Attribute> aggregation_attributes;
  aggregation_attributes.push_back(table->getAttribute("L_QUANTITY"));
  aggregation_attributes.push_back(table->getAttribute("L_EXTENDEDPRICE"));
  aggregation_attributes.push_back(table->getAttribute("L_DISCOUNT"));
  aggregation_attributes.push_back(Attribute(ATTRIBUTE_ANY));

  std::vector<PhysicalAggregation::State::Aggregation> aggregation_function;

  aggregation_function.push_back(PhysicalAggregation::State::kSum);
  aggregation_function.push_back(PhysicalAggregation::State::kSum);
  aggregation_function.push_back(PhysicalAggregation::State::kSum);
  aggregation_function.push_back(PhysicalAggregation::State::kCount);
  LogicalOperator* aggregation =
      new LogicalAggregation(group_by_attributes, aggregation_attributes,
                             aggregation_function, project1);

  //==========================project=========================
  vector<vector<ExpressionItem> > expr_list2;

  ExpressionItem ei21_1;
  ei21_1.setVariable("LINEITEM.row_id+1");
//.........这里部分代码省略.........
开发者ID:JolyZhang,项目名称:CLAIMS,代码行数:101,代码来源:issue27ing.cpp

示例9: test_logical_index_building

static void test_logical_index_building()
{
	TableDescriptor* table = Catalog::getInstance()->getTable("cj");
	LogicalOperator* csb_building = new LogicalCSBIndexBuilding(table->getProjectoin(0)->getProjectionID(), table->getAttribute(3), "sec_code_index");
	const NodeID collector_node_id=0;
	LogicalOperator* root=new LogicalQueryPlanRoot(collector_node_id,csb_building,LogicalQueryPlanRoot::RESULTCOLLECTOR);
	root->print();
	BlockStreamIteratorBase* executable_query_plan=root->getIteratorTree(1024*64);
	executable_query_plan->open();
	while (executable_query_plan->next(0));
	executable_query_plan->close();

//	ResultSet* result_set = executable_query_plan->getResultSet();

	executable_query_plan->~BlockStreamIteratorBase();
	root->~LogicalOperator();
	cout << "index building finished!\n";
}
开发者ID:egraldlo,项目名称:CLAIMS,代码行数:18,代码来源:test_IndexManager_serialize.cpp

示例10: 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

示例11: CreateProjection

void CreateProjection(Catalog *catalog, Node *node, ResultSet *&result_set, bool & result_flag,  string &error_msg, string &info) {
	bool is_correct = true;
	Create_projection_stmt *newnode = (Create_projection_stmt *)node;
	int partition_num = newnode->partition_num;
	string tablename = newnode->tablename;
	TableDescriptor *table = NULL;

	if((table = catalog->getTable(tablename)) == NULL)	// 2014-4-30---add check---by Yu
	{
		error_msg="There is no table named "+ tablename+" during creating projection";
		result_flag=false;
		result_set = NULL;
		return;
		is_correct = false;
		return;
	}
	TableID table_id=catalog->getTable(tablename)->get_table_id();
	string partition_attribute_name = newnode->partition_attribute_name;

	std::vector<ColumnOffset> index;
	index.push_back(0);		// add by scdong: add row_id column to each projection automatically
	Columns *col_list = (Columns *)newnode->column_list;
	string colname;
	while(col_list)
	{
		if (col_list->parameter2 != NULL)
		{
			colname = col_list->parameter2;
		}
		else if (col_list->parameter1 != NULL)
		{
			colname = col_list->parameter1;
		}
		else
		{
			error_msg="NO column name during creating projection!";
			result_flag=false;
			result_set = NULL;
			return;
			is_correct = false;
			break;
		}
		cout<<tablename+"."+colname<<endl;
		if(table->isExist(tablename+"."+colname))	// 2014-4-30---add check---by Yu
			index.push_back(table->getAttribute(colname).index);
		else
		{
			error_msg="The column "+ colname+" is not existed! during creating projection";
			result_flag=false;
			result_set = NULL;
			return;
			is_correct = false;
			break;
		}
		col_list = (Columns *)col_list->next;
	}
	if(result_flag==false)
		return;
	if(!is_correct)
		return;

	catalog->getTable(table_id)->createHashPartitionedProjection(index,partition_attribute_name,partition_num);

	int projection_index = catalog->getTable(table_id)->getNumberOfProjection()-1;
	for(unsigned i=0;i<catalog->getTable(table_id)->getProjectoin(projection_index)->getPartitioner()->getNumberOfPartitions();i++){

		catalog->getTable(table_id)->getProjectoin(projection_index)->getPartitioner()->RegisterPartition(i,0);
	}

	catalog->saveCatalog();
	//			catalog->restoreCatalog();// commented by li to solve the dirty read after insert

	result_flag=true;
	result_set = NULL;
	info = "create projection successfully";
	result_set=NULL;
	return;
}
开发者ID:wangli1426,项目名称:Claims,代码行数:78,代码来源:ExecuteLogicalQueryPlan.cpp

示例12: InsertData


//.........这里部分代码省略.........

			if (!is_correct) break;

			// check insert value count
			if (insert_value)
			{
				//						ASTParserLogging::elog("Value count is too many");
				error_msg = "Value count is too many";
				result_flag = false;
				result_set = NULL;
				is_correct = false;
				break;
			}
		}
		else	//insert part of columns
		{
			// get insert value count and check whether it match column count
			unsigned insert_value_count = 0;
			while (insert_value)
			{
				++insert_value_count;
				insert_value = (Insert_vals*)insert_value->next;
			}
			if (insert_value_count != col_count)
			{
				//						ASTParserLogging::elog("Column count doesn't match value count");
				error_msg = "Column count doesn't match value count";
				result_flag = false;
				result_set = NULL;
				is_correct = false;
				break;
			}
			unsigned int used_col_count = 0;

			// by scdong: Claims adds a default row_id attribute for all tables which is attribute(0), when inserting tuples we should begin to construct the string_tuple from the second attribute.
			for(unsigned int position = 1; position < table->getNumberOfAttribute(); position++)
			{
				// find the matched column and value by name
				col = (Columns*)insert_stmt->col_list;
				Insert_vals *insert_value = (Insert_vals *)insert_value_list->insert_vals;

				// take attention that attrName is tablename.colname
				while (col && (table->getAttribute(position).attrName).compare(table->getTableName() +"."+ col->parameter1))
				{
					col = (Columns*)col->next;
					insert_value = (Insert_vals*)insert_value->next;
				}

				// if find
				// the column count is proved to match the insert value count, so column exist, then insert_value exist
				if (col && insert_value)
				{
					++used_col_count;

					// insert value to ostringstream and if has warning return 1; look out the order!
					has_warning = InsertValueToStream(insert_value, table, position, ostr) || has_warning;
				}

				ostr<<"|";
			}//end for

			// check if every insert column is existed
			if (used_col_count != col_count)
			{
				//						ASTParserLogging::elog("Some columns don't exist");
				error_msg = "Some columns don't exist";
				result_flag = false;
				result_set = NULL;
				is_correct = false;
				break;
			}
		}//end else

		if (!is_correct) break;

		insert_value_list = (Insert_val_list*)insert_value_list->next;
		if(insert_value_list != NULL)
			ostr<<"\n";

		++changed_row_num;
	}// end while

	if (!is_correct) return;
	if (has_warning) ASTParserLogging::log("[WARNING]: The type is not matched!\n");
	ASTParserLogging::log("the insert content is \n%s\n",ostr.str().c_str());

	HdfsLoader* Hl = new HdfsLoader(table);
	string tmp = ostr.str();
	Hl->append(ostr.str());

	catalog->saveCatalog();
	//			catalog->restoreCatalog(); // commented by li to solve the dirty read after insert

	result_flag=true;
	ostr.clear();
	ostr.str("");
	ostr<<"insert data successfully. " <<changed_row_num <<" rows changed.";
	info = ostr.str();
	result_set=NULL;
}
开发者ID:wangli1426,项目名称:Claims,代码行数:101,代码来源:ExecuteLogicalQueryPlan.cpp


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