本文整理汇总了C++中Database::GetMinimalPersistentLSN方法的典型用法代码示例。如果您正苦于以下问题:C++ Database::GetMinimalPersistentLSN方法的具体用法?C++ Database::GetMinimalPersistentLSN怎么用?C++ Database::GetMinimalPersistentLSN使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Database
的用法示例。
在下文中一共展示了Database::GetMinimalPersistentLSN方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IndexMerger
TEST_TMPDIR(Database_Migration,babudb)
{
StringOrder myorder;
IndexMerger* merger = new IndexMerger(testPath("test-testidx").getHostCharsetPath(), myorder);
merger->Add(1, Buffer("Key1"), Buffer("data1"));
merger->Add(2, Buffer("Key2"), Buffer("data2"));
merger->Run();
delete merger;
std::vector<babudb::IndexDescriptor> indices;
indices.push_back(std::make_pair("testidx", &myorder));
Database* db = Database::Open(testPath("test").getHostCharsetPath(), indices);
EXPECT_EQUAL(db->GetMinimalPersistentLSN(), 2);
EXPECT_FALSE(db->Lookup("testidx", babudb::Buffer::wrap("Key1")).isEmpty());
EXPECT_FALSE(db->Lookup("testidx", babudb::Buffer::wrap("Key2")).isEmpty());
EXPECT_TRUE(db->Lookup("testidx", babudb::Buffer::wrap("Key3")).isNotExists());
StringSetOperation(3, "testidx", "Key3").ApplyTo(*db, 3);
EXPECT_FALSE(db->Lookup("testidx", babudb::Buffer::wrap("Key1")).isEmpty());
EXPECT_FALSE(db->Lookup("testidx", babudb::Buffer::wrap("Key2")).isEmpty());
EXPECT_TRUE(db->Lookup("testidx", babudb::Buffer::wrap("Key3")).isNotExists());
EXPECT_TRUE(db->Lookup("testidx", babudb::Buffer::wrap("Key4")).isNotExists());
delete db;
}
示例2: StringSetOperation
TEST_TMPDIR(Database_SnapshotAndImport,babudb)
{
StringOrder myorder;
std::vector<babudb::IndexDescriptor> indices;
indices.push_back(std::make_pair("testidx", &myorder));
indices.push_back(std::make_pair("testidx2", &myorder));
Database* db = Database::Open(testPath("test").getHostCharsetPath(), indices);
EXPECT_EQUAL(0, db->GetMinimalPersistentLSN());
EXPECT_EQUAL(0, db->GetCurrentLSN());
StringSetOperation(1, "testidx", "Key1","data1").ApplyTo(*db, 1);
StringSetOperation(2, "testidx", "Key2","data2").ApplyTo(*db, 2);
StringSetOperation(3, "testidx2", "Key1","data1").ApplyTo(*db, 3);
EXPECT_EQUAL(0, db->GetMinimalPersistentLSN());
EXPECT_EQUAL(3, db->GetCurrentLSN());
vector<pair<string, babudb::lsn_t> > index_versions = db->GetIndexVersions();
for (vector<pair<string, babudb::lsn_t> >::iterator i = index_versions.begin(); i != index_versions.end(); ++i) {
db->Snapshot(i->first);
db->CompactIndex(i->first, db->GetCurrentLSN());
}
// The database has not loaded the new index base yet,
// we merely created index files with a newer version
index_versions = db->GetIndexVersions();
for (vector<pair<string, babudb::lsn_t> >::iterator i = index_versions.begin();
i != index_versions.end(); ++i) {
EXPECT_EQUAL(0, i->second);
}
// Now reopen the index files we have just compacted
db->ReopenIndices();
index_versions = db->GetIndexVersions();
for (vector<pair<string, babudb::lsn_t> >::iterator i = index_versions.begin();
i != index_versions.end(); ++i) {
EXPECT_EQUAL(db->GetCurrentLSN(), i->second);
}
delete db;
db = Database::Open(testPath("test").getHostCharsetPath(), indices);
EXPECT_EQUAL(3, db->GetMinimalPersistentLSN());
EXPECT_EQUAL(3, db->GetCurrentLSN());
const int current_lsn = db->GetCurrentLSN();
index_versions = db->GetIndexVersions();
for (vector<pair<string, babudb::lsn_t> >::iterator i = index_versions.begin(); i != index_versions.end(); ++i) {
EXPECT_EQUAL(3, i->second);
}
delete db;
// And now import the index snapshots into a new database
EXPECT_TRUE(Database::ImportIndex(
testPath("copy").getHostCharsetPath(), "testidx", current_lsn,
testPath("test-testidx_3.idx"), false));
EXPECT_TRUE(Database::ImportIndex(
testPath("copy").getHostCharsetPath(), "testidx2", current_lsn,
testPath("test-testidx2_3.idx"), false));
db = Database::Open(testPath("copy").getHostCharsetPath(), indices);
EXPECT_EQUAL(3, db->GetMinimalPersistentLSN());
EXPECT_EQUAL(3, db->GetCurrentLSN());
delete db;
}