@ -59,14 +59,11 @@ class VersionBuilderTest : public testing::Test {
bool sampled = false , SequenceNumber smallest_seqno = 0 ,
SequenceNumber largest_seqno = 0 ) {
assert ( level < vstorage_ . num_levels ( ) ) ;
FileMetaData * f = new FileMetaData ;
f - > fd = FileDescriptor ( file_number , path_id , file_size ) ;
f - > smallest = GetInternalKey ( smallest , smallest_seq ) ;
f - > largest = GetInternalKey ( largest , largest_seq ) ;
f - > fd . smallest_seqno = smallest_seqno ;
f - > fd . largest_seqno = largest_seqno ;
FileMetaData * f = new FileMetaData (
file_number , path_id , file_size , GetInternalKey ( smallest , smallest_seq ) ,
GetInternalKey ( largest , largest_seq ) , smallest_seqno , largest_seqno ,
/* marked_for_compact */ false , kInvalidBlobFileNumber ) ;
f - > compensated_file_size = file_size ;
f - > refs = 0 ;
f - > num_entries = num_entries ;
f - > num_deletions = num_deletions ;
vstorage_ . AddFile ( level , f ) ;
@ -115,7 +112,8 @@ TEST_F(VersionBuilderTest, ApplyAndSaveTo) {
VersionEdit version_edit ;
version_edit . AddFile ( 2 , 666 , 0 , 100U , GetInternalKey ( " 301 " ) ,
GetInternalKey ( " 350 " ) , 200 , 200 , false ) ;
GetInternalKey ( " 350 " ) , 200 , 200 , false ,
kInvalidBlobFileNumber ) ;
version_edit . DeleteFile ( 3 , 27U ) ;
EnvOptions env_options ;
@ -149,7 +147,8 @@ TEST_F(VersionBuilderTest, ApplyAndSaveToDynamic) {
VersionEdit version_edit ;
version_edit . AddFile ( 3 , 666 , 0 , 100U , GetInternalKey ( " 301 " ) ,
GetInternalKey ( " 350 " ) , 200 , 200 , false ) ;
GetInternalKey ( " 350 " ) , 200 , 200 , false ,
kInvalidBlobFileNumber ) ;
version_edit . DeleteFile ( 0 , 1U ) ;
version_edit . DeleteFile ( 0 , 88U ) ;
@ -186,7 +185,8 @@ TEST_F(VersionBuilderTest, ApplyAndSaveToDynamic2) {
VersionEdit version_edit ;
version_edit . AddFile ( 4 , 666 , 0 , 100U , GetInternalKey ( " 301 " ) ,
GetInternalKey ( " 350 " ) , 200 , 200 , false ) ;
GetInternalKey ( " 350 " ) , 200 , 200 , false ,
kInvalidBlobFileNumber ) ;
version_edit . DeleteFile ( 0 , 1U ) ;
version_edit . DeleteFile ( 0 , 88U ) ;
version_edit . DeleteFile ( 4 , 6U ) ;
@ -214,15 +214,20 @@ TEST_F(VersionBuilderTest, ApplyMultipleAndSaveTo) {
VersionEdit version_edit ;
version_edit . AddFile ( 2 , 666 , 0 , 100U , GetInternalKey ( " 301 " ) ,
GetInternalKey ( " 350 " ) , 200 , 200 , false ) ;
GetInternalKey ( " 350 " ) , 200 , 200 , false ,
kInvalidBlobFileNumber ) ;
version_edit . AddFile ( 2 , 676 , 0 , 100U , GetInternalKey ( " 401 " ) ,
GetInternalKey ( " 450 " ) , 200 , 200 , false ) ;
GetInternalKey ( " 450 " ) , 200 , 200 , false ,
kInvalidBlobFileNumber ) ;
version_edit . AddFile ( 2 , 636 , 0 , 100U , GetInternalKey ( " 601 " ) ,
GetInternalKey ( " 650 " ) , 200 , 200 , false ) ;
GetInternalKey ( " 650 " ) , 200 , 200 , false ,
kInvalidBlobFileNumber ) ;
version_edit . AddFile ( 2 , 616 , 0 , 100U , GetInternalKey ( " 501 " ) ,
GetInternalKey ( " 550 " ) , 200 , 200 , false ) ;
GetInternalKey ( " 550 " ) , 200 , 200 , false ,
kInvalidBlobFileNumber ) ;
version_edit . AddFile ( 2 , 606 , 0 , 100U , GetInternalKey ( " 701 " ) ,
GetInternalKey ( " 750 " ) , 200 , 200 , false ) ;
GetInternalKey ( " 750 " ) , 200 , 200 , false ,
kInvalidBlobFileNumber ) ;
EnvOptions env_options ;
@ -248,24 +253,31 @@ TEST_F(VersionBuilderTest, ApplyDeleteAndSaveTo) {
VersionEdit version_edit ;
version_edit . AddFile ( 2 , 666 , 0 , 100U , GetInternalKey ( " 301 " ) ,
GetInternalKey ( " 350 " ) , 200 , 200 , false ) ;
GetInternalKey ( " 350 " ) , 200 , 200 , false ,
kInvalidBlobFileNumber ) ;
version_edit . AddFile ( 2 , 676 , 0 , 100U , GetInternalKey ( " 401 " ) ,
GetInternalKey ( " 450 " ) , 200 , 200 , false ) ;
GetInternalKey ( " 450 " ) , 200 , 200 , false ,
kInvalidBlobFileNumber ) ;
version_edit . AddFile ( 2 , 636 , 0 , 100U , GetInternalKey ( " 601 " ) ,
GetInternalKey ( " 650 " ) , 200 , 200 , false ) ;
GetInternalKey ( " 650 " ) , 200 , 200 , false ,
kInvalidBlobFileNumber ) ;
version_edit . AddFile ( 2 , 616 , 0 , 100U , GetInternalKey ( " 501 " ) ,
GetInternalKey ( " 550 " ) , 200 , 200 , false ) ;
GetInternalKey ( " 550 " ) , 200 , 200 , false ,
kInvalidBlobFileNumber ) ;
version_edit . AddFile ( 2 , 606 , 0 , 100U , GetInternalKey ( " 701 " ) ,
GetInternalKey ( " 750 " ) , 200 , 200 , false ) ;
GetInternalKey ( " 750 " ) , 200 , 200 , false ,
kInvalidBlobFileNumber ) ;
version_builder . Apply ( & version_edit ) ;
VersionEdit version_edit2 ;
version_edit . AddFile ( 2 , 808 , 0 , 100U , GetInternalKey ( " 901 " ) ,
GetInternalKey ( " 950 " ) , 200 , 200 , false ) ;
GetInternalKey ( " 950 " ) , 200 , 200 , false ,
kInvalidBlobFileNumber ) ;
version_edit2 . DeleteFile ( 2 , 616 ) ;
version_edit2 . DeleteFile ( 2 , 636 ) ;
version_edit . AddFile ( 2 , 806 , 0 , 100U , GetInternalKey ( " 801 " ) ,
GetInternalKey ( " 850 " ) , 200 , 200 , false ) ;
GetInternalKey ( " 850 " ) , 200 , 200 , false ,
kInvalidBlobFileNumber ) ;
version_builder . Apply ( & version_edit2 ) ;
version_builder . SaveTo ( & new_vstorage ) ;