@ -8,6 +8,7 @@
# include <string>
# include <vector>
# include "db/merge_context.h"
# include "db/range_del_aggregator.h"
# include "db/version_set.h"
# include "db/write_controller.h"
# include "rocksdb/db.h"
@ -116,10 +117,13 @@ TEST_F(MemTableListTest, GetTest) {
std : : string value ;
Status s ;
MergeContext merge_context ;
InternalKeyComparator ikey_cmp ( options . comparator ) ;
RangeDelAggregator range_del_agg ( ikey_cmp , { } /* snapshots */ ) ;
autovector < MemTable * > to_delete ;
LookupKey lkey ( " key1 " , seq ) ;
bool found = list . current ( ) - > Get ( lkey , & value , & s , & merge_context ) ;
bool found = list . current ( ) - > Get ( lkey , & value , & s , & merge_context ,
& range_del_agg , ReadOptions ( ) ) ;
ASSERT_FALSE ( found ) ;
// Create a MemTable
@ -141,17 +145,20 @@ TEST_F(MemTableListTest, GetTest) {
// Fetch the newly written keys
merge_context . Clear ( ) ;
found = mem - > Get ( LookupKey ( " key1 " , seq ) , & value , & s , & merge_context ) ;
found = mem - > Get ( LookupKey ( " key1 " , seq ) , & value , & s , & merge_context ,
& range_del_agg , ReadOptions ( ) ) ;
ASSERT_TRUE ( s . ok ( ) & & found ) ;
ASSERT_EQ ( value , " value1 " ) ;
merge_context . Clear ( ) ;
found = mem - > Get ( LookupKey ( " key1 " , 2 ) , & value , & s , & merge_context ) ;
found = mem - > Get ( LookupKey ( " key1 " , 2 ) , & value , & s , & merge_context ,
& range_del_agg , ReadOptions ( ) ) ;
// MemTable found out that this key is *not* found (at this sequence#)
ASSERT_TRUE ( found & & s . IsNotFound ( ) ) ;
merge_context . Clear ( ) ;
found = mem - > Get ( LookupKey ( " key2 " , seq ) , & value , & s , & merge_context ) ;
found = mem - > Get ( LookupKey ( " key2 " , seq ) , & value , & s , & merge_context ,
& range_del_agg , ReadOptions ( ) ) ;
ASSERT_TRUE ( s . ok ( ) & & found ) ;
ASSERT_EQ ( value , " value2.2 " ) ;
@ -177,24 +184,25 @@ TEST_F(MemTableListTest, GetTest) {
// Fetch keys via MemTableList
merge_context . Clear ( ) ;
found =
list . current ( ) - > Get ( LookupKey ( " key1 " , seq ) , & value , & s , & merge_context ) ;
found = list . current ( ) - > Get ( LookupKey ( " key1 " , seq ) , & value , & s ,
& merge_context , & range_del_agg , ReadOptions ( ) ) ;
ASSERT_TRUE ( found & & s . IsNotFound ( ) ) ;
merge_context . Clear ( ) ;
found = list . current ( ) - > Get ( LookupKey ( " key1 " , saved_seq ) , & value , & s ,
& merge_context ) ;
& merge_context , & range_del_agg , ReadOptions ( ) ) ;
ASSERT_TRUE ( s . ok ( ) & & found ) ;
ASSERT_EQ ( " value1 " , value ) ;
merge_context . Clear ( ) ;
found =
list . current ( ) - > Get ( LookupKey ( " key2 " , seq ) , & value , & s , & merge_context ) ;
found = list . current ( ) - > Get ( LookupKey ( " key2 " , seq ) , & value , & s ,
& merge_context , & range_del_agg , ReadOptions ( ) ) ;
ASSERT_TRUE ( s . ok ( ) & & found ) ;
ASSERT_EQ ( value , " value2.3 " ) ;
merge_context . Clear ( ) ;
found = list . current ( ) - > Get ( LookupKey ( " key2 " , 1 ) , & value , & s , & merge_context ) ;
found = list . current ( ) - > Get ( LookupKey ( " key2 " , 1 ) , & value , & s , & merge_context ,
& range_del_agg , ReadOptions ( ) ) ;
ASSERT_FALSE ( found ) ;
ASSERT_EQ ( 2 , list . NumNotFlushed ( ) ) ;
@ -216,10 +224,13 @@ TEST_F(MemTableListTest, GetFromHistoryTest) {
std : : string value ;
Status s ;
MergeContext merge_context ;
InternalKeyComparator ikey_cmp ( options . comparator ) ;
RangeDelAggregator range_del_agg ( ikey_cmp , { } /* snapshots */ ) ;
autovector < MemTable * > to_delete ;
LookupKey lkey ( " key1 " , seq ) ;
bool found = list . current ( ) - > Get ( lkey , & value , & s , & merge_context ) ;
bool found = list . current ( ) - > Get ( lkey , & value , & s , & merge_context ,
& range_del_agg , ReadOptions ( ) ) ;
ASSERT_FALSE ( found ) ;
// Create a MemTable
@ -240,12 +251,14 @@ TEST_F(MemTableListTest, GetFromHistoryTest) {
// Fetch the newly written keys
merge_context . Clear ( ) ;
found = mem - > Get ( LookupKey ( " key1 " , seq ) , & value , & s , & merge_context ) ;
found = mem - > Get ( LookupKey ( " key1 " , seq ) , & value , & s , & merge_context ,
& range_del_agg , ReadOptions ( ) ) ;
// MemTable found out that this key is *not* found (at this sequence#)
ASSERT_TRUE ( found & & s . IsNotFound ( ) ) ;
merge_context . Clear ( ) ;
found = mem - > Get ( LookupKey ( " key2 " , seq ) , & value , & s , & merge_context ) ;
found = mem - > Get ( LookupKey ( " key2 " , seq ) , & value , & s , & merge_context ,
& range_del_agg , ReadOptions ( ) ) ;
ASSERT_TRUE ( s . ok ( ) & & found ) ;
ASSERT_EQ ( value , " value2.2 " ) ;
@ -255,13 +268,13 @@ TEST_F(MemTableListTest, GetFromHistoryTest) {
// Fetch keys via MemTableList
merge_context . Clear ( ) ;
found =
list . current ( ) - > Get ( LookupKey ( " key1 " , seq ) , & value , & s , & merge_context ) ;
found = list . current ( ) - > Get ( LookupKey ( " key1 " , seq ) , & value , & s ,
& merge_context , & range_del_agg , ReadOptions ( ) ) ;
ASSERT_TRUE ( found & & s . IsNotFound ( ) ) ;
merge_context . Clear ( ) ;
found =
list . current ( ) - > Get ( LookupKey ( " key2 " , seq ) , & value , & s , & merge_context ) ;
found = list . current ( ) - > Get ( LookupKey ( " key2 " , seq ) , & value , & s ,
& merge_context , & range_del_agg , ReadOptions ( ) ) ;
ASSERT_TRUE ( s . ok ( ) & & found ) ;
ASSERT_EQ ( " value2.2 " , value ) ;
@ -280,24 +293,26 @@ TEST_F(MemTableListTest, GetFromHistoryTest) {
// Verify keys are no longer in MemTableList
merge_context . Clear ( ) ;
found =
list . current ( ) - > Get ( LookupKey ( " key1 " , seq ) , & value , & s , & merge_context ) ;
found = list . current ( ) - > Get ( LookupKey ( " key1 " , seq ) , & value , & s ,
& merge_context , & range_del_agg , ReadOptions ( ) ) ;
ASSERT_FALSE ( found ) ;
merge_context . Clear ( ) ;
found =
list . current ( ) - > Get ( LookupKey ( " key2 " , seq ) , & value , & s , & merge_context ) ;
found = list . current ( ) - > Get ( LookupKey ( " key2 " , seq ) , & value , & s ,
& merge_context , & range_del_agg , ReadOptions ( ) ) ;
ASSERT_FALSE ( found ) ;
// Verify keys are present in history
merge_context . Clear ( ) ;
found = list . current ( ) - > GetFromHistory ( LookupKey ( " key1 " , seq ) , & value , & s ,
& merge_context ) ;
& merge_context , & range_del_agg ,
ReadOptions ( ) ) ;
ASSERT_TRUE ( found & & s . IsNotFound ( ) ) ;
merge_context . Clear ( ) ;
found = list . current ( ) - > GetFromHistory ( LookupKey ( " key2 " , seq ) , & value , & s ,
& merge_context ) ;
& merge_context , & range_del_agg ,
ReadOptions ( ) ) ;
ASSERT_TRUE ( found ) ;
ASSERT_EQ ( " value2.2 " , value ) ;
@ -338,36 +353,38 @@ TEST_F(MemTableListTest, GetFromHistoryTest) {
// Verify keys are no longer in MemTableList
merge_context . Clear ( ) ;
found =
list . current ( ) - > Get ( LookupKey ( " key1 " , seq ) , & value , & s , & merge_context ) ;
found = list . current ( ) - > Get ( LookupKey ( " key1 " , seq ) , & value , & s ,
& merge_context , & range_del_agg , ReadOptions ( ) ) ;
ASSERT_FALSE ( found ) ;
merge_context . Clear ( ) ;
found =
list . current ( ) - > Get ( LookupKey ( " key2 " , seq ) , & value , & s , & merge_context ) ;
found = list . current ( ) - > Get ( LookupKey ( " key2 " , seq ) , & value , & s ,
& merge_context , & range_del_agg , ReadOptions ( ) ) ;
ASSERT_FALSE ( found ) ;
merge_context . Clear ( ) ;
found =
list . current ( ) - > Get ( LookupKey ( " key3 " , seq ) , & value , & s , & merge_context ) ;
found = list . current ( ) - > Get ( LookupKey ( " key3 " , seq ) , & value , & s ,
& merge_context , & range_del_agg , ReadOptions ( ) ) ;
ASSERT_FALSE ( found ) ;
// Verify that the second memtable's keys are in the history
merge_context . Clear ( ) ;
found = list . current ( ) - > GetFromHistory ( LookupKey ( " key1 " , seq ) , & value , & s ,
& merge_context ) ;
& merge_context , & range_del_agg ,
ReadOptions ( ) ) ;
ASSERT_TRUE ( found & & s . IsNotFound ( ) ) ;
merge_context . Clear ( ) ;
found = list . current ( ) - > GetFromHistory ( LookupKey ( " key3 " , seq ) , & value , & s ,
& merge_context ) ;
& merge_context , & range_del_agg ,
ReadOptions ( ) ) ;
ASSERT_TRUE ( found ) ;
ASSERT_EQ ( " value3 " , value ) ;
// Verify that key2 from the first memtable is no longer in the history
merge_context . Clear ( ) ;
found =
list . current ( ) - > Get ( LookupKey ( " key2 " , seq ) , & value , & s , & merge_context ) ;
found = list . current ( ) - > Get ( LookupKey ( " key2 " , seq ) , & value , & s ,
& merge_context , & range_del_agg , ReadOptions ( ) ) ;
ASSERT_FALSE ( found ) ;
// Cleanup