本文整理汇总了C++中TableTuple::getNValue方法的典型用法代码示例。如果您正苦于以下问题:C++ TableTuple::getNValue方法的具体用法?C++ TableTuple::getNValue怎么用?C++ TableTuple::getNValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TableTuple
的用法示例。
在下文中一共展示了TableTuple::getNValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UniqueEngineBuilder
TEST_F(TableTupleTest, VolatileStandAloneTuple) {
UniqueEngine engine = UniqueEngineBuilder().build();
// A schema with
// - one fixed size column
// - one inlined variable-length column
// - one non-inlined variable-length column
ScopedTupleSchema schema{Tools::buildSchema(VALUE_TYPE_BIGINT,
std::make_pair(VALUE_TYPE_VARCHAR, 12),
std::make_pair(VALUE_TYPE_VARCHAR, 256))};
StandAloneTupleStorage standAloneTuple{schema.get()};
TableTuple tuple = standAloneTuple.tuple();
Tools::setTupleValues(&tuple, int64_t(0), "foo", "foo bar");
// Stand alone tuples are similar to pool-backed tuples.
ASSERT_TRUE(tuple.inlinedDataIsVolatile());
ASSERT_FALSE(tuple.nonInlinedDataIsVolatile());
NValue nv = tuple.getNValue(0);
ASSERT_FALSE(nv.getVolatile());
nv = tuple.getNValue(1);
ASSERT_TRUE(nv.getVolatile());
nv = tuple.getNValue(2);
ASSERT_FALSE(nv.getVolatile());
}
示例2: processTupleDelete
void MaterializedViewMetadata::processTupleDelete(TableTuple &oldTuple) {
// don't change the view if this tuple doesn't match the predicate
if (m_filterPredicate && (m_filterPredicate->eval(&oldTuple, NULL).isFalse()))
return;
// this will assert if the tuple isn't there as param expected is true
findExistingTuple(oldTuple, true);
// clear the tuple that will be built to insert or overwrite
memset(m_updatedTupleBackingStore, 0, m_target->schema()->tupleLength() + 1);
//printf(" Existing tuple: %s.\n", m_existingTuple.debugNoHeader().c_str());
//fflush(stdout);
// set up the first column, which is a count
NValue count = m_existingTuple.getNValue(m_groupByColumnCount).op_decrement();
//printf(" Count is: %d.\n", (int)(m_existingTuple.getSlimValue(m_groupByColumnCount).getBigInt()));
//fflush(stdout);
// check if we should remove the tuple
if (count.isZero()) {
m_target->deleteTuple(m_existingTuple, true);
return;
}
// assume from here that we're just updating the existing row
int colindex = 0;
// set up the first n columns, based on group-by columns
for (colindex = 0; colindex < m_groupByColumnCount; colindex++) {
m_updatedTuple.setNValue(colindex, oldTuple.getNValue(m_groupByColumns[colindex]));
}
m_updatedTuple.setNValue(colindex, count);
colindex++;
// set values for the other columns
for (int i = colindex; i < m_outputColumnCount; i++) {
NValue oldValue = oldTuple.getNValue(m_outputColumnSrcTableIndexes[i]);
NValue existingValue = m_existingTuple.getNValue(i);
if (m_outputColumnAggTypes[i] == EXPRESSION_TYPE_AGGREGATE_SUM) {
m_updatedTuple.setNValue(i, existingValue.op_subtract(oldValue));
}
else if (m_outputColumnAggTypes[i] == EXPRESSION_TYPE_AGGREGATE_COUNT) {
m_updatedTuple.setNValue(i, existingValue.op_decrement());
}
else {
throw SerializableEEException(VOLT_EE_EXCEPTION_TYPE_EEEXCEPTION,
"Error in materialized view table"
" update.");
}
}
// update the row
// shouldn't need to update indexes as this shouldn't ever change the key
m_target->updateTuple(m_updatedTuple, m_existingTuple, false);
}
示例3: processTupleInsert
void MaterializedViewMetadata::processTupleInsert(TableTuple &newTuple) {
// don't change the view if this tuple doesn't match the predicate
if (m_filterPredicate
&& (m_filterPredicate->eval(&newTuple, NULL).isFalse()))
return;
bool exists = findExistingTuple(newTuple);
if (!exists) {
// create a blank tuple
m_existingTuple.move(m_emptyTupleBackingStore);
}
// clear the tuple that will be built to insert or overwrite
memset(m_updatedTupleBackingStore, 0, m_target->schema()->tupleLength() + 1);
int colindex = 0;
// set up the first n columns, based on group-by columns
for (colindex = 0; colindex < m_groupByColumnCount; colindex++) {
m_updatedTuple.setNValue(colindex,
newTuple.getNValue(m_groupByColumns[colindex]));
}
// set up the next column, which is a count
m_updatedTuple.setNValue(colindex,
m_existingTuple.getNValue(colindex).op_increment());
colindex++;
// set values for the other columns
for (int i = colindex; i < m_outputColumnCount; i++) {
NValue newValue = newTuple.getNValue(m_outputColumnSrcTableIndexes[i]);
NValue existingValue = m_existingTuple.getNValue(i);
if (m_outputColumnAggTypes[i] == EXPRESSION_TYPE_AGGREGATE_SUM) {
m_updatedTuple.setNValue(i, newValue.op_add(existingValue));
}
else if (m_outputColumnAggTypes[i] == EXPRESSION_TYPE_AGGREGATE_COUNT) {
m_updatedTuple.setNValue(i, existingValue.op_increment());
}
else {
char message[128];
sprintf(message, "Error in materialized view table update for"
" col %d. Expression type %d", i, m_outputColumnAggTypes[i]);
throw SerializableEEException(VOLT_EE_EXCEPTION_TYPE_EEEXCEPTION,
message);
}
}
// update or insert the row
if (exists) {
// shouldn't need to update indexes as this shouldn't ever change the
// key
m_target->updateTuple(m_updatedTuple, m_existingTuple, false);
}
else {
m_target->insertTuple(m_updatedTuple);
}
}
示例4: getTempTable
TEST_F(TableTupleFilterTest, tableTupleFilterTest)
{
static const int MARKER = 33;
TempTable* table = getTempTable();
TableTupleFilter tableFilter;
tableFilter.init(table);
int tuplePerBlock = table->getTuplesPerBlock();
// make sure table spans more than one block
ASSERT_TRUE(NUM_OF_TUPLES / tuplePerBlock > 1);
TableTuple tuple = table->tempTuple();
TableIterator iterator = table->iterator();
// iterator over and mark every 5th tuple
int counter = 0;
std::multiset<int64_t> control_values;
while(iterator.next(tuple)) {
if (++counter % 5 == 0) {
NValue nvalue = tuple.getNValue(1);
int64_t value = ValuePeeker::peekBigInt(nvalue);
control_values.insert(value);
tableFilter.updateTuple(tuple, MARKER);
}
}
TableTupleFilter_iter<MARKER> endItr = tableFilter.end<MARKER>();
for (TableTupleFilter_iter<MARKER> itr = tableFilter.begin<MARKER>(); itr != endItr; ++itr) {
uint64_t tupleAddr = tableFilter.getTupleAddress(*itr);
tuple.move((char *)tupleAddr);
ASSERT_TRUE(tuple.isActive());
NValue nvalue = tuple.getNValue(1);
int64_t value = ValuePeeker::peekBigInt(nvalue);
ASSERT_FALSE(control_values.empty());
auto it = control_values.find(value);
ASSERT_NE(it, control_values.end());
control_values.erase(it);
}
ASSERT_TRUE(control_values.empty());
}
示例5: updateTxnHash
void DRTupleStream::updateTxnHash(TableTuple &tuple, int partitionColumn) {
if (partitionColumn != -1 && m_txnPkHash != LONG_MAX) {
int64_t txnPkHash = (int64_t)tuple.getNValue(partitionColumn).murmurHash3();
if (m_txnPkHash == LONG_MIN) {
m_txnPkHash = txnPkHash;
}
else if (txnPkHash != m_txnPkHash) {
m_txnPkHash = LONG_MAX;
}
}
}
示例6: compare_tuple
NValue compare_tuple(const TableTuple& tuple1, const TableTuple& tuple2)
{
assert(tuple1.getSchema()->columnCount() == tuple2.getSchema()->columnCount());
NValue fallback_result = OP::includes_equality() ? NValue::getTrue() : NValue::getFalse();
int schemaSize = tuple1.getSchema()->columnCount();
for (int columnIdx = 0; columnIdx < schemaSize; ++columnIdx) {
NValue value1 = tuple1.getNValue(columnIdx);
if (value1.isNull()) {
fallback_result = NValue::getNullValue(VALUE_TYPE_BOOLEAN);
if (OP::implies_null_for_row()) {
return fallback_result;
}
continue;
}
NValue value2 = tuple2.getNValue(columnIdx);
if (value2.isNull()) {
fallback_result = NValue::getNullValue(VALUE_TYPE_BOOLEAN);
if (OP::implies_null_for_row()) {
return fallback_result;
}
continue;
}
if (OP::compare_withoutNull(value1, tuple2.getNValue(columnIdx)).isTrue()) {
if (OP::implies_true_for_row(value1, value2)) {
// allow early return on strict inequality
return NValue::getTrue();
}
}
else {
if (OP::implies_false_for_row(value1, value2)) {
// allow early return on strict inequality
return NValue::getFalse();
}
}
}
// The only cases that have not already short-circuited involve all equal columns.
// Each op either includes or excludes that particular case.
return fallback_result;
}
示例7: tuple
TEST_F(PersistentTableMemStatsTest, UpdateAndUndoTest) {
initTable(true);
tableutil::addRandomTuples(m_table, 10);
int64_t orig_size = m_table->nonInlinedMemorySize();
//cout << "Original non-inline size: " << orig_size << endl;
TableTuple tuple(m_tableSchema);
tableutil::getRandomTuple(m_table, tuple);
//cout << "Retrieved random tuple " << endl << tuple.debugNoHeader() << endl;
size_t removed_bytes =
StringRef::computeStringMemoryUsed(ValuePeeker::peekObjectLength(tuple.getNValue(1))) +
StringRef::computeStringMemoryUsed(ValuePeeker::peekObjectLength(tuple.getNValue(2)));
//cout << "Removing bytes from table: " << removed_bytes << endl;
/*
* A copy of the tuple to modify and use as a source tuple when
* updating the new tuple.
*/
TableTuple tempTuple = m_table->tempTuple();
tempTuple.copy(tuple);
string strval = "123456";
NValue new_string = ValueFactory::getStringValue(strval);
tempTuple.setNValue(1, new_string);
//cout << "Created random tuple " << endl << tempTuple.debugNoHeader() << endl;
size_t added_bytes =
StringRef::computeStringMemoryUsed(ValuePeeker::peekObjectLength(tempTuple.getNValue(1))) +
StringRef::computeStringMemoryUsed(ValuePeeker::peekObjectLength(tempTuple.getNValue(2)));
//cout << "Adding bytes to table: " << added_bytes << endl;
m_engine->setUndoToken(INT64_MIN + 2);
// this next line is a testing hack until engine data is
// de-duplicated with executorcontext data
m_engine->getExecutorContext();
m_table->updateTuple(tempTuple, tuple, true);
ASSERT_EQ(orig_size + added_bytes - removed_bytes, m_table->nonInlinedMemorySize());
m_engine->undoUndoToken(INT64_MIN + 2);
ASSERT_EQ(orig_size, m_table->nonInlinedMemorySize());
//tuple.freeObjectColumns();
//tempTuple.freeObjectColumns();
//delete [] tuple.address();
//delete[] tempTuple.address();
new_string.free();
}
示例8: findExistingTuple
bool MaterializedViewMetadata::findExistingTuple(TableTuple &oldTuple, bool expected) {
// find the key for this tuple (which is the group by columns)
for (int i = 0; i < m_groupByColumnCount; i++)
m_searchKey.setNValue(i, oldTuple.getNValue(m_groupByColumns[i]));
// determine if the row exists (create the empty one if it doesn't)
m_index->moveToKey(&m_searchKey);
m_existingTuple = m_index->nextValueAtKey();
if (m_existingTuple.isNullTuple()) {
if (expected) {
throw SerializableEEException(VOLT_EE_EXCEPTION_TYPE_EEEXCEPTION,
"MaterializedViewMetadata went"
" looking for a tuple in the view and"
" expected to find it but didn't");
}
return false;
}
else {
return true;
}
}
示例9: findExistingTuple
bool MaterializedViewMetadata::findExistingTuple(TableTuple &oldTuple, bool expected) {
// find the key for this tuple (which is the group by columns)
for (int i = 0; i < m_groupByColumnCount; i++) {
m_searchKey.setNValue(i, oldTuple.getNValue(m_groupByColumns[i]));
}
// determine if the row exists (create the empty one if it doesn't)
m_index->moveToKey(&m_searchKey);
m_existingTuple = m_index->nextValueAtKey();
if (m_existingTuple.isNullTuple()) {
if (expected) {
std::string name = m_target->name();
throwFatalException("MaterializedViewMetadata for table %s went"
" looking for a tuple in the view and"
" expected to find it but didn't", name.c_str());
}
return false;
}
else {
return true;
}
}
示例10: p_execute
bool UpdateExecutor::p_execute(const NValueArray ¶ms, ReadWriteTracker *tracker) {
assert(m_inputTable);
assert(m_targetTable);
VOLT_TRACE("INPUT TABLE: %s\n", m_inputTable->debug().c_str());
VOLT_TRACE("TARGET TABLE - BEFORE: %s\n", m_targetTable->debug().c_str());
assert(m_inputTuple.sizeInValues() == m_inputTable->columnCount());
assert(m_targetTuple.sizeInValues() == m_targetTable->columnCount());
TableIterator input_iterator(m_inputTable);
while (input_iterator.next(m_inputTuple)) {
//
// OPTIMIZATION: Single-Sited Query Plans
// If our beloved UpdatePlanNode is apart of a single-site query plan,
// then the first column in the input table will be the address of a
// tuple on the target table that we will want to update. This saves us
// the trouble of having to do an index lookup
//
void *target_address = m_inputTuple.getNValue(0).castAsAddress();
m_targetTuple.move(target_address);
// Read/Write Set Tracking
if (tracker != NULL) {
tracker->markTupleWritten(m_targetTable, &m_targetTuple);
}
// Loop through INPUT_COL_IDX->TARGET_COL_IDX mapping and only update
// the values that we need to. The key thing to note here is that we
// grab a temp tuple that is a copy of the target tuple (i.e., the tuple
// we want to update). This insures that if the input tuple is somehow
// bringing garbage with it, we're only going to copy what we really
// need to into the target tuple.
//
TableTuple &tempTuple = m_targetTable->getTempTupleInlined(m_targetTuple);
for (int map_ctr = 0; map_ctr < m_inputTargetMapSize; map_ctr++) {
tempTuple.setNValue(m_inputTargetMap[map_ctr].second,
m_inputTuple.getNValue(m_inputTargetMap[map_ctr].first));
}
// if there is a partition column for the target table
if (m_partitionColumn != -1) {
// check for partition problems
// get the value for the partition column
NValue value = tempTuple.getNValue(m_partitionColumn);
bool isLocal = m_engine->isLocalSite(value);
// if it doesn't map to this site
if (!isLocal) {
VOLT_ERROR("Mispartitioned tuple in single-partition plan for"
" table '%s'", m_targetTable->name().c_str());
return false;
}
}
#ifdef ARIES
if(m_engine->isARIESEnabled()){
// add persistency check:
PersistentTable* table = dynamic_cast<PersistentTable*>(m_targetTable);
// only log if we are writing to a persistent table.
if (table != NULL) {
// before image -- target is old val with no updates
// XXX: what about uninlined fields?
// should we not be doing
// m_targetTable->getTempTupleInlined(m_targetTuple); instead?
TableTuple *beforeImage = &m_targetTuple;
// after image -- temp is NEW, created using target and input
TableTuple *afterImage = &tempTuple;
TableTuple *keyTuple = NULL;
char *keydata = NULL;
std::vector<int32_t> modifiedCols;
int32_t numCols = -1;
// See if we can do better by using an index instead
TableIndex *index = table->primaryKeyIndex();
if (index != NULL) {
// First construct tuple for primary key
keydata = new char[index->getKeySchema()->tupleLength()];
keyTuple = new TableTuple(keydata, index->getKeySchema());
for (int i = 0; i < index->getKeySchema()->columnCount(); i++) {
keyTuple->setNValue(i, beforeImage->getNValue(index->getColumnIndices()[i]));
}
// no before image need be recorded, just the primary key
beforeImage = NULL;
}
// Set the modified column list
numCols = m_inputTargetMapSize;
modifiedCols.resize(m_inputTargetMapSize, -1);
for (int map_ctr = 0; map_ctr < m_inputTargetMapSize; map_ctr++) {
// can't use column-id directly, otherwise we would go over vector bounds
//.........这里部分代码省略.........
示例11: compare
NValue compare(const TableTuple& tuple) const
{
assert(tuple.getSchema()->columnCount() == 1);
return compare<OP>(tuple.getNValue(0));
}
示例12: p_execute
//.........这里部分代码省略.........
}
}
if (tuple.isNullTuple()) {
tableIndex->moveToEnd(false);
}
}
}
else {
return false;
}
} else {
bool toStartActually = (localSortDirection != SORT_DIRECTION_TYPE_DESC);
tableIndex->moveToEnd(toStartActually);
}
int tuple_ctr = 0;
int tuples_skipped = 0; // for offset
int limit = -1;
int offset = -1;
if (limit_node != NULL) {
limit_node->getLimitAndOffsetByReference(params, limit, offset);
}
//
// We have to different nextValue() methods for different lookup types
//
while ((limit == -1 || tuple_ctr < limit) &&
((localLookupType == INDEX_LOOKUP_TYPE_EQ &&
!(tuple = tableIndex->nextValueAtKey()).isNullTuple()) ||
((localLookupType != INDEX_LOOKUP_TYPE_EQ || activeNumOfSearchKeys == 0) &&
!(tuple = tableIndex->nextValue()).isNullTuple()))) {
VOLT_TRACE("LOOPING in indexscan: tuple: '%s'\n", tuple.debug("tablename").c_str());
pmp.countdownProgress();
//
// First check to eliminate the null index rows for UNDERFLOW case only
//
if (skipNullExpr != NULL) {
if (skipNullExpr->eval(&tuple, NULL).isTrue()) {
VOLT_DEBUG("Index scan: find out null rows or columns.");
continue;
} else {
skipNullExpr = NULL;
}
}
//
// First check whether the end_expression is now false
//
if (end_expression != NULL && !end_expression->eval(&tuple, NULL).isTrue()) {
VOLT_TRACE("End Expression evaluated to false, stopping scan");
break;
}
//
// Then apply our post-predicate to do further filtering
//
if (post_expression == NULL || post_expression->eval(&tuple, NULL).isTrue()) {
//
// INLINE OFFSET
//
if (tuples_skipped < offset)
{
tuples_skipped++;
continue;
}
tuple_ctr++;
if (m_projectionNode != NULL)
{
TableTuple &temp_tuple = m_outputTable->tempTuple();
if (m_projectionAllTupleArray != NULL)
{
VOLT_TRACE("sweet, all tuples");
for (int ctr = m_numOfColumns - 1; ctr >= 0; --ctr) {
temp_tuple.setNValue(ctr, tuple.getNValue(m_projectionAllTupleArray[ctr]));
}
}
else
{
for (int ctr = m_numOfColumns - 1; ctr >= 0; --ctr) {
temp_tuple.setNValue(ctr, m_projectionExpressions[ctr]->eval(&tuple, NULL));
}
}
m_outputTable->insertTupleNonVirtual(temp_tuple);
}
else
//
// Straight Insert
//
{
//
// Try to put the tuple into our output table
//
m_outputTable->insertTupleNonVirtual(tuple);
}
pmp.countdownProgress();
}
}
VOLT_DEBUG ("Index Scanned :\n %s", m_outputTable->debug().c_str());
return true;
}
示例13: setSearchKeyFromTuple
void setSearchKeyFromTuple(TableTuple &source) {
keyTuple.setNValue(0, source.getNValue(1));
keyTuple.setNValue(1, source.getNValue(2));
}
示例14: p_execute
bool DeleteExecutor::p_execute(const NValueArray ¶ms, ReadWriteTracker *tracker) {
assert(m_targetTable);
if (m_truncate) {
VOLT_TRACE("truncating table %s...", m_targetTable->name().c_str());
// count the truncated tuples as deleted
m_engine->m_tuplesModified += m_inputTable->activeTupleCount();
#ifdef ARIES
if(m_engine->isARIESEnabled()){
// no need of persistency check, m_targetTable is
// always persistent for deletes
LogRecord *logrecord = new LogRecord(computeTimeStamp(),
LogRecord::T_TRUNCATE,// this is a truncate record
LogRecord::T_FORWARD,// the system is running normally
-1,// XXX: prevLSN must be fetched from table!
m_engine->getExecutorContext()->currentTxnId() ,// txn id
m_engine->getSiteId(),// which execution site
m_targetTable->name(),// the table affected
NULL,// primary key irrelevant
-1,// irrelevant numCols
NULL,// list of modified cols irrelevant
NULL,// before image irrelevant
NULL// after image irrelevant
);
size_t logrecordLength = logrecord->getEstimatedLength();
char *logrecordBuffer = new char[logrecordLength];
FallbackSerializeOutput output;
output.initializeWithPosition(logrecordBuffer, logrecordLength, 0);
logrecord->serializeTo(output);
LogManager* m_logManager = this->m_engine->getLogManager();
Logger m_ariesLogger = m_logManager->getAriesLogger();
//VOLT_WARN("m_logManager : %p AriesLogger : %p",&m_logManager, &m_ariesLogger);
const Logger *logger = m_logManager->getThreadLogger(LOGGERID_MM_ARIES);
logger->log(LOGLEVEL_INFO, output.data(), output.position());
delete[] logrecordBuffer;
logrecordBuffer = NULL;
delete logrecord;
logrecord = NULL;
}
#endif
//m_engine->context().incrementTuples(m_targetTable->activeTupleCount());
// actually delete all the tuples
m_targetTable->deleteAllTuples(true);
return true;
}
// XXX : ARIES : Not sure if else is needed ?
assert(m_inputTable);
assert(m_inputTuple.sizeInValues() == m_inputTable->columnCount());
assert(m_targetTuple.sizeInValues() == m_targetTable->columnCount());
TableIterator inputIterator(m_inputTable);
while (inputIterator.next(m_inputTuple)) {
//
// OPTIMIZATION: Single-Sited Query Plans
// If our beloved DeletePlanNode is apart of a single-site query plan,
// then the first column in the input table will be the address of a
// tuple on the target table that we will want to blow away. This saves
// us the trouble of having to do an index lookup
//
void *targetAddress = m_inputTuple.getNValue(0).castAsAddress();
m_targetTuple.move(targetAddress);
// Read/Write Set Tracking
if (tracker != NULL) {
tracker->markTupleWritten(m_targetTable, &m_targetTuple);
}
#ifdef ARIES
if(m_engine->isARIESEnabled()){
// no need of persistency check, m_targetTable is
// always persistent for deletes
// before image -- target is tuple to be deleted.
TableTuple *beforeImage = &m_targetTuple;
TableTuple *keyTuple = NULL;
char *keydata = NULL;
// See if we use an index instead
TableIndex *index = m_targetTable->primaryKeyIndex();
if (index != NULL) {
// First construct tuple for primary key
keydata = new char[index->getKeySchema()->tupleLength()];
keyTuple = new TableTuple(keydata, index->getKeySchema());
for (int i = 0; i < index->getKeySchema()->columnCount(); i++) {
keyTuple->setNValue(i, beforeImage->getNValue(index->getColumnIndices()[i]));
//.........这里部分代码省略.........
示例15: generateHash
/**
* Generate hash value for key.
*/
ElasticHash ElasticIndex::generateHash(const PersistentTable &table, const TableTuple &tuple)
{
return tuple.getNValue(table.partitionColumn()).murmurHash3();
}