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
main
Kai Liu 11 years ago
parent 74939a9e13
commit ff151132b3
  1. 12
      table/block_based_table_reader.cc

@ -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;
}

Loading…
Cancel
Save