void Database::CompactIndex(const string& index_name, lsn_t snapshot_lsn) { if (snapshot_lsn == indices[index_name]->GetLastPersistentLSN()) { return; // nothing to do } LookupIterator snapshot = indices[index_name]->GetSnapshot(snapshot_lsn); ImmutableIndexWriter* writer = ImmutableIndex::Create( GetIndexPrefix(name, index_name), snapshot_lsn, 64*1024); while (snapshot.hasMore()) { writer->Add((*snapshot).first, (*snapshot).second); ++snapshot; } writer->Finalize(); }
void EXPECT_KEY_ADVANCE( LookupIterator& it, const babudb::Buffer& key, const babudb::Buffer& value) { EXPECT_TRUE(it.hasMore()); if (!((*it).first == key)) { string found((char*)(*it).first.data, (*it).first.size); string expected((char*)key.data ,key.size); EXPECT_TRUE(false); } if (!((*it).second == value)) { string found((char*)(*it).second.data, (*it).second.size); string expected((char*)value.data, value.size); EXPECT_TRUE(false); } ++it; }