本文整理汇总了C++中PersistentTable类的典型用法代码示例。如果您正苦于以下问题:C++ PersistentTable类的具体用法?C++ PersistentTable怎么用?C++ PersistentTable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PersistentTable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: executePurgeFragmentIfNeeded
bool InsertExecutor::executePurgeFragmentIfNeeded(PersistentTable** ptrToTable) {
PersistentTable* table = *ptrToTable;
int tupleLimit = table->tupleLimit();
int numTuples = table->visibleTupleCount();
// Note that the number of tuples may be larger than the limit.
// This can happen we data is redistributed after an elastic
// rejoin for example.
if (numTuples >= tupleLimit) {
// Next insert will fail: run the purge fragment
// before trying to insert.
m_engine->executePurgeFragment(table);
// If the purge fragment did a truncate table, then the old
// table is still around for undo purposes, but there is now a
// new empty table we can insert into. Update the caller's table
// pointer to use it.
//
// The plan node will go through the table catalog delegate to get
// the correct instance of PersistentTable.
*ptrToTable = static_cast<PersistentTable*>(m_node->getTargetTable());
}
return true;
}
示例2: assert
bool UpdateExecutor::p_execute(const NValueArray ¶ms) {
assert(m_inputTable);
// target table should be persistenttable
PersistentTable* targetTable = dynamic_cast<PersistentTable*>(m_node->getTargetTable());
assert(targetTable);
TableTuple targetTuple = TableTuple(targetTable->schema());
VOLT_TRACE("INPUT TABLE: %s\n", m_inputTable->debug().c_str());
VOLT_TRACE("TARGET TABLE - BEFORE: %s\n", targetTable->debug().c_str());
// determine which indices are updated by this executor
// iterate through all target table indices and see if they contain
// columns mutated by this executor
std::vector<TableIndex*> indexesToUpdate;
const std::vector<TableIndex*>& allIndexes = targetTable->allIndexes();
BOOST_FOREACH(TableIndex *index, allIndexes) {
bool indexKeyUpdated = false;
BOOST_FOREACH(int colIndex, index->getColumnIndices()) {
std::pair<int, int> updateColInfo; // needs to be here because of macro failure
BOOST_FOREACH(updateColInfo, m_inputTargetMap) {
if (updateColInfo.second == colIndex) {
indexKeyUpdated = true;
break;
}
}
if (indexKeyUpdated) break;
}
if (indexKeyUpdated) {
indexesToUpdate.push_back(index);
}
}
示例3: TableStreamerContext
CopyOnWriteContext::CopyOnWriteContext(
PersistentTable &table,
TupleSerializer &serializer,
int32_t partitionId,
const std::vector<std::string> &predicateStrings,
int64_t totalTuples) :
TableStreamerContext(table, predicateStrings),
m_backedUpTuples(TableFactory::getCopiedTempTable(table.databaseId(),
"COW of " + table.name(),
&table, NULL)),
m_serializer(serializer),
m_pool(2097152, 320),
m_blocks(getTable().m_data),
m_iterator(new CopyOnWriteIterator(&table, m_blocks.begin(), m_blocks.end())),
m_maxTupleLength(serializer.getMaxSerializedTupleSize(table.schema())),
m_tuple(table.schema()),
m_finishedTableScan(false),
m_partitionId(partitionId),
m_totalTuples(totalTuples),
m_tuplesRemaining(totalTuples),
m_blocksCompacted(0),
m_serializationBatches(0),
m_inserts(0),
m_updates(0)
{}
示例4: next
bool EvictionIterator::next(TableTuple &tuple)
{
PersistentTable* ptable = static_cast<PersistentTable*>(table);
if(current_tuple_id == ptable->getNewestTupleID()) // we've already returned the last tuple in the chain
{
VOLT_DEBUG("No more tuples in the chain.");
return false;
}
if(current_tuple_id == -1) // this is the first call to next
{
VOLT_DEBUG("This is the first tuple in the chain.");
if(ptable->getNumTuplesInEvictionChain() == 0) // there are no tuples in the chain
{
VOLT_DEBUG("There are no tuples in the eviction chain.");
return false;
}
current_tuple_id = ptable->getOldestTupleID();
}
else // advance the iterator to the next tuple in the chain
{
current_tuple_id = current_tuple->getTupleID();
}
current_tuple->move(ptable->dataPtrForTuple(current_tuple_id));
tuple.move(current_tuple->address());
VOLT_DEBUG("current_tuple_id = %d", current_tuple_id);
return true;
}
开发者ID:Arpit-Mittal,项目名称:Hbase-Hstore-Hadoop-Implementation-Cassandra,代码行数:34,代码来源:EvictionIterator.cpp
示例5: getTable
bool
VoltDBEngine::loadTable(int32_t tableId,
ReferenceSerializeInput &serializeIn,
int64_t txnId, int64_t lastCommittedTxnId)
{
m_executorContext->setupForPlanFragments(getCurrentUndoQuantum(),
txnId,
lastCommittedTxnId);
Table* ret = getTable(tableId);
if (ret == NULL) {
VOLT_ERROR("Table ID %d doesn't exist. Could not load data",
(int) tableId);
return false;
}
PersistentTable* table = dynamic_cast<PersistentTable*>(ret);
if (table == NULL) {
VOLT_ERROR("Table ID %d(name '%s') is not a persistent table."
" Could not load data",
(int) tableId, ret->name().c_str());
return false;
}
try {
table->loadTuplesFrom(serializeIn);
} catch (SerializableEEException e) {
throwFatalException("%s", e.message().c_str());
}
return true;
}
示例6: CopyOnWriteIterator
CopyOnWriteContext::CopyOnWriteContext(
PersistentTable &table,
TupleSerializer &serializer,
int32_t partitionId,
const std::vector<std::string> &predicateStrings,
int64_t totalTuples,
bool doDelete) :
m_table(table),
m_backedUpTuples(TableFactory::getCopiedTempTable(table.databaseId(),
"COW of " + table.name(),
&table, NULL)),
m_serializer(serializer),
m_pool(2097152, 320),
m_blocks(m_table.m_data),
m_iterator(new CopyOnWriteIterator(&table, m_blocks.begin(), m_blocks.end())),
m_maxTupleLength(serializer.getMaxSerializedTupleSize(table.schema())),
m_tuple(table.schema()),
m_finishedTableScan(false),
m_partitionId(partitionId),
m_totalTuples(totalTuples),
m_tuplesRemaining(totalTuples),
m_blocksCompacted(0),
m_serializationBatches(0),
m_inserts(0),
m_updates(0),
m_doDelete(doDelete)
{
// Parse predicate strings. The factory type determines the kind of
// predicates that get generated.
// Throws an exception to be handled by caller on errors.
std::ostringstream errmsg;
if (!m_predicates.parseStrings(predicateStrings, errmsg)) {
throwFatalException("CopyOnWriteContext() failed to parse predicate strings.");
}
}
示例7: VOLT_TRACE
bool InsertExecutor::p_init(AbstractPlanNode* abstractNode,
TempTableLimits* limits)
{
VOLT_TRACE("init Insert Executor");
m_node = dynamic_cast<InsertPlanNode*>(abstractNode);
assert(m_node);
assert(m_node->getTargetTable());
assert(m_node->getInputTableCount() == 1);
Table* targetTable = m_node->getTargetTable();
m_isUpsert = m_node->isUpsert();
setDMLCountOutputTable(limits);
m_inputTable = dynamic_cast<TempTable*>(m_node->getInputTable()); //input table should be temptable
assert(m_inputTable);
// Target table can be StreamedTable or PersistentTable and must not be NULL
PersistentTable *persistentTarget = dynamic_cast<PersistentTable*>(targetTable);
m_partitionColumn = -1;
m_isStreamed = (persistentTarget == NULL);
if (m_isUpsert) {
VOLT_TRACE("init Upsert Executor actually");
if (m_isStreamed) {
VOLT_ERROR("UPSERT is not supported for Stream table %s", targetTable->name().c_str());
}
// look up the tuple whether it exists already
if (targetTable->primaryKeyIndex() == NULL) {
VOLT_ERROR("No primary keys were found in our target table '%s'",
targetTable->name().c_str());
}
}
if (persistentTarget) {
m_partitionColumn = persistentTarget->partitionColumn();
}
m_multiPartition = m_node->isMultiPartition();
m_sourceIsPartitioned = m_node->sourceIsPartitioned();
// allocate memory for template tuple, set defaults for all columns
m_templateTuple.init(targetTable->schema());
TableTuple tuple = m_templateTuple.tuple();
std::set<int> fieldsExplicitlySet(m_node->getFieldMap().begin(), m_node->getFieldMap().end());
m_node->initTupleWithDefaultValues(m_engine,
&m_memoryPool,
fieldsExplicitlySet,
tuple,
m_nowFields);
m_hasPurgeFragment = persistentTarget ? persistentTarget->hasPurgeFragment() : false;
return true;
}
示例8:
Table *TableCatalogDelegate::getTable() const {
// If a persistent table has an active delta table, return the delta table instead of the whole table.
PersistentTable *persistentTable = dynamic_cast<PersistentTable*>(m_table);
if (persistentTable && persistentTable->isDeltaTableActive()) {
return persistentTable->deltaTable();
}
return m_table;
}
示例9: StreamedTable
Table* TableFactory::getPersistentTable(
voltdb::CatalogId databaseId,
const std::string &name,
TupleSchema* schema,
const std::vector<std::string> &columnNames,
char *signature,
bool tableIsMaterialized,
int partitionColumn,
bool exportEnabled,
bool exportOnly,
int tableAllocationTargetSize,
int tupleLimit,
int32_t compactionThreshold,
bool drEnabled)
{
Table *table = NULL;
StreamedTable *streamedTable = NULL;
PersistentTable *persistentTable = NULL;
if (exportOnly) {
table = streamedTable = new StreamedTable(partitionColumn);
}
else {
table = persistentTable = new PersistentTable(partitionColumn,
signature,
tableIsMaterialized,
tableAllocationTargetSize,
tupleLimit,
drEnabled);
}
initCommon(databaseId,
table,
name,
schema,
columnNames,
true, // table will take ownership of TupleSchema object
compactionThreshold);
TableStats *stats;
if (exportOnly) {
stats = streamedTable->getTableStats();
}
else {
stats = persistentTable->getTableStats();
// Allocate and assign the tuple storage block to the persistent table ahead of time instead
// of doing so at time of first tuple insertion. The intent of block allocation ahead of time
// is to avoid allocation cost at time of tuple insertion
TBPtr block = persistentTable->allocateNextBlock();
assert(block->hasFreeTuples());
persistentTable->m_blocksWithSpace.insert(block);
}
// initialize stats for the table
configureStats(name, stats);
return table;
}
示例10: setOutputTable
void AbstractPlanNode::setOutputTable(Table* table)
{
PersistentTable* persistentTable = dynamic_cast<PersistentTable*>(table);
if (persistentTable) {
VoltDBEngine* engine = ExecutorContext::getEngine();
TableCatalogDelegate* tcd = engine->getTableDelegate(persistentTable->name());
m_outputTable.setTable(tcd);
} else {
TempTable* tempTable = dynamic_cast<TempTable*>(table);
assert(tempTable);
m_outputTable.setTable(tempTable);
}
}
示例11: setTargetTable
void MaterializedViewMetadata::setTargetTable(PersistentTable * target)
{
PersistentTable * oldTarget = m_target;
m_target = target;
target->incrementRefcount();
// Re-initialize dependencies on the target table, allowing for widened columns
m_index = m_target->primaryKeyIndex();
freeBackedTuples();
allocateBackedTuples();
oldTarget->decrementRefcount();
}
示例12: hasNext
bool EvictionIterator::hasNext()
{
PersistentTable* ptable = static_cast<PersistentTable*>(table);
if(current_tuple_id == ptable->getNewestTupleID())
return false;
if(ptable->usedTupleCount() == 0)
return false;
if(ptable->getNumTuplesInEvictionChain() == 0) { // there are no tuples in the chain
VOLT_DEBUG("There are no tuples in the eviction chain.");
return false;
}
return true;
}
开发者ID:Arpit-Mittal,项目名称:Hbase-Hstore-Hadoop-Implementation-Cassandra,代码行数:15,代码来源:EvictionIterator.cpp
示例13: setTable
void setTable(TableIndexScheme *pkey = NULL) {
assert (columnNames.size() == columnTypes.size());
assert (columnTypes.size() == columnSizes.size());
assert (columnSizes.size() == columnNullables.size());
TupleSchema *schema = TupleSchema::createTupleSchemaForTest(columnTypes, columnSizes, columnNullables);
if (pkey != NULL) {
pkey->tupleSchema = schema;
}
table = static_cast<PersistentTable*>(TableFactory::getPersistentTable(database_id, "test_table", schema, columnNames, signature));
if (pkey) {
TableIndex *pkeyIndex = TableIndexFactory::getInstance(*pkey);
assert(pkeyIndex);
table->addIndex(pkeyIndex);
table->setPrimaryKeyIndex(pkeyIndex);
}
};
示例14: MultiStreamTestTool
MultiStreamTestTool(PersistentTable& table, size_t nparts) :
table(table),
nparts(nparts),
iteration(-1),
nerrors(0),
showTuples(TUPLE_COUNT <= MAX_DETAIL_COUNT)
{
strcpy(stage, "Initialize");
TableTuple tuple(table.schema());
size_t i = 0;
voltdb::TableIterator& iterator = table.iterator();
while (iterator.next(tuple)) {
int64_t value = *reinterpret_cast<int64_t*>(tuple.address() + 1);
values.push_back(value);
valueSet.insert(std::pair<int64_t,size_t>(value, i++));
}
}
示例15: StreamedTable
Table* TableFactory::getPersistentTable(
voltdb::CatalogId databaseId,
const std::string &name,
TupleSchema* schema,
const std::vector<std::string> &columnNames,
char *signature,
bool tableIsMaterialized,
int partitionColumn,
bool exportEnabled,
bool exportOnly,
int tableAllocationTargetSize,
int tupleLimit,
int32_t compactionThreshold,
bool drEnabled)
{
Table *table = NULL;
if (exportOnly) {
table = new StreamedTable(exportEnabled);
}
else {
table = new PersistentTable(partitionColumn, signature, tableIsMaterialized, tableAllocationTargetSize, tupleLimit, drEnabled);
}
initCommon(databaseId,
table,
name,
schema,
columnNames,
true, // table will take ownership of TupleSchema object
compactionThreshold);
// initialize stats for the table
configureStats(databaseId, name, table);
if(!exportOnly) {
// allocate tuple storage block for the persistent table ahead of time
// instead of waiting till first tuple insertion. Intend of allocating tuple
// block storage ahead is to improve performance on first tuple insertion.
PersistentTable *persistentTable = static_cast<PersistentTable*>(table);
TBPtr block = persistentTable->allocateNextBlock();
assert(block->hasFreeTuples());
persistentTable->m_blocksWithSpace.insert(block);
}
return table;
}