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


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

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


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

示例1: analyse

void Analyzer::analyse(TableID table_id, analysis_level level) {
  TableStatistic* tab_stat =
      StatManager::getInstance()->getTableStatistic(table_id);
  TableDescriptor* table = Catalog::getInstance()->getTable(table_id);
  if (tab_stat == 0) {
    //    LogicalOperator * scan = new LogicalScan(table->getProjectoin(0));
    //    std::vector<Attribute> group_by_attributes;
    //    std::vector<Attribute> aggregation_attributes;
    //
    //    aggregation_attributes.push_back(Attribute(ATTRIBUTE_ANY));
    //
    //    std::vector<BlockStreamAggregationIterator::State::aggregation>
    //    aggregation_function;
    //    aggregation_function.push_back(
    //        BlockStreamAggregationIterator::State::count);
    //    LogicalOperator* agg = new Aggregation(group_by_attributes,
    //                                           aggregation_attributes,
    //                                           aggregation_function, scan);
    //    LogicalOperator* root = new LogicalQueryPlanRoot(
    //        0, agg, 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::BlockStreamTraverseIterator* b_it = it.nextBlock()
    //        ->createIterator();
    //    const unsigned long tuple_count = *(unsigned
    //    long*) b_it->nextTuple();
    //    BlockStreamBase* block;
    //    while (block = it.nextBlock()) {
    //      BlockStreamBase::BlockStreamTraverseIterator* b_it =
    //          block->createIterator();
    //
    //    }
    //    tab_stat = new TableStatistic();
    //    tab_stat->number_of_tuples_ = tuple_count;
    //    printf("Statistics for table %s is
    //        gathered!\n",Catalog::getInstance()->getTable(table_id)
    //    ->getTableName().c_str());
    //        tab_stat->print();
    //        StatManager::getInstance()->setTableStatistic(table_id, tab_stat);
    //        resultset->destory();
    //        root->~LogicalOperator();
    compute_table_stat(table_id);
  }

  if (level == a_l_attribute) {
    std::vector<Attribute> attribute_list = table->getAttributes();
    for (unsigned i = 0; i < attribute_list.size(); i++) {
      compute_attribute_stat(attribute_list[i].getID());
    }
  }
}
开发者ID:yestodaylee,项目名称:CLAIMS,代码行数:57,代码来源:Analyzer.cpp

示例2: Execute

RetCode DescExec::Execute(ExecutedResult* exec_result) {
  SemanticContext sem_cnxt;
  RetCode ret = desc_stmt_ast_->SemanticAnalisys(&sem_cnxt);
  if (rSuccess != ret) {
    exec_result->error_info_ =
        "Semantic analysis error.\n" + sem_cnxt.error_msg_;
    exec_result->status_ = false;
    LOG(ERROR) << "semantic analysis error result= : " << ret;
    cout << "semantic analysis error result= : " << ret << endl;
    return ret;
  }

  ostringstream ostr;
  Catalog* local_catalog = Environment::getInstance()->getCatalog();
  TableDescriptor* table = local_catalog->getTable(desc_stmt_ast_->table_name_);
  for (int i = 0; i < table->getAttributes().size(); i++) {
    desc_stmt_ast_->column_name_.push_back(table->getAttributes()[i].attrName);
    // extra and is_key not used now.
    desc_stmt_ast_->extra_.push_back("");
    desc_stmt_ast_->is_key_.push_back("");
    desc_stmt_ast_->size_.push_back(
        table->getAttributes()[i].attrType->get_length());
    if (table->getAttributes()[i].attrType->nullable) {
      desc_stmt_ast_->nullable_.push_back("YES");
    } else {
      desc_stmt_ast_->nullable_.push_back("NO");
    }
    switch (table->getAttributes()[i].attrType->type) {
      case t_smallInt:
        desc_stmt_ast_->type_.push_back("small int");
        desc_stmt_ast_->default_value_.push_back("0");
        break;
      case t_int:
        desc_stmt_ast_->type_.push_back("int");
        desc_stmt_ast_->default_value_.push_back("0");
        break;
      case t_u_long:
        desc_stmt_ast_->type_.push_back("unsigned long");
        desc_stmt_ast_->default_value_.push_back("0");
        break;
      case t_float:
        desc_stmt_ast_->type_.push_back("float");
        desc_stmt_ast_->default_value_.push_back("0.0");
        break;
      case t_double:
        desc_stmt_ast_->type_.push_back("double");
        desc_stmt_ast_->default_value_.push_back("0.0");
        break;
      case t_string:
        desc_stmt_ast_->type_.push_back("string");
        desc_stmt_ast_->default_value_.push_back("NULL");
        break;
      case t_date:
        desc_stmt_ast_->type_.push_back("date");
        desc_stmt_ast_->default_value_.push_back("1400-01-01");
        break;
      case t_time:
        desc_stmt_ast_->type_.push_back("time");
        desc_stmt_ast_->default_value_.push_back("00:00:00.000000");
        break;
      case t_datetime:
        desc_stmt_ast_->type_.push_back("date and time");
        desc_stmt_ast_->default_value_.push_back("1400-01-01 00:00:00.000000");
        break;
      case t_decimal:
        desc_stmt_ast_->type_.push_back("decimal");
        desc_stmt_ast_->default_value_.push_back("0.0");
        break;
      case t_boolean:
        desc_stmt_ast_->type_.push_back("boolean");
        desc_stmt_ast_->default_value_.push_back("false");
        break;
      case t_u_smallInt:
        desc_stmt_ast_->type_.push_back("unsigned small int");
        desc_stmt_ast_->default_value_.push_back("0.0");
        break;
      case t_date_day:
        desc_stmt_ast_->type_.push_back("date day");
        desc_stmt_ast_->default_value_.push_back("");
        break;
      case t_date_week:
        desc_stmt_ast_->type_.push_back("date week");
        desc_stmt_ast_->default_value_.push_back("");
        break;
      case t_date_month:
        desc_stmt_ast_->type_.push_back("date month");
        desc_stmt_ast_->default_value_.push_back("");
        break;
      case t_date_year:
        desc_stmt_ast_->type_.push_back("date year");
        desc_stmt_ast_->default_value_.push_back("");
        break;
      case t_date_quarter:
        desc_stmt_ast_->type_.push_back("date quarter");
        desc_stmt_ast_->default_value_.push_back("");
        break;
      default:
        desc_stmt_ast_->type_.push_back("unknown");
        desc_stmt_ast_->default_value_.push_back("");
        break;
//.........这里部分代码省略.........
开发者ID:cs-wang,项目名称:CLAIMS,代码行数:101,代码来源:desc_exec.cpp


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