Parameterize table magic number

Summary:

As we are having different types of tables and they all might share the same structure in block-based table:

[metaindex block]
[index block]
[Footer]

To be able to identify differnt types of tables, we need to parameterize the "magic number" in the `Footer`.

Test Plan:

make check
This commit is contained in:
Kai Liu
2013-12-04 15:09:41 -08:00
parent f040e536e4
commit 3a0e98d558
4 changed files with 19 additions and 9 deletions

View File

@@ -77,6 +77,14 @@ void LogPropertiesCollectionError(
} // anonymous namespace
// kBlockedBasedTableMagicNumber was picked by running
// echo http://code.google.com/p/leveldb/ | sha1sum
// and taking the leading 64 bits.
// Please note that kBlockedBasedTableMagicNumber may also be accessed by
// other .cc files so it have to be explicitly declared with "extern".
extern const uint64_t kBlockedBasedTableMagicNumber
= 0xdb4775248b80fb57ull;
struct BlockBasedTableBuilder::Rep {
Options options;
WritableFile* file;
@@ -503,7 +511,7 @@ Status BlockBasedTableBuilder::Finish() {
// Write footer
if (ok()) {
Footer footer;
Footer footer(kBlockedBasedTableMagicNumber);
footer.set_metaindex_handle(metaindex_block_handle);
footer.set_index_handle(index_block_handle);
std::string footer_encoding;