@ -1108,111 +1108,6 @@ TEST_F(DBBasicTestWithTimestamp, SimpleForwardIterateLowerTsBound) {
Close ( ) ;
}
class DBBasicDeletionTestWithTimestamp
: public DBBasicTestWithTimestampBase ,
public testing : : WithParamInterface < enum ValueType > {
public :
DBBasicDeletionTestWithTimestamp ( )
: DBBasicTestWithTimestampBase ( " db_basic_deletion_test_with_timestamp " ) { }
} ;
INSTANTIATE_TEST_CASE_P (
Timestamp , DBBasicDeletionTestWithTimestamp ,
: : testing : : Values ( ValueType : : kTypeSingleDeletion ,
ValueType : : kTypeDeletionWithTimestamp ) ) ;
TEST_P ( DBBasicDeletionTestWithTimestamp , ForwardIterateStartSeqnum ) {
const int kNumKeysPerFile = 128 ;
const uint64_t kMaxKey = 0xffffffffffffffff ;
const uint64_t kMinKey = kMaxKey - 1023 ;
Options options = CurrentOptions ( ) ;
options . env = env_ ;
options . create_if_missing = true ;
ValueType op_type = GetParam ( ) ;
// Need to disable compaction to bottommost level when sequence number will be
// zeroed out, causing the verification of sequence number to fail in this
// test.
options . disable_auto_compactions = true ;
const size_t kTimestampSize = Timestamp ( 0 , 0 ) . size ( ) ;
TestComparator test_cmp ( kTimestampSize ) ;
options . comparator = & test_cmp ;
options . memtable_factory . reset (
test : : NewSpecialSkipListFactory ( kNumKeysPerFile ) ) ;
DestroyAndReopen ( options ) ;
std : : vector < SequenceNumber > start_seqs ;
const int kNumTimestamps = 4 ;
std : : vector < std : : string > write_ts_list ;
for ( int t = 0 ; t ! = kNumTimestamps ; + + t ) {
write_ts_list . push_back ( Timestamp ( 2 * t , /*do not care*/ 17 ) ) ;
}
WriteOptions write_opts ;
for ( size_t i = 0 ; i ! = write_ts_list . size ( ) ; + + i ) {
Slice write_ts = write_ts_list [ i ] ;
write_opts . timestamp = & write_ts ;
for ( uint64_t k = kMaxKey ; k > = kMinKey ; - - k ) {
Status s ;
if ( k % 2 ) {
s = db_ - > Put ( write_opts , Key1 ( k ) , " value " + std : : to_string ( i ) ) ;
} else {
if ( op_type = = ValueType : : kTypeDeletionWithTimestamp ) {
s = db_ - > Delete ( write_opts , Key1 ( k ) ) ;
} else if ( op_type = = ValueType : : kTypeSingleDeletion ) {
s = db_ - > SingleDelete ( write_opts , Key1 ( k ) ) ;
}
}
ASSERT_OK ( s ) ;
}
start_seqs . push_back ( db_ - > GetLatestSequenceNumber ( ) ) ;
}
std : : vector < std : : string > read_ts_list ;
for ( int t = 0 ; t ! = kNumTimestamps - 1 ; + + t ) {
read_ts_list . push_back ( Timestamp ( 2 * t + 3 , /*do not care*/ 17 ) ) ;
}
ReadOptions read_opts ;
// Scan with only read_opts.iter_start_seqnum set.
for ( size_t i = 0 ; i ! = read_ts_list . size ( ) ; + + i ) {
Slice read_ts = read_ts_list [ i ] ;
read_opts . timestamp = & read_ts ;
read_opts . iter_start_seqnum = start_seqs [ i ] + 1 ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_opts ) ) ;
SequenceNumber expected_seq = start_seqs [ i ] + ( kMaxKey - kMinKey ) + 1 ;
uint64_t key = kMinKey ;
for ( iter - > Seek ( Key1 ( kMinKey ) ) ; iter - > Valid ( ) ; iter - > Next ( ) ) {
CheckIterEntry (
iter . get ( ) , Key1 ( key ) , expected_seq , ( key % 2 ) ? kTypeValue : op_type ,
( key % 2 ) ? " value " + std : : to_string ( i + 1 ) : std : : string ( ) ,
write_ts_list [ i + 1 ] ) ;
+ + key ;
- - expected_seq ;
}
}
// Scan with both read_opts.iter_start_seqnum and read_opts.iter_start_ts set.
std : : vector < std : : string > read_ts_lb_list ;
for ( int t = 0 ; t < kNumTimestamps - 1 ; + + t ) {
read_ts_lb_list . push_back ( Timestamp ( 2 * t , /*do not care*/ 17 ) ) ;
}
for ( size_t i = 0 ; i < read_ts_list . size ( ) ; + + i ) {
Slice read_ts = read_ts_list [ i ] ;
Slice read_ts_lb = read_ts_lb_list [ i ] ;
read_opts . timestamp = & read_ts ;
read_opts . iter_start_ts = & read_ts_lb ;
read_opts . iter_start_seqnum = start_seqs [ i ] + 1 ;
std : : unique_ptr < Iterator > it ( db_ - > NewIterator ( read_opts ) ) ;
uint64_t key = kMinKey ;
SequenceNumber expected_seq = start_seqs [ i ] + ( kMaxKey - kMinKey ) + 1 ;
for ( it - > Seek ( Key1 ( kMinKey ) ) ; it - > Valid ( ) ; it - > Next ( ) ) {
CheckIterEntry ( it . get ( ) , Key1 ( key ) , expected_seq ,
( key % 2 ) ? kTypeValue : op_type ,
" value " + std : : to_string ( i + 1 ) , write_ts_list [ i + 1 ] ) ;
+ + key ;
- - expected_seq ;
}
}
Close ( ) ;
}
TEST_F ( DBBasicTestWithTimestamp , ReseekToTargetTimestamp ) {
Options options = CurrentOptions ( ) ;
options . env = env_ ;