本文整理汇总了C++中TableTuple::tupleLength方法的典型用法代码示例。如果您正苦于以下问题:C++ TableTuple::tupleLength方法的具体用法?C++ TableTuple::tupleLength怎么用?C++ TableTuple::tupleLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TableTuple
的用法示例。
在下文中一共展示了TableTuple::tupleLength方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TableTuple
TableTuple *newTuple(TupleSchema *schema, int idx, long value) {
TableTuple *tuple = new TableTuple(schema);
char *data = new char[tuple->tupleLength()];
memset(data, 0, tuple->tupleLength());
tuple->move(data);
tuple->setNValue(idx, ValueFactory::getBigIntValue(value));
return tuple;
}
示例2: addRandomUniqueTuples
void addRandomUniqueTuples(Table *table, int numTuples) {
TableTuple tuple = table->tempTuple();
::memset(tuple.address() + 1, 0, tuple.tupleLength() - 1);
for (int ii = 0; ii < numTuples; ii++) {
tuple.setNValue(0, ValueFactory::getIntegerValue(m_primaryKeyIndex++));
tuple.setNValue(1, ValueFactory::getIntegerValue(rand()));
bool success = table->insertTuple(tuple);
if (!success) {
std::cout << "Failed to add random unique tuple" << std::endl;
return;
}
}
}
示例3: markTupleDirty
void CopyOnWriteContext::markTupleDirty(TableTuple tuple, bool newTuple) {
/**
* If this an update or a delete of a tuple that is already dirty then no further action is
* required.
*/
if (!newTuple && tuple.isDirty()) {
return;
}
/**
* If the table has been scanned already there is no need to continue marking tuples dirty
* If the tuple is dirty then it has already been backed up.
*/
if (m_finishedTableScan) {
tuple.setDirtyFalse();
return;
}
/**
* Find out which block the address is contained in.
*/
char *address = tuple.address();
#ifdef MEMCHECK
BlockPair compP;
compP.pair = std::pair<char*, int>(address, 0);
compP.tupleLength = tuple.tupleLength();
#else
const BlockPair compP(address, 0);
#endif
BlockPairVectorI i =
std::lower_bound(m_blocks.begin(), m_blocks.end(), compP, pairAddressToPairAddressComparator);
if (i == m_blocks.end()) {
tuple.setDirtyFalse();
return;
}
#ifdef MEMCHECK
const char *blockStartAddress = (*i).pair.first;
const int blockIndex = (*i).pair.second;
const char *blockEndAddress = blockStartAddress + tuple.tupleLength();
#else
const char *blockStartAddress = (*i).first;
const int blockIndex = (*i).second;
const char *blockEndAddress = blockStartAddress + TABLE_BLOCKSIZE;
#endif
if (address >= blockEndAddress || address < blockStartAddress) {
/**
* Tuple is in a block allocated after the start of COW
*/
tuple.setDirtyFalse();
return;
}
/**
* Now check where this is relative to the COWIterator.
*/
CopyOnWriteIterator *iter = reinterpret_cast<CopyOnWriteIterator*>(m_iterator.get());
if (iter->needToDirtyTuple(blockIndex, address, newTuple)) {
tuple.setDirtyTrue();
/**
* Don't back up a newly introduced tuple, just mark it as dirty.
*/
if (!newTuple) {
m_backedUpTuples->insertTupleNonVirtualWithDeepCopy(tuple, &m_pool);
}
} else {
tuple.setDirtyFalse();
return;
}
}