Fix the unit test failure in devbox

Summary:
My last diff was developed in MacOS but in devserver environment error occurs.

I dug into the problem and found the way we calcuate approximate data size is pretty out-of-date. We can use table properties to get more accurate results.

Test Plan: ran ./table_test and passed

Reviewers: igor, dhruba, haobo, sdong

CC: leveldb

Differential Revision: https://reviews.facebook.net/D16509
This commit is contained in:
Kai Liu 2014-02-28 20:37:32 -08:00
parent 74939a9e13
commit ff151132b3

View File

@ -1025,10 +1025,14 @@ uint64_t BlockBasedTable::ApproximateOffsetOf(const Slice& key) {
result = rep_->metaindex_handle.offset();
}
} else {
// key is past the last key in the file. Approximate the offset
// by returning the offset of the metaindex block (which is
// right near the end of the file).
result = rep_->metaindex_handle.offset();
// key is past the last key in the file. If table_properties is not
// available, approximate the offset by returning the offset of the
// metaindex block (which is right near the end of the file).
result = rep_->table_properties->data_size;
// table_properties is not present in the table.
if (result == 0) {
result = rep_->metaindex_handle.offset();
}
}
return result;
}