本文整理汇总了C++中TableIterator::hasNext方法的典型用法代码示例。如果您正苦于以下问题:C++ TableIterator::hasNext方法的具体用法?C++ TableIterator::hasNext怎么用?C++ TableIterator::hasNext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TableIterator
的用法示例。
在下文中一共展示了TableIterator::hasNext方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
TEST_F(LargeTempTableTest, iteratorDeletingAsWeGo) {
UniqueEngine engine = UniqueEngineBuilder().build();
LargeTempTableBlockCache* lttBlockCache = ExecutorContext::getExecutorContext()->lttBlockCache();
typedef std::tuple<int64_t, std::string> StdTuple;
TupleSchema* schema = Tools::buildSchema<StdTuple>();
std::vector<std::string> names{"id", "str"};
auto ltt = makeUniqueTable(TableFactory::buildLargeTempTable("ltmp", schema, names));
ASSERT_EQ(0, ltt->activeTupleCount());
ASSERT_EQ(0, ltt->allocatedBlockCount());
TableIterator tblIt = ltt->iteratorDeletingAsWeGo();
ASSERT_FALSE(tblIt.hasNext());
// Make sure iterating over an empty table works okay.
int scanCount = 0;
TableTuple iterTuple{ltt->schema()};
while (tblIt.next(iterTuple)) {
++scanCount;
}
ASSERT_EQ(0, scanCount);
// insert a row
StdTuple stdTuple{0, std::string(4096, 'z')};
TableTuple tupleForInsert = ltt->tempTuple(); // tuple now points at the storage for the temp tuple.
Tools::initTuple(&tupleForInsert, stdTuple);
ltt->insertTuple(tupleForInsert);
ltt->finishInserts();
ASSERT_EQ(1, ltt->activeTupleCount());
ASSERT_EQ(1, ltt->allocatedBlockCount());
ASSERT_EQ(1, lttBlockCache->totalBlockCount());
tblIt = ltt->iteratorDeletingAsWeGo();
while (tblIt.next(iterTuple)) {
++scanCount;
ASSERT_TUPLES_EQ(stdTuple, iterTuple);
}
ASSERT_EQ(1, scanCount);
// Table should again be empty
ASSERT_EQ(0, ltt->activeTupleCount());
ASSERT_EQ(0, ltt->allocatedBlockCount());
ASSERT_EQ(0, lttBlockCache->totalBlockCount());
// Calling iterator again should be a no-op
ASSERT_FALSE(tblIt.next(iterTuple));
ASSERT_FALSE(tblIt.next(iterTuple));
// Now insert more than one row
for (int i = 0; i < 100; ++i) {
std::get<0>(stdTuple) = i;
Tools::initTuple(&tupleForInsert, stdTuple);
ltt->insertTuple(tupleForInsert);
}
ltt->finishInserts();
ASSERT_EQ(100, ltt->activeTupleCount());
ASSERT_EQ(1, ltt->allocatedBlockCount());
ASSERT_EQ(1, lttBlockCache->totalBlockCount());
tblIt = ltt->iteratorDeletingAsWeGo();
int i = 0;
while (tblIt.next(iterTuple)) {
std::get<0>(stdTuple) = i;
ASSERT_TUPLES_EQ(stdTuple, iterTuple);
++i;
}
ASSERT_EQ(100, i);
// Table should again be empty
ASSERT_EQ(0, ltt->activeTupleCount());
ASSERT_EQ(0, ltt->allocatedBlockCount());
ASSERT_EQ(0, lttBlockCache->totalBlockCount());
// Calling iterator again should be a no-op
ASSERT_FALSE(tblIt.next(iterTuple));
ASSERT_FALSE(tblIt.next(iterTuple));
// Tuple length:
// inlined: 1 + 8 + 8 17
// non-inlined: 4096 + 12 4108
// ----
// 4125
// 8MB / 4125 = 2033 tuples / block
//
// Insert enough tuples for 3 blocks.
for (i = 0; i < 5000; ++i) {
std::get<0>(stdTuple) = i;
Tools::initTuple(&tupleForInsert, stdTuple);
ltt->insertTuple(tupleForInsert);
}
ltt->finishInserts();
ASSERT_EQ(5000, ltt->activeTupleCount());
ASSERT_EQ(3, ltt->allocatedBlockCount());
//.........这里部分代码省略.........