@ -73,7 +73,7 @@ class VersionBuilderTest : public testing::Test {
/* marked_for_compact */ false , Temperature : : kUnknown ,
oldest_blob_file_number , kUnknownOldestAncesterTime ,
kUnknownFileCreationTime , epoch_number , kUnknownFileChecksum ,
kUnknownFileChecksumFuncName , kNullUniqueId64x2 ) ;
kUnknownFileChecksumFuncName , kNullUniqueId64x2 , 0 ) ;
f - > compensated_file_size = file_size ;
f - > num_entries = num_entries ;
f - > num_deletions = num_deletions ;
@ -130,12 +130,13 @@ class VersionBuilderTest : public testing::Test {
constexpr SequenceNumber largest_seqno = 300 ;
constexpr bool marked_for_compaction = false ;
edit - > AddFile (
level , table_file_number , path_id , file_size , GetInternalKey ( smallest ) ,
GetInternalKey ( largest ) , smallest_seqno , largest_seqno ,
marked_for_compaction , Temperature : : kUnknown , blob_file_number ,
kUnknownOldestAncesterTime , kUnknownFileCreationTime , epoch_number ,
kUnknownFileChecksum , kUnknownFileChecksumFuncName , kNullUniqueId64x2 ) ;
edit - > AddFile ( level , table_file_number , path_id , file_size ,
GetInternalKey ( smallest ) , GetInternalKey ( largest ) ,
smallest_seqno , largest_seqno , marked_for_compaction ,
Temperature : : kUnknown , blob_file_number ,
kUnknownOldestAncesterTime , kUnknownFileCreationTime ,
epoch_number , kUnknownFileChecksum ,
kUnknownFileChecksumFuncName , kNullUniqueId64x2 , 0 ) ;
}
void UpdateVersionStorageInfo ( VersionStorageInfo * vstorage ) {
@ -186,7 +187,7 @@ TEST_F(VersionBuilderTest, ApplyAndSaveTo) {
2 , 666 , 0 , 100U , GetInternalKey ( " 301 " ) , GetInternalKey ( " 350 " ) , 200 , 200 ,
false , Temperature : : kUnknown , kInvalidBlobFileNumber ,
kUnknownOldestAncesterTime , kUnknownFileCreationTime , kUnknownEpochNumber ,
kUnknownFileChecksum , kUnknownFileChecksumFuncName , kNullUniqueId64x2 ) ;
kUnknownFileChecksum , kUnknownFileChecksumFuncName , kNullUniqueId64x2 , 0 ) ;
version_edit . DeleteFile ( 3 , 27U ) ;
EnvOptions env_options ;
@ -233,7 +234,8 @@ TEST_F(VersionBuilderTest, ApplyAndSaveToDynamic) {
3 , 666 , 0 , 100U , GetInternalKey ( " 301 " ) , GetInternalKey ( " 350 " ) , 200 , 200 ,
false , Temperature : : kUnknown , kInvalidBlobFileNumber ,
kUnknownOldestAncesterTime , kUnknownFileCreationTime , kUnknownEpochNumber ,
kUnknownFileChecksum , kUnknownFileChecksumFuncName , kNullUniqueId64x2 ) ;
kUnknownFileChecksum , kUnknownFileChecksumFuncName , kNullUniqueId64x2 , 0 ) ;
version_edit . DeleteFile ( 0 , 1U ) ;
version_edit . DeleteFile ( 0 , 88U ) ;
@ -283,7 +285,7 @@ TEST_F(VersionBuilderTest, ApplyAndSaveToDynamic2) {
4 , 666 , 0 , 100U , GetInternalKey ( " 301 " ) , GetInternalKey ( " 350 " ) , 200 , 200 ,
false , Temperature : : kUnknown , kInvalidBlobFileNumber ,
kUnknownOldestAncesterTime , kUnknownFileCreationTime , kUnknownEpochNumber ,
kUnknownFileChecksum , kUnknownFileChecksumFuncName , kNullUniqueId64x2 ) ;
kUnknownFileChecksum , kUnknownFileChecksumFuncName , kNullUniqueId64x2 , 0 ) ;
version_edit . DeleteFile ( 0 , 1U ) ;
version_edit . DeleteFile ( 0 , 88U ) ;
version_edit . DeleteFile ( 4 , 6U ) ;
@ -319,27 +321,27 @@ TEST_F(VersionBuilderTest, ApplyMultipleAndSaveTo) {
2 , 666 , 0 , 100U , GetInternalKey ( " 301 " ) , GetInternalKey ( " 350 " ) , 200 , 200 ,
false , Temperature : : kUnknown , kInvalidBlobFileNumber ,
kUnknownOldestAncesterTime , kUnknownFileCreationTime , kUnknownEpochNumber ,
kUnknownFileChecksum , kUnknownFileChecksumFuncName , kNullUniqueId64x2 ) ;
kUnknownFileChecksum , kUnknownFileChecksumFuncName , kNullUniqueId64x2 , 0 ) ;
version_edit . AddFile (
2 , 676 , 0 , 100U , GetInternalKey ( " 401 " ) , GetInternalKey ( " 450 " ) , 200 , 200 ,
false , Temperature : : kUnknown , kInvalidBlobFileNumber ,
kUnknownOldestAncesterTime , kUnknownFileCreationTime , kUnknownEpochNumber ,
kUnknownFileChecksum , kUnknownFileChecksumFuncName , kNullUniqueId64x2 ) ;
kUnknownFileChecksum , kUnknownFileChecksumFuncName , kNullUniqueId64x2 , 0 ) ;
version_edit . AddFile (
2 , 636 , 0 , 100U , GetInternalKey ( " 601 " ) , GetInternalKey ( " 650 " ) , 200 , 200 ,
false , Temperature : : kUnknown , kInvalidBlobFileNumber ,
kUnknownOldestAncesterTime , kUnknownFileCreationTime , kUnknownEpochNumber ,
kUnknownFileChecksum , kUnknownFileChecksumFuncName , kNullUniqueId64x2 ) ;
kUnknownFileChecksum , kUnknownFileChecksumFuncName , kNullUniqueId64x2 , 0 ) ;
version_edit . AddFile (
2 , 616 , 0 , 100U , GetInternalKey ( " 501 " ) , GetInternalKey ( " 550 " ) , 200 , 200 ,
false , Temperature : : kUnknown , kInvalidBlobFileNumber ,
kUnknownOldestAncesterTime , kUnknownFileCreationTime , kUnknownEpochNumber ,
kUnknownFileChecksum , kUnknownFileChecksumFuncName , kNullUniqueId64x2 ) ;
kUnknownFileChecksum , kUnknownFileChecksumFuncName , kNullUniqueId64x2 , 0 ) ;
version_edit . AddFile (
2 , 606 , 0 , 100U , GetInternalKey ( " 701 " ) , GetInternalKey ( " 750 " ) , 200 , 200 ,
false , Temperature : : kUnknown , kInvalidBlobFileNumber ,
kUnknownOldestAncesterTime , kUnknownFileCreationTime , kUnknownEpochNumber ,
kUnknownFileChecksum , kUnknownFileChecksumFuncName , kNullUniqueId64x2 ) ;
kUnknownFileChecksum , kUnknownFileChecksumFuncName , kNullUniqueId64x2 , 0 ) ;
EnvOptions env_options ;
constexpr TableCache * table_cache = nullptr ;
@ -378,27 +380,27 @@ TEST_F(VersionBuilderTest, ApplyDeleteAndSaveTo) {
2 , 666 , 0 , 100U , GetInternalKey ( " 301 " ) , GetInternalKey ( " 350 " ) , 200 , 200 ,
false , Temperature : : kUnknown , kInvalidBlobFileNumber ,
kUnknownOldestAncesterTime , kUnknownFileCreationTime , kUnknownEpochNumber ,
kUnknownFileChecksum , kUnknownFileChecksumFuncName , kNullUniqueId64x2 ) ;
kUnknownFileChecksum , kUnknownFileChecksumFuncName , kNullUniqueId64x2 , 0 ) ;
version_edit . AddFile (
2 , 676 , 0 , 100U , GetInternalKey ( " 401 " ) , GetInternalKey ( " 450 " ) , 200 , 200 ,
false , Temperature : : kUnknown , kInvalidBlobFileNumber ,
kUnknownOldestAncesterTime , kUnknownFileCreationTime , kUnknownEpochNumber ,
kUnknownFileChecksum , kUnknownFileChecksumFuncName , kNullUniqueId64x2 ) ;
kUnknownFileChecksum , kUnknownFileChecksumFuncName , kNullUniqueId64x2 , 0 ) ;
version_edit . AddFile (
2 , 636 , 0 , 100U , GetInternalKey ( " 601 " ) , GetInternalKey ( " 650 " ) , 200 , 200 ,
false , Temperature : : kUnknown , kInvalidBlobFileNumber ,
kUnknownOldestAncesterTime , kUnknownFileCreationTime , kUnknownEpochNumber ,
kUnknownFileChecksum , kUnknownFileChecksumFuncName , kNullUniqueId64x2 ) ;
kUnknownFileChecksum , kUnknownFileChecksumFuncName , kNullUniqueId64x2 , 0 ) ;
version_edit . AddFile (
2 , 616 , 0 , 100U , GetInternalKey ( " 501 " ) , GetInternalKey ( " 550 " ) , 200 , 200 ,
false , Temperature : : kUnknown , kInvalidBlobFileNumber ,
kUnknownOldestAncesterTime , kUnknownFileCreationTime , kUnknownEpochNumber ,
kUnknownFileChecksum , kUnknownFileChecksumFuncName , kNullUniqueId64x2 ) ;
kUnknownFileChecksum , kUnknownFileChecksumFuncName , kNullUniqueId64x2 , 0 ) ;
version_edit . AddFile (
2 , 606 , 0 , 100U , GetInternalKey ( " 701 " ) , GetInternalKey ( " 750 " ) , 200 , 200 ,
false , Temperature : : kUnknown , kInvalidBlobFileNumber ,
kUnknownOldestAncesterTime , kUnknownFileCreationTime , kUnknownEpochNumber ,
kUnknownFileChecksum , kUnknownFileChecksumFuncName , kNullUniqueId64x2 ) ;
kUnknownFileChecksum , kUnknownFileChecksumFuncName , kNullUniqueId64x2 , 0 ) ;
ASSERT_OK ( version_builder . Apply ( & version_edit ) ) ;
VersionEdit version_edit2 ;
@ -406,14 +408,14 @@ TEST_F(VersionBuilderTest, ApplyDeleteAndSaveTo) {
2 , 808 , 0 , 100U , GetInternalKey ( " 901 " ) , GetInternalKey ( " 950 " ) , 200 , 200 ,
false , Temperature : : kUnknown , kInvalidBlobFileNumber ,
kUnknownOldestAncesterTime , kUnknownFileCreationTime , kUnknownEpochNumber ,
kUnknownFileChecksum , kUnknownFileChecksumFuncName , kNullUniqueId64x2 ) ;
kUnknownFileChecksum , kUnknownFileChecksumFuncName , kNullUniqueId64x2 , 0 ) ;
version_edit2 . DeleteFile ( 2 , 616 ) ;
version_edit2 . DeleteFile ( 2 , 636 ) ;
version_edit . AddFile (
2 , 806 , 0 , 100U , GetInternalKey ( " 801 " ) , GetInternalKey ( " 850 " ) , 200 , 200 ,
false , Temperature : : kUnknown , kInvalidBlobFileNumber ,
kUnknownOldestAncesterTime , kUnknownFileCreationTime , kUnknownEpochNumber ,
kUnknownFileChecksum , kUnknownFileChecksumFuncName , kNullUniqueId64x2 ) ;
kUnknownFileChecksum , kUnknownFileChecksumFuncName , kNullUniqueId64x2 , 0 ) ;
ASSERT_OK ( version_builder . Apply ( & version_edit2 ) ) ;
ASSERT_OK ( version_builder . SaveTo ( & new_vstorage ) ) ;
@ -524,7 +526,7 @@ TEST_F(VersionBuilderTest, ApplyFileDeletionAndAddition) {
GetInternalKey ( largest , largest_seq ) , smallest_seqno , largest_seqno ,
marked_for_compaction , Temperature : : kUnknown , kInvalidBlobFileNumber ,
kUnknownOldestAncesterTime , kUnknownFileCreationTime , kUnknownEpochNumber ,
kUnknownFileChecksum , kUnknownFileChecksumFuncName , kNullUniqueId64x2 ) ;
kUnknownFileChecksum , kUnknownFileChecksumFuncName , kNullUniqueId64x2 , 0 ) ;
ASSERT_OK ( builder . Apply ( & addition ) ) ;
@ -573,7 +575,7 @@ TEST_F(VersionBuilderTest, ApplyFileAdditionAlreadyInBase) {
GetInternalKey ( largest ) , smallest_seqno , largest_seqno ,
marked_for_compaction , Temperature : : kUnknown , kInvalidBlobFileNumber ,
kUnknownOldestAncesterTime , kUnknownFileCreationTime , kUnknownEpochNumber ,
kUnknownFileChecksum , kUnknownFileChecksumFuncName , kNullUniqueId64x2 ) ;
kUnknownFileChecksum , kUnknownFileChecksumFuncName , kNullUniqueId64x2 , 0 ) ;
const Status s = builder . Apply ( & edit ) ;
ASSERT_TRUE ( s . IsCorruption ( ) ) ;
@ -609,7 +611,7 @@ TEST_F(VersionBuilderTest, ApplyFileAdditionAlreadyApplied) {
GetInternalKey ( largest ) , smallest_seqno , largest_seqno ,
marked_for_compaction , Temperature : : kUnknown , kInvalidBlobFileNumber ,
kUnknownOldestAncesterTime , kUnknownFileCreationTime , kUnknownEpochNumber ,
kUnknownFileChecksum , kUnknownFileChecksumFuncName , kNullUniqueId64x2 ) ;
kUnknownFileChecksum , kUnknownFileChecksumFuncName , kNullUniqueId64x2 , 0 ) ;
ASSERT_OK ( builder . Apply ( & edit ) ) ;
@ -622,7 +624,7 @@ TEST_F(VersionBuilderTest, ApplyFileAdditionAlreadyApplied) {
GetInternalKey ( largest ) , smallest_seqno , largest_seqno ,
marked_for_compaction , Temperature : : kUnknown , kInvalidBlobFileNumber ,
kUnknownOldestAncesterTime , kUnknownFileCreationTime , kUnknownEpochNumber ,
kUnknownFileChecksum , kUnknownFileChecksumFuncName , kNullUniqueId64x2 ) ;
kUnknownFileChecksum , kUnknownFileChecksumFuncName , kNullUniqueId64x2 , 0 ) ;
const Status s = builder . Apply ( & other_edit ) ;
ASSERT_TRUE ( s . IsCorruption ( ) ) ;
@ -658,7 +660,7 @@ TEST_F(VersionBuilderTest, ApplyFileAdditionAndDeletion) {
GetInternalKey ( largest ) , smallest_seqno , largest_seqno ,
marked_for_compaction , Temperature : : kUnknown , kInvalidBlobFileNumber ,
kUnknownOldestAncesterTime , kUnknownFileCreationTime , kUnknownEpochNumber ,
kUnknownFileChecksum , kUnknownFileChecksumFuncName , kNullUniqueId64x2 ) ;
kUnknownFileChecksum , kUnknownFileChecksumFuncName , kNullUniqueId64x2 , 0 ) ;
ASSERT_OK ( builder . Apply ( & addition ) ) ;
@ -1231,7 +1233,7 @@ TEST_F(VersionBuilderTest, SaveBlobFilesToConcurrentJobs) {
GetInternalKey ( largest ) , smallest_seqno , largest_seqno ,
marked_for_compaction , Temperature : : kUnknown , blob_file_number ,
kUnknownOldestAncesterTime , kUnknownFileCreationTime , 2 /*epoch_number*/ ,
checksum_value , checksum_method , kNullUniqueId64x2 ) ;
checksum_value , checksum_method , kNullUniqueId64x2 , 0 ) ;
edit . AddBlobFile ( blob_file_number , total_blob_count , total_blob_bytes ,
checksum_method , checksum_value ) ;
@ -1319,7 +1321,7 @@ TEST_F(VersionBuilderTest, CheckConsistencyForBlobFiles) {
/* oldest_blob_file_number */ 16 , kUnknownOldestAncesterTime ,
kUnknownFileCreationTime , kUnknownEpochNumber ,
kUnknownFileChecksum , kUnknownFileChecksumFuncName ,
kNullUniqueId64x2 ) ;
kNullUniqueId64x2 , 0 ) ;
edit . AddFile ( /* level */ 1 , /* file_number */ 700 , /* path_id */ 0 ,
/* file_size */ 100 , /* smallest */ GetInternalKey ( " 801 " ) ,
@ -1329,7 +1331,7 @@ TEST_F(VersionBuilderTest, CheckConsistencyForBlobFiles) {
/* oldest_blob_file_number */ 1000 , kUnknownOldestAncesterTime ,
kUnknownFileCreationTime , kUnknownEpochNumber ,
kUnknownFileChecksum , kUnknownFileChecksumFuncName ,
kNullUniqueId64x2 ) ;
kNullUniqueId64x2 , 0 ) ;
edit . AddBlobFile ( /* blob_file_number */ 1000 , /* total_blob_count */ 2000 ,
/* total_blob_bytes */ 200000 ,
/* checksum_method */ std : : string ( ) ,
@ -1550,7 +1552,7 @@ TEST_F(VersionBuilderTest, MaintainLinkedSstsForBlobFiles) {
Temperature : : kUnknown ,
/* oldest_blob_file_number */ 1 , kUnknownOldestAncesterTime ,
kUnknownFileCreationTime , kUnknownEpochNumber , kUnknownFileChecksum ,
kUnknownFileChecksumFuncName , kNullUniqueId64x2 ) ;
kUnknownFileChecksumFuncName , kNullUniqueId64x2 , 0 ) ;
// Add an SST that does not reference any blob files.
edit . AddFile (
@ -1560,7 +1562,7 @@ TEST_F(VersionBuilderTest, MaintainLinkedSstsForBlobFiles) {
/* largest_seqno */ 2200 , /* marked_for_compaction */ false ,
Temperature : : kUnknown , kInvalidBlobFileNumber , kUnknownOldestAncesterTime ,
kUnknownFileCreationTime , kUnknownEpochNumber , kUnknownFileChecksum ,
kUnknownFileChecksumFuncName , kNullUniqueId64x2 ) ;
kUnknownFileChecksumFuncName , kNullUniqueId64x2 , 0 ) ;
// Delete a file that references a blob file.
edit . DeleteFile ( /* level */ 1 , /* file_number */ 6 ) ;
@ -1583,7 +1585,7 @@ TEST_F(VersionBuilderTest, MaintainLinkedSstsForBlobFiles) {
/* oldest_blob_file_number */ 3 , kUnknownOldestAncesterTime ,
kUnknownFileCreationTime , kUnknownEpochNumber ,
kUnknownFileChecksum , kUnknownFileChecksumFuncName ,
kNullUniqueId64x2 ) ;
kNullUniqueId64x2 , 0 ) ;
// Trivially move a file that does not reference any blob files.
edit . DeleteFile ( /* level */ 1 , /* file_number */ 13 ) ;
@ -1595,7 +1597,7 @@ TEST_F(VersionBuilderTest, MaintainLinkedSstsForBlobFiles) {
Temperature : : kUnknown , kInvalidBlobFileNumber ,
kUnknownOldestAncesterTime , kUnknownFileCreationTime ,
kUnknownEpochNumber , kUnknownFileChecksum ,
kUnknownFileChecksumFuncName , kNullUniqueId64x2 ) ;
kUnknownFileChecksumFuncName , kNullUniqueId64x2 , 0 ) ;
// Add one more SST file that references a blob file, then promptly
// delete it in a second version edit before the new version gets saved.
@ -1609,7 +1611,7 @@ TEST_F(VersionBuilderTest, MaintainLinkedSstsForBlobFiles) {
/* oldest_blob_file_number */ 5 , kUnknownOldestAncesterTime ,
kUnknownFileCreationTime , kUnknownEpochNumber ,
kUnknownFileChecksum , kUnknownFileChecksumFuncName ,
kNullUniqueId64x2 ) ;
kNullUniqueId64x2 , 0 ) ;
VersionEdit edit2 ;
@ -1710,7 +1712,7 @@ TEST_F(VersionBuilderTest, CheckConsistencyForL0FilesSortedByEpochNumber) {
/* oldest_blob_file_number */ kInvalidBlobFileNumber ,
kUnknownOldestAncesterTime , kUnknownFileCreationTime ,
1 /* epoch_number */ , kUnknownFileChecksum , kUnknownFileChecksumFuncName ,
kNullUniqueId64x2 ) ;
kNullUniqueId64x2 , 0 ) ;
version_edit_1 . AddFile (
/* level */ 0 , /* file_number */ 2U , /* path_id */ 0 ,
/* file_size */ 100 , /* smallest */ GetInternalKey ( " b " , 2 ) ,
@ -1720,7 +1722,7 @@ TEST_F(VersionBuilderTest, CheckConsistencyForL0FilesSortedByEpochNumber) {
/* oldest_blob_file_number */ kInvalidBlobFileNumber ,
kUnknownOldestAncesterTime , kUnknownFileCreationTime ,
1 /* epoch_number */ , kUnknownFileChecksum , kUnknownFileChecksumFuncName ,
kNullUniqueId64x2 ) ;
kNullUniqueId64x2 , 0 ) ;
VersionBuilder version_builder_1 ( EnvOptions ( ) , & ioptions_ ,
nullptr /* table_cache */ , & vstorage_ ,
@ -1747,7 +1749,7 @@ TEST_F(VersionBuilderTest, CheckConsistencyForL0FilesSortedByEpochNumber) {
/* oldest_blob_file_number */ kInvalidBlobFileNumber ,
kUnknownOldestAncesterTime , kUnknownFileCreationTime ,
1 /* epoch_number */ , kUnknownFileChecksum , kUnknownFileChecksumFuncName ,
kNullUniqueId64x2 ) ;
kNullUniqueId64x2 , 0 ) ;
version_edit_2 . AddFile (
/* level */ 0 , /* file_number */ 2U , /* path_id */ 0 ,
/* file_size */ 100 , /* smallest */ GetInternalKey ( " b " , 2 ) ,
@ -1757,7 +1759,7 @@ TEST_F(VersionBuilderTest, CheckConsistencyForL0FilesSortedByEpochNumber) {
/* oldest_blob_file_number */ kInvalidBlobFileNumber ,
kUnknownOldestAncesterTime , kUnknownFileCreationTime ,
2 /* epoch_number */ , kUnknownFileChecksum , kUnknownFileChecksumFuncName ,
kNullUniqueId64x2 ) ;
kNullUniqueId64x2 , 0 ) ;
VersionBuilder version_builder_2 ( EnvOptions ( ) , & ioptions_ ,
nullptr /* table_cache */ , & vstorage_ ,