本文整理汇总了C++中std::unique_ptr::AddIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ unique_ptr::AddIndex方法的具体用法?C++ unique_ptr::AddIndex怎么用?C++ unique_ptr::AddIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::unique_ptr
的用法示例。
在下文中一共展示了unique_ptr::AddIndex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateTable
void CreateTable() {
const oid_t col_count = state.column_count + 1;
const bool is_inlined = true;
// Create schema first
std::vector<catalog::Column> columns;
for (oid_t col_itr = 0; col_itr < col_count; col_itr++) {
auto column =
catalog::Column(VALUE_TYPE_INTEGER, GetTypeSize(VALUE_TYPE_INTEGER),
"" + std::to_string(col_itr), is_inlined);
columns.push_back(column);
}
catalog::Schema *table_schema = new catalog::Schema(columns);
std::string table_name("HYADAPTTABLE");
/////////////////////////////////////////////////////////
// Create table.
/////////////////////////////////////////////////////////
bool own_schema = true;
bool adapt_table = true;
sdbench_table.reset(storage::TableFactory::GetDataTable(
INVALID_OID, INVALID_OID, table_schema, table_name,
state.tuples_per_tilegroup, own_schema, adapt_table));
// PRIMARY INDEXES
for(int index_itr = 0; index_itr < state.index_count; index_itr++) {
std::vector<oid_t> key_attrs;
auto tuple_schema = sdbench_table->GetSchema();
catalog::Schema *key_schema;
index::IndexMetadata *index_metadata;
bool unique;
key_attrs = {0};
key_schema = catalog::Schema::CopySchema(tuple_schema, key_attrs);
key_schema->SetIndexedColumns(key_attrs);
unique = true;
index_metadata = new index::IndexMetadata(
"primary_index",
index_itr,
INDEX_TYPE_SKIPLIST,
INDEX_CONSTRAINT_TYPE_PRIMARY_KEY,
tuple_schema,
key_schema,
unique);
index::Index *pkey_index = index::IndexFactory::GetInstance(index_metadata);
sdbench_table->AddIndex(pkey_index);
}
}
示例2: CreateTable
void CreateTable(std::unique_ptr<storage::DataTable> &hyadapt_table,
bool build_indexes) {
const bool is_inlined = true;
// Create schema first
std::vector<catalog::Column> columns;
for (oid_t col_itr = 0; col_itr < column_count; col_itr++) {
auto column = catalog::Column(type::TypeId::INTEGER,
type::Type::GetTypeSize(type::TypeId::INTEGER),
std::to_string(col_itr), is_inlined);
columns.push_back(column);
}
catalog::Schema *table_schema = new catalog::Schema(columns);
std::string table_name("HYADAPT_TABLE");
/////////////////////////////////////////////////////////
// Create table.
/////////////////////////////////////////////////////////
bool own_schema = true;
bool adapt_table = true;
hyadapt_table.reset(storage::TableFactory::GetDataTable(
INVALID_OID, INVALID_OID, table_schema, table_name, tuples_per_tile_group,
own_schema, adapt_table));
// PRIMARY INDEX
if (build_indexes == true) {
std::vector<oid_t> key_attrs;
auto tuple_schema = hyadapt_table->GetSchema();
catalog::Schema *key_schema;
index::IndexMetadata *index_metadata;
bool unique;
key_attrs = {0};
key_schema = catalog::Schema::CopySchema(tuple_schema, key_attrs);
key_schema->SetIndexedColumns(key_attrs);
unique = true;
index_metadata = new index::IndexMetadata(
"primary_index", 123, INVALID_OID, INVALID_OID, IndexType::BWTREE,
IndexConstraintType::PRIMARY_KEY, tuple_schema, key_schema, key_attrs,
unique);
std::shared_ptr<index::Index> pkey_index(
index::IndexFactory::GetIndex(index_metadata));
hyadapt_table->AddIndex(pkey_index);
}
}