@ -69,7 +69,8 @@ class VersionBuilderTest : public testing::Test {
GetInternalKey ( largest , largest_seq ) , smallest_seqno , largest_seqno ,
/* marked_for_compact */ false , oldest_blob_file_number ,
kUnknownOldestAncesterTime , kUnknownFileCreationTime ,
kUnknownFileChecksum , kUnknownFileChecksumFuncName ) ;
kUnknownFileChecksum , kUnknownFileChecksumFuncName ,
kDisableUserTimestamp , kDisableUserTimestamp ) ;
f - > compensated_file_size = file_size ;
f - > num_entries = num_entries ;
f - > num_deletions = num_deletions ;
@ -130,7 +131,8 @@ class VersionBuilderTest : public testing::Test {
smallest_seqno , largest_seqno , marked_for_compaction ,
blob_file_number , kUnknownOldestAncesterTime ,
kUnknownFileCreationTime , kUnknownFileChecksum ,
kUnknownFileChecksumFuncName ) ;
kUnknownFileChecksumFuncName , kDisableUserTimestamp ,
kDisableUserTimestamp ) ;
}
static std : : shared_ptr < BlobFileMetaData > GetBlobFileMetaData (
@ -190,7 +192,8 @@ TEST_F(VersionBuilderTest, ApplyAndSaveTo) {
GetInternalKey ( " 350 " ) , 200 , 200 , false ,
kInvalidBlobFileNumber , kUnknownOldestAncesterTime ,
kUnknownFileCreationTime , kUnknownFileChecksum ,
kUnknownFileChecksumFuncName ) ;
kUnknownFileChecksumFuncName , kDisableUserTimestamp ,
kDisableUserTimestamp ) ;
version_edit . DeleteFile ( 3 , 27U ) ;
EnvOptions env_options ;
@ -230,7 +233,8 @@ TEST_F(VersionBuilderTest, ApplyAndSaveToDynamic) {
GetInternalKey ( " 350 " ) , 200 , 200 , false ,
kInvalidBlobFileNumber , kUnknownOldestAncesterTime ,
kUnknownFileCreationTime , kUnknownFileChecksum ,
kUnknownFileChecksumFuncName ) ;
kUnknownFileChecksumFuncName , kDisableUserTimestamp ,
kDisableUserTimestamp ) ;
version_edit . DeleteFile ( 0 , 1U ) ;
version_edit . DeleteFile ( 0 , 88U ) ;
@ -273,7 +277,8 @@ TEST_F(VersionBuilderTest, ApplyAndSaveToDynamic2) {
GetInternalKey ( " 350 " ) , 200 , 200 , false ,
kInvalidBlobFileNumber , kUnknownOldestAncesterTime ,
kUnknownFileCreationTime , kUnknownFileChecksum ,
kUnknownFileChecksumFuncName ) ;
kUnknownFileChecksumFuncName , kDisableUserTimestamp ,
kDisableUserTimestamp ) ;
version_edit . DeleteFile ( 0 , 1U ) ;
version_edit . DeleteFile ( 0 , 88U ) ;
version_edit . DeleteFile ( 4 , 6U ) ;
@ -307,27 +312,32 @@ TEST_F(VersionBuilderTest, ApplyMultipleAndSaveTo) {
GetInternalKey ( " 350 " ) , 200 , 200 , false ,
kInvalidBlobFileNumber , kUnknownOldestAncesterTime ,
kUnknownFileCreationTime , kUnknownFileChecksum ,
kUnknownFileChecksumFuncName ) ;
kUnknownFileChecksumFuncName , kDisableUserTimestamp ,
kDisableUserTimestamp ) ;
version_edit . AddFile ( 2 , 676 , 0 , 100U , GetInternalKey ( " 401 " ) ,
GetInternalKey ( " 450 " ) , 200 , 200 , false ,
kInvalidBlobFileNumber , kUnknownOldestAncesterTime ,
kUnknownFileCreationTime , kUnknownFileChecksum ,
kUnknownFileChecksumFuncName ) ;
kUnknownFileChecksumFuncName , kDisableUserTimestamp ,
kDisableUserTimestamp ) ;
version_edit . AddFile ( 2 , 636 , 0 , 100U , GetInternalKey ( " 601 " ) ,
GetInternalKey ( " 650 " ) , 200 , 200 , false ,
kInvalidBlobFileNumber , kUnknownOldestAncesterTime ,
kUnknownFileCreationTime , kUnknownFileChecksum ,
kUnknownFileChecksumFuncName ) ;
kUnknownFileChecksumFuncName , kDisableUserTimestamp ,
kDisableUserTimestamp ) ;
version_edit . AddFile ( 2 , 616 , 0 , 100U , GetInternalKey ( " 501 " ) ,
GetInternalKey ( " 550 " ) , 200 , 200 , false ,
kInvalidBlobFileNumber , kUnknownOldestAncesterTime ,
kUnknownFileCreationTime , kUnknownFileChecksum ,
kUnknownFileChecksumFuncName ) ;
kUnknownFileChecksumFuncName , kDisableUserTimestamp ,
kDisableUserTimestamp ) ;
version_edit . AddFile ( 2 , 606 , 0 , 100U , GetInternalKey ( " 701 " ) ,
GetInternalKey ( " 750 " ) , 200 , 200 , false ,
kInvalidBlobFileNumber , kUnknownOldestAncesterTime ,
kUnknownFileCreationTime , kUnknownFileChecksum ,
kUnknownFileChecksumFuncName ) ;
kUnknownFileChecksumFuncName , kDisableUserTimestamp ,
kDisableUserTimestamp ) ;
EnvOptions env_options ;
constexpr TableCache * table_cache = nullptr ;
@ -364,27 +374,32 @@ TEST_F(VersionBuilderTest, ApplyDeleteAndSaveTo) {
GetInternalKey ( " 350 " ) , 200 , 200 , false ,
kInvalidBlobFileNumber , kUnknownOldestAncesterTime ,
kUnknownFileCreationTime , kUnknownFileChecksum ,
kUnknownFileChecksumFuncName ) ;
kUnknownFileChecksumFuncName , kDisableUserTimestamp ,
kDisableUserTimestamp ) ;
version_edit . AddFile ( 2 , 676 , 0 , 100U , GetInternalKey ( " 401 " ) ,
GetInternalKey ( " 450 " ) , 200 , 200 , false ,
kInvalidBlobFileNumber , kUnknownOldestAncesterTime ,
kUnknownFileCreationTime , kUnknownFileChecksum ,
kUnknownFileChecksumFuncName ) ;
kUnknownFileChecksumFuncName , kDisableUserTimestamp ,
kDisableUserTimestamp ) ;
version_edit . AddFile ( 2 , 636 , 0 , 100U , GetInternalKey ( " 601 " ) ,
GetInternalKey ( " 650 " ) , 200 , 200 , false ,
kInvalidBlobFileNumber , kUnknownOldestAncesterTime ,
kUnknownFileCreationTime , kUnknownFileChecksum ,
kUnknownFileChecksumFuncName ) ;
kUnknownFileChecksumFuncName , kDisableUserTimestamp ,
kDisableUserTimestamp ) ;
version_edit . AddFile ( 2 , 616 , 0 , 100U , GetInternalKey ( " 501 " ) ,
GetInternalKey ( " 550 " ) , 200 , 200 , false ,
kInvalidBlobFileNumber , kUnknownOldestAncesterTime ,
kUnknownFileCreationTime , kUnknownFileChecksum ,
kUnknownFileChecksumFuncName ) ;
kUnknownFileChecksumFuncName , kDisableUserTimestamp ,
kDisableUserTimestamp ) ;
version_edit . AddFile ( 2 , 606 , 0 , 100U , GetInternalKey ( " 701 " ) ,
GetInternalKey ( " 750 " ) , 200 , 200 , false ,
kInvalidBlobFileNumber , kUnknownOldestAncesterTime ,
kUnknownFileCreationTime , kUnknownFileChecksum ,
kUnknownFileChecksumFuncName ) ;
kUnknownFileChecksumFuncName , kDisableUserTimestamp ,
kDisableUserTimestamp ) ;
ASSERT_OK ( version_builder . Apply ( & version_edit ) ) ;
VersionEdit version_edit2 ;
@ -392,14 +407,16 @@ TEST_F(VersionBuilderTest, ApplyDeleteAndSaveTo) {
GetInternalKey ( " 950 " ) , 200 , 200 , false ,
kInvalidBlobFileNumber , kUnknownOldestAncesterTime ,
kUnknownFileCreationTime , kUnknownFileChecksum ,
kUnknownFileChecksumFuncName ) ;
kUnknownFileChecksumFuncName , kDisableUserTimestamp ,
kDisableUserTimestamp ) ;
version_edit2 . DeleteFile ( 2 , 616 ) ;
version_edit2 . DeleteFile ( 2 , 636 ) ;
version_edit . AddFile ( 2 , 806 , 0 , 100U , GetInternalKey ( " 801 " ) ,
GetInternalKey ( " 850 " ) , 200 , 200 , false ,
kInvalidBlobFileNumber , kUnknownOldestAncesterTime ,
kUnknownFileCreationTime , kUnknownFileChecksum ,
kUnknownFileChecksumFuncName ) ;
kUnknownFileChecksumFuncName , kDisableUserTimestamp ,
kDisableUserTimestamp ) ;
ASSERT_OK ( version_builder . Apply ( & version_edit2 ) ) ;
ASSERT_OK ( version_builder . SaveTo ( & new_vstorage ) ) ;
@ -500,7 +517,8 @@ TEST_F(VersionBuilderTest, ApplyFileDeletionAndAddition) {
GetInternalKey ( largest , largest_seq ) , smallest_seqno ,
largest_seqno , marked_for_compaction , kInvalidBlobFileNumber ,
kUnknownOldestAncesterTime , kUnknownFileCreationTime ,
kUnknownFileChecksum , kUnknownFileChecksumFuncName ) ;
kUnknownFileChecksum , kUnknownFileChecksumFuncName ,
kDisableUserTimestamp , kDisableUserTimestamp ) ;
ASSERT_OK ( builder . Apply ( & addition ) ) ;
@ -544,7 +562,8 @@ TEST_F(VersionBuilderTest, ApplyFileAdditionAlreadyInBase) {
smallest_seqno , largest_seqno , marked_for_compaction ,
kInvalidBlobFileNumber , kUnknownOldestAncesterTime ,
kUnknownFileCreationTime , kUnknownFileChecksum ,
kUnknownFileChecksumFuncName ) ;
kUnknownFileChecksumFuncName , kDisableUserTimestamp ,
kDisableUserTimestamp ) ;
const Status s = builder . Apply ( & edit ) ;
ASSERT_TRUE ( s . IsCorruption ( ) ) ;
@ -577,7 +596,8 @@ TEST_F(VersionBuilderTest, ApplyFileAdditionAlreadyApplied) {
GetInternalKey ( largest ) , smallest_seqno , largest_seqno ,
marked_for_compaction , kInvalidBlobFileNumber ,
kUnknownOldestAncesterTime , kUnknownFileCreationTime ,
kUnknownFileChecksum , kUnknownFileChecksumFuncName ) ;
kUnknownFileChecksum , kUnknownFileChecksumFuncName ,
kDisableUserTimestamp , kDisableUserTimestamp ) ;
ASSERT_OK ( builder . Apply ( & edit ) ) ;
@ -590,7 +610,8 @@ TEST_F(VersionBuilderTest, ApplyFileAdditionAlreadyApplied) {
smallest_seqno , largest_seqno , marked_for_compaction ,
kInvalidBlobFileNumber , kUnknownOldestAncesterTime ,
kUnknownFileCreationTime , kUnknownFileChecksum ,
kUnknownFileChecksumFuncName ) ;
kUnknownFileChecksumFuncName , kDisableUserTimestamp ,
kDisableUserTimestamp ) ;
const Status s = builder . Apply ( & other_edit ) ;
ASSERT_TRUE ( s . IsCorruption ( ) ) ;
@ -624,7 +645,8 @@ TEST_F(VersionBuilderTest, ApplyFileAdditionAndDeletion) {
smallest_seqno , largest_seqno , marked_for_compaction ,
kInvalidBlobFileNumber , kUnknownOldestAncesterTime ,
kUnknownFileCreationTime , kUnknownFileChecksum ,
kUnknownFileChecksumFuncName ) ;
kUnknownFileChecksumFuncName , kDisableUserTimestamp ,
kDisableUserTimestamp ) ;
ASSERT_OK ( builder . Apply ( & addition ) ) ;
@ -1154,7 +1176,8 @@ TEST_F(VersionBuilderTest, SaveBlobFilesToConcurrentJobs) {
GetInternalKey ( smallest ) , GetInternalKey ( largest ) ,
smallest_seqno , largest_seqno , marked_for_compaction ,
blob_file_number , kUnknownOldestAncesterTime ,
kUnknownFileCreationTime , checksum_value , checksum_method ) ;
kUnknownFileCreationTime , checksum_value , checksum_method ,
kDisableUserTimestamp , kDisableUserTimestamp ) ;
edit . AddBlobFile ( blob_file_number , total_blob_count , total_blob_bytes ,
checksum_method , checksum_value ) ;
@ -1238,7 +1261,8 @@ TEST_F(VersionBuilderTest, CheckConsistencyForBlobFiles) {
/* largest_seqno */ 200 , /* marked_for_compaction */ false ,
/* oldest_blob_file_number */ 16 , kUnknownOldestAncesterTime ,
kUnknownFileCreationTime , kUnknownFileChecksum ,
kUnknownFileChecksumFuncName ) ;
kUnknownFileChecksumFuncName , kDisableUserTimestamp ,
kDisableUserTimestamp ) ;
edit . AddFile ( /* level */ 1 , /* file_number */ 700 , /* path_id */ 0 ,
/* file_size */ 100 , /* smallest */ GetInternalKey ( " 801 " ) ,
@ -1246,7 +1270,8 @@ TEST_F(VersionBuilderTest, CheckConsistencyForBlobFiles) {
/* largest_seqno */ 200 , /* marked_for_compaction */ false ,
/* oldest_blob_file_number */ 1000 , kUnknownOldestAncesterTime ,
kUnknownFileCreationTime , kUnknownFileChecksum ,
kUnknownFileChecksumFuncName ) ;
kUnknownFileChecksumFuncName , kDisableUserTimestamp ,
kDisableUserTimestamp ) ;
edit . AddBlobFile ( /* blob_file_number */ 1000 , /* total_blob_count */ 2000 ,
/* total_blob_bytes */ 200000 ,
/* checksum_method */ std : : string ( ) ,
@ -1464,7 +1489,8 @@ TEST_F(VersionBuilderTest, MaintainLinkedSstsForBlobFiles) {
/* largest_seqno */ 2100 , /* marked_for_compaction */ false ,
/* oldest_blob_file_number */ 1 , kUnknownOldestAncesterTime ,
kUnknownFileCreationTime , kUnknownFileChecksum ,
kUnknownFileChecksumFuncName ) ;
kUnknownFileChecksumFuncName , kDisableUserTimestamp ,
kDisableUserTimestamp ) ;
// Add an SST that does not reference any blob files.
edit . AddFile (
@ -1474,7 +1500,8 @@ TEST_F(VersionBuilderTest, MaintainLinkedSstsForBlobFiles) {
/* largest_seqno */ 2200 , /* marked_for_compaction */ false ,
kInvalidBlobFileNumber , kUnknownOldestAncesterTime ,
kUnknownFileCreationTime , kUnknownFileChecksum ,
kUnknownFileChecksumFuncName ) ;
kUnknownFileChecksumFuncName , kDisableUserTimestamp ,
kDisableUserTimestamp ) ;
// Delete a file that references a blob file.
edit . DeleteFile ( /* level */ 1 , /* file_number */ 6 ) ;
@ -1496,7 +1523,8 @@ TEST_F(VersionBuilderTest, MaintainLinkedSstsForBlobFiles) {
/* largest_seqno */ 300 , /* marked_for_compaction */ false ,
/* oldest_blob_file_number */ 3 , kUnknownOldestAncesterTime ,
kUnknownFileCreationTime , kUnknownFileChecksum ,
kUnknownFileChecksumFuncName ) ;
kUnknownFileChecksumFuncName , kDisableUserTimestamp ,
kDisableUserTimestamp ) ;
// Trivially move a file that does not reference any blob files.
edit . DeleteFile ( /* level */ 1 , /* file_number */ 13 ) ;
@ -1507,7 +1535,8 @@ TEST_F(VersionBuilderTest, MaintainLinkedSstsForBlobFiles) {
/* largest_seqno */ 1300 , /* marked_for_compaction */ false ,
kInvalidBlobFileNumber , kUnknownOldestAncesterTime ,
kUnknownFileCreationTime , kUnknownFileChecksum ,
kUnknownFileChecksumFuncName ) ;
kUnknownFileChecksumFuncName , kDisableUserTimestamp ,
kDisableUserTimestamp ) ;
// 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.
@ -1519,7 +1548,8 @@ TEST_F(VersionBuilderTest, MaintainLinkedSstsForBlobFiles) {
/* largest_seqno */ 2300 , /* marked_for_compaction */ false ,
/* oldest_blob_file_number */ 5 , kUnknownOldestAncesterTime ,
kUnknownFileCreationTime , kUnknownFileChecksum ,
kUnknownFileChecksumFuncName ) ;
kUnknownFileChecksumFuncName , kDisableUserTimestamp ,
kDisableUserTimestamp ) ;
VersionEdit edit2 ;