本文整理汇总了C++中PersistentTable::getDRTimestampColumnIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ PersistentTable::getDRTimestampColumnIndex方法的具体用法?C++ PersistentTable::getDRTimestampColumnIndex怎么用?C++ PersistentTable::getDRTimestampColumnIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PersistentTable
的用法示例。
在下文中一共展示了PersistentTable::getDRTimestampColumnIndex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: storage
TEST_F(PersistentTableTest, DRTimestampColumn) {
// Load a catalog where active/active DR is turned on for the database,
// And we have a table "T" which is being DRed.
getEngine()->loadCatalog(0, catalogPayload());
PersistentTable *table = dynamic_cast<PersistentTable*>(
getEngine()->getTable("T"));
ASSERT_NE(NULL, table);
ASSERT_EQ(true, table->hasDRTimestampColumn());
ASSERT_EQ(0, table->getDRTimestampColumnIndex());
const voltdb::TupleSchema* schema = table->schema();
ASSERT_EQ(1, schema->hiddenColumnCount());
voltdb::StandAloneTupleStorage storage(schema);
TableTuple &srcTuple = const_cast<TableTuple&>(storage.tuple());
NValue bigintNValues[] = {
ValueFactory::getBigIntValue(1900),
ValueFactory::getBigIntValue(1901),
ValueFactory::getBigIntValue(1902)
};
NValue stringNValues[] = {
ValueFactory::getTempStringValue("Je me souviens"),
ValueFactory::getTempStringValue("Ut Incepit Fidelis Sic Permanet"),
ValueFactory::getTempStringValue("Splendor sine occasu")
};
// Let's do some inserts into the table.
beginWork();
for (int i = 0; i < 3; ++i) {
srcTuple.setNValue(0, bigintNValues[i]);
srcTuple.setNValue(1, stringNValues[i]);
table->insertTuple(srcTuple);
}
commit();
// Now verify that the right DR timestamp was created in the
// hidden column for each row.
int64_t drTimestampOrig = ExecutorContext::getExecutorContext()->currentDRTimestamp();
NValue drTimestampValueOrig = ValueFactory::getBigIntValue(drTimestampOrig);
TableTuple tuple(schema);
TableIterator iterator = table->iteratorDeletingAsWeGo();
int i = 0;
const int timestampColIndex = table->getDRTimestampColumnIndex();
while (iterator.next(tuple)) {
// DR timestamp is set for each row.
EXPECT_EQ(0, tuple.getHiddenNValue(timestampColIndex).compare(drTimestampValueOrig));
EXPECT_EQ(0, tuple.getNValue(0).compare(bigintNValues[i]));
EXPECT_EQ(0, tuple.getNValue(1).compare(stringNValues[i]));
++i;
}
// Now let's update the middle tuple with a new value, and make
// sure the DR timestamp changes.
beginWork();
NValue newStringData = ValueFactory::getTempStringValue("Nunavut Sannginivut");
iterator = table->iteratorDeletingAsWeGo();
ASSERT_TRUE(iterator.next(tuple));
ASSERT_TRUE(iterator.next(tuple));
TableTuple& tempTuple = table->copyIntoTempTuple(tuple);
tempTuple.setNValue(1, newStringData);
table->updateTupleWithSpecificIndexes(tuple,
tempTuple,
table->allIndexes());
// verify the updated tuple has the new timestamp.
int64_t drTimestampNew = ExecutorContext::getExecutorContext()->currentDRTimestamp();
ASSERT_NE(drTimestampNew, drTimestampOrig);
NValue drTimestampValueNew = ValueFactory::getBigIntValue(drTimestampNew);
iterator = table->iteratorDeletingAsWeGo();
i = 0;
while (iterator.next(tuple)) {
if (i == 1) {
EXPECT_EQ(0, tuple.getHiddenNValue(timestampColIndex).compare(drTimestampValueNew));
EXPECT_EQ(0, tuple.getNValue(0).compare(bigintNValues[i]));
EXPECT_EQ(0, tuple.getNValue(1).compare(newStringData));
}
else {
EXPECT_EQ(0, tuple.getHiddenNValue(timestampColIndex).compare(drTimestampValueOrig));
EXPECT_EQ(0, tuple.getNValue(0).compare(bigintNValues[i]));
EXPECT_EQ(0, tuple.getNValue(1).compare(stringNValues[i]));
}
++i;
}
// After rolling back, we should have all our original values,
// including the DR timestamp.
rollback();
i = 0;
//.........这里部分代码省略.........