本文整理汇总了C++中TableDescriptor::getTableName方法的典型用法代码示例。如果您正苦于以下问题:C++ TableDescriptor::getTableName方法的具体用法?C++ TableDescriptor::getTableName怎么用?C++ TableDescriptor::getTableName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TableDescriptor
的用法示例。
在下文中一共展示了TableDescriptor::getTableName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetOrderByKey
int LogicalSort::GetOrderByKey(const char *table_name, const char *attr) {
// Use table name and attribute name to get the number.
for (unsigned attr_id = 0;
attr_id < child_plan_context_.attribute_list_.size(); attr_id++) {
TableDescriptor *table = Catalog::getInstance()->getTable(
child_plan_context_.attribute_list_[attr_id].table_id_);
string tablename = table->getTableName();
if ((tablename.compare(table_name) == 0) &&
(child_plan_context_.attribute_list_[attr_id].attrName.compare(attr) ==
0)) {
return attr_id;
}
}
}
示例2: Execute
//.........这里部分代码省略.........
insert_value = dynamic_cast<AstInsertVals *>(insert_value->next_);
ostr << "|";
}
if (rSuccess != ret) break;
// check insert value count
if (NULL != insert_value) {
LOG(ERROR) << "Value count is too many";
exec_result->SetError("Value count is too many");
return claims::common::rFailure;
}
} 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 = dynamic_cast<AstInsertVals *>(insert_value->next_);
}
if (insert_value_count != col_count) {
LOG(ERROR) << "Column count doesn't match value count. "
"insert_value_count is " << insert_value_count
<< ", col_count is: " << col_count << endl;
exec_result->SetError("Column count doesn't match value count");
return claims::common::rFailure;
}
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_desc_->getNumberOfAttribute(); position++) {
// find the matched column and value by name
col = dynamic_cast<AstColumn *>(insert_ast_->col_list_);
AstInsertVals *insert_value =
dynamic_cast<AstInsertVals *>(insert_value_list->insert_vals_);
// take attention that attrName is tablename.colname
// here is temporary code and need to change later
while (col &&
(table_desc_->getAttribute(position).attrName).compare(
table_desc_->getTableName() + "." + col->column_name_)) {
col = dynamic_cast<AstColumn *>(col->next_);
insert_value = dynamic_cast<AstInsertVals *>(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!
if (rSuccess != (ret = InsertValueToStream(insert_value, table,
position, ostr))) {
ELOG(ret, "failed to insert value to stream");
exec_result->SetError("Not supported type to insert");
return claims::common::rFailure;
}
}
ostr << "|";
}
// check if every insert column is existed
if (used_col_count != col_count) {
exec_result->SetError("Some columns don't exist");
LOG(ERROR) << "Some columns don't exist. "
"used_col_count is " << used_col_count
<< ", col_count is: " << col_count << endl;
return claims::common::rFailure;
}
}
if (!is_correct_) break;
insert_value_list =
dynamic_cast<AstInsertValList *>(insert_value_list->next_);
if (insert_value_list != NULL) ostr << "\n";
++changed_row_num;
} // while
if (!is_correct_) return claims::common::rFailure;
DataInjector *injector = new DataInjector(table);
// str() will copy string buffer without the last '\n'
ret = injector->InsertFromString(ostr.str() + "\n", exec_result);
if (rSuccess == ret) {
ostr.clear();
ostr.str("");
ostr << "insert data successfully. " << changed_row_num
<< " rows changed.";
exec_result->SetResult(ostr.str(), NULL);
} else {
LOG(ERROR) << "failed to insert tuples into table:"
<< table->getTableName() << endl;
exec_result->SetError("failed to insert tuples into table ");
}
DELETE_PTR(injector);
Environment::getInstance()->getCatalog()->saveCatalog();
}
return ret;
}
示例3: 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;
}