@ -1356,9 +1356,9 @@ TEST_F(DBBasicTest, MultiGetBatchedMultiLevel) {
// Test class for batched MultiGet with prefix extractor
// Test class for batched MultiGet with prefix extractor
// Param bool - If true, use partitioned filters
// Param bool - If true, use partitioned filters
// If false, use full filter block
// If false, use full filter block
class MultiGetPrefixExtractorTest
class MultiGetPrefixExtractorTest : public DBBasicTest ,
: public DBBasicTest ,
public : : testing : : WithParamInterface < bool > {
public : : testing : : WithParamInterface < bool > { } ;
} ;
TEST_P ( MultiGetPrefixExtractorTest , Batched ) {
TEST_P ( MultiGetPrefixExtractorTest , Batched ) {
Options options = CurrentOptions ( ) ;
Options options = CurrentOptions ( ) ;
@ -1396,14 +1396,12 @@ TEST_P(MultiGetPrefixExtractorTest, Batched) {
ASSERT_EQ ( get_perf_context ( ) - > bloom_sst_hit_count , 4 ) ;
ASSERT_EQ ( get_perf_context ( ) - > bloom_sst_hit_count , 4 ) ;
}
}
INSTANTIATE_TEST_CASE_P (
INSTANTIATE_TEST_CASE_P ( MultiGetPrefix , MultiGetPrefixExtractorTest ,
MultiGetPrefix , MultiGetPrefixExtractorTest ,
: : testing : : Bool ( ) ) ;
: : testing : : Bool ( ) ) ;
# ifndef ROCKSDB_LITE
# ifndef ROCKSDB_LITE
class DBMultiGetRowCacheTest
class DBMultiGetRowCacheTest : public DBBasicTest ,
: public DBBasicTest ,
public : : testing : : WithParamInterface < bool > { } ;
public : : testing : : WithParamInterface < bool > { } ;
TEST_P ( DBMultiGetRowCacheTest , MultiGetBatched ) {
TEST_P ( DBMultiGetRowCacheTest , MultiGetBatched ) {
do {
do {
@ -1543,10 +1541,9 @@ TEST_F(DBBasicTest, GetAllKeyVersions) {
class DBBasicTestWithParallelIO
class DBBasicTestWithParallelIO
: public DBTestBase ,
: public DBTestBase ,
public testing : : WithParamInterface < std : : tuple < bool , bool , bool , bool > > {
public testing : : WithParamInterface < std : : tuple < bool , bool , bool , bool > > {
public :
public :
DBBasicTestWithParallelIO ( )
DBBasicTestWithParallelIO ( ) : DBTestBase ( " /db_basic_test_with_parallel_io " ) {
: DBTestBase ( " /db_basic_test_with_parallel_io " ) {
bool compressed_cache = std : : get < 0 > ( GetParam ( ) ) ;
bool compressed_cache = std : : get < 0 > ( GetParam ( ) ) ;
bool uncompressed_cache = std : : get < 1 > ( GetParam ( ) ) ;
bool uncompressed_cache = std : : get < 1 > ( GetParam ( ) ) ;
compression_enabled_ = std : : get < 2 > ( GetParam ( ) ) ;
compression_enabled_ = std : : get < 2 > ( GetParam ( ) ) ;
@ -1570,7 +1567,7 @@ class DBBasicTestWithParallelIO
table_options . block_cache = uncompressed_cache_ ;
table_options . block_cache = uncompressed_cache_ ;
table_options . block_cache_compressed = compressed_cache_ ;
table_options . block_cache_compressed = compressed_cache_ ;
table_options . flush_block_policy_factory . reset (
table_options . flush_block_policy_factory . reset (
new MyFlushBlockPolicyFactory ( ) ) ;
new MyFlushBlockPolicyFactory ( ) ) ;
options . table_factory . reset ( new BlockBasedTableFactory ( table_options ) ) ;
options . table_factory . reset ( new BlockBasedTableFactory ( table_options ) ) ;
if ( ! compression_enabled_ ) {
if ( ! compression_enabled_ ) {
options . compression = kNoCompression ;
options . compression = kNoCompression ;
@ -1598,15 +1595,9 @@ class DBBasicTestWithParallelIO
int num_found ( ) { return uncompressed_cache_ - > num_found ( ) ; }
int num_found ( ) { return uncompressed_cache_ - > num_found ( ) ; }
int num_inserts ( ) { return uncompressed_cache_ - > num_inserts ( ) ; }
int num_inserts ( ) { return uncompressed_cache_ - > num_inserts ( ) ; }
int num_lookups_compressed ( ) {
int num_lookups_compressed ( ) { return compressed_cache_ - > num_lookups ( ) ; }
return compressed_cache_ - > num_lookups ( ) ;
int num_found_compressed ( ) { return compressed_cache_ - > num_found ( ) ; }
}
int num_inserts_compressed ( ) { return compressed_cache_ - > num_inserts ( ) ; }
int num_found_compressed ( ) {
return compressed_cache_ - > num_found ( ) ;
}
int num_inserts_compressed ( ) {
return compressed_cache_ - > num_inserts ( ) ;
}
bool fill_cache ( ) { return fill_cache_ ; }
bool fill_cache ( ) { return fill_cache_ ; }
@ -1614,8 +1605,7 @@ class DBBasicTestWithParallelIO
static void TearDownTestCase ( ) { }
static void TearDownTestCase ( ) { }
private :
private :
class MyFlushBlockPolicyFactory
class MyFlushBlockPolicyFactory : public FlushBlockPolicyFactory {
: public FlushBlockPolicyFactory {
public :
public :
MyFlushBlockPolicyFactory ( ) { }
MyFlushBlockPolicyFactory ( ) { }
@ -1630,11 +1620,10 @@ class DBBasicTestWithParallelIO
}
}
} ;
} ;
class MyFlushBlockPolicy
class MyFlushBlockPolicy : public FlushBlockPolicy {
: public FlushBlockPolicy {
public :
public :
explicit MyFlushBlockPolicy ( const BlockBuilder & data_block_builder )
explicit MyFlushBlockPolicy ( const BlockBuilder & data_block_builder )
: num_keys_ ( 0 ) , data_block_builder_ ( data_block_builder ) { }
: num_keys_ ( 0 ) , data_block_builder_ ( data_block_builder ) { }
bool Update ( const Slice & /*key*/ , const Slice & /*value*/ ) override {
bool Update ( const Slice & /*key*/ , const Slice & /*value*/ ) override {
if ( data_block_builder_ . empty ( ) ) {
if ( data_block_builder_ . empty ( ) ) {
@ -1656,11 +1645,10 @@ class DBBasicTestWithParallelIO
const BlockBuilder & data_block_builder_ ;
const BlockBuilder & data_block_builder_ ;
} ;
} ;
class MyBlockCache
class MyBlockCache : public Cache {
: public Cache {
public :
public :
explicit MyBlockCache ( std : : shared_ptr < Cache > & target )
explicit MyBlockCache ( std : : shared_ptr < Cache > & target )
: target_ ( target ) , num_lookups_ ( 0 ) , num_found_ ( 0 ) , num_inserts_ ( 0 ) { }
: target_ ( target ) , num_lookups_ ( 0 ) , num_found_ ( 0 ) , num_inserts_ ( 0 ) { }
virtual const char * Name ( ) const override { return " MyBlockCache " ; }
virtual const char * Name ( ) const override { return " MyBlockCache " ; }
@ -1682,9 +1670,7 @@ class DBBasicTestWithParallelIO
return handle ;
return handle ;
}
}
virtual bool Ref ( Handle * handle ) override {
virtual bool Ref ( Handle * handle ) override { return target_ - > Ref ( handle ) ; }
return target_ - > Ref ( handle ) ;
}
virtual bool Release ( Handle * handle , bool force_erase = false ) override {
virtual bool Release ( Handle * handle , bool force_erase = false ) override {
return target_ - > Release ( handle , force_erase ) ;
return target_ - > Release ( handle , force_erase ) ;
@ -1694,12 +1680,8 @@ class DBBasicTestWithParallelIO
return target_ - > Value ( handle ) ;
return target_ - > Value ( handle ) ;
}
}
virtual void Erase ( const Slice & key ) override {
virtual void Erase ( const Slice & key ) override { target_ - > Erase ( key ) ; }
target_ - > Erase ( key ) ;
virtual uint64_t NewId ( ) override { return target_ - > NewId ( ) ; }
}
virtual uint64_t NewId ( ) override {
return target_ - > NewId ( ) ;
}
virtual void SetCapacity ( size_t capacity ) override {
virtual void SetCapacity ( size_t capacity ) override {
target_ - > SetCapacity ( capacity ) ;
target_ - > SetCapacity ( capacity ) ;
@ -1717,9 +1699,7 @@ class DBBasicTestWithParallelIO
return target_ - > GetCapacity ( ) ;
return target_ - > GetCapacity ( ) ;
}
}
virtual size_t GetUsage ( ) const override {
virtual size_t GetUsage ( ) const override { return target_ - > GetUsage ( ) ; }
return target_ - > GetUsage ( ) ;
}
virtual size_t GetUsage ( Handle * handle ) const override {
virtual size_t GetUsage ( Handle * handle ) const override {
return target_ - > GetUsage ( handle ) ;
return target_ - > GetUsage ( handle ) ;
@ -1745,6 +1725,7 @@ class DBBasicTestWithParallelIO
int num_found ( ) { return num_found_ ; }
int num_found ( ) { return num_found_ ; }
int num_inserts ( ) { return num_inserts_ ; }
int num_inserts ( ) { return num_inserts_ ; }
private :
private :
std : : shared_ptr < Cache > target_ ;
std : : shared_ptr < Cache > target_ ;
int num_lookups_ ;
int num_lookups_ ;
@ -1777,7 +1758,7 @@ TEST_P(DBBasicTestWithParallelIO, MultiGet) {
statuses . resize ( keys . size ( ) ) ;
statuses . resize ( keys . size ( ) ) ;
dbfull ( ) - > MultiGet ( ro , dbfull ( ) - > DefaultColumnFamily ( ) , keys . size ( ) ,
dbfull ( ) - > MultiGet ( ro , dbfull ( ) - > DefaultColumnFamily ( ) , keys . size ( ) ,
keys . data ( ) , values . data ( ) , statuses . data ( ) , true ) ;
keys . data ( ) , values . data ( ) , statuses . data ( ) , true ) ;
ASSERT_TRUE ( CheckValue ( 0 , values [ 0 ] . ToString ( ) ) ) ;
ASSERT_TRUE ( CheckValue ( 0 , values [ 0 ] . ToString ( ) ) ) ;
ASSERT_TRUE ( CheckValue ( 50 , values [ 1 ] . ToString ( ) ) ) ;
ASSERT_TRUE ( CheckValue ( 50 , values [ 1 ] . ToString ( ) ) ) ;
@ -1789,7 +1770,7 @@ TEST_P(DBBasicTestWithParallelIO, MultiGet) {
values [ 0 ] . Reset ( ) ;
values [ 0 ] . Reset ( ) ;
values [ 1 ] . Reset ( ) ;
values [ 1 ] . Reset ( ) ;
dbfull ( ) - > MultiGet ( ro , dbfull ( ) - > DefaultColumnFamily ( ) , keys . size ( ) ,
dbfull ( ) - > MultiGet ( ro , dbfull ( ) - > DefaultColumnFamily ( ) , keys . size ( ) ,
keys . data ( ) , values . data ( ) , statuses . data ( ) , true ) ;
keys . data ( ) , values . data ( ) , statuses . data ( ) , true ) ;
ASSERT_TRUE ( CheckValue ( 1 , values [ 0 ] . ToString ( ) ) ) ;
ASSERT_TRUE ( CheckValue ( 1 , values [ 0 ] . ToString ( ) ) ) ;
ASSERT_TRUE ( CheckValue ( 51 , values [ 1 ] . ToString ( ) ) ) ;
ASSERT_TRUE ( CheckValue ( 51 , values [ 1 ] . ToString ( ) ) ) ;
@ -1798,7 +1779,7 @@ TEST_P(DBBasicTestWithParallelIO, MultiGet) {
keys . resize ( 10 ) ;
keys . resize ( 10 ) ;
statuses . resize ( 10 ) ;
statuses . resize ( 10 ) ;
std : : vector < int > key_ints { 1 , 2 , 15 , 16 , 55 , 81 , 82 , 83 , 84 , 85 } ;
std : : vector < int > key_ints { 1 , 2 , 15 , 16 , 55 , 81 , 82 , 83 , 84 , 85 } ;
for ( size_t i = 0 ; i < key_ints . size ( ) ; + + i ) {
for ( size_t i = 0 ; i < key_ints . size ( ) ; + + i ) {
key_data [ i ] = Key ( key_ints [ i ] ) ;
key_data [ i ] = Key ( key_ints [ i ] ) ;
keys [ i ] = Slice ( key_data [ i ] ) ;
keys [ i ] = Slice ( key_data [ i ] ) ;
@ -1806,7 +1787,7 @@ TEST_P(DBBasicTestWithParallelIO, MultiGet) {
values [ i ] . Reset ( ) ;
values [ i ] . Reset ( ) ;
}
}
dbfull ( ) - > MultiGet ( ro , dbfull ( ) - > DefaultColumnFamily ( ) , keys . size ( ) ,
dbfull ( ) - > MultiGet ( ro , dbfull ( ) - > DefaultColumnFamily ( ) , keys . size ( ) ,
keys . data ( ) , values . data ( ) , statuses . data ( ) , true ) ;
keys . data ( ) , values . data ( ) , statuses . data ( ) , true ) ;
for ( size_t i = 0 ; i < key_ints . size ( ) ; + + i ) {
for ( size_t i = 0 ; i < key_ints . size ( ) ; + + i ) {
ASSERT_OK ( statuses [ i ] ) ;
ASSERT_OK ( statuses [ i ] ) ;
ASSERT_TRUE ( CheckValue ( key_ints [ i ] , values [ i ] . ToString ( ) ) ) ;
ASSERT_TRUE ( CheckValue ( key_ints [ i ] , values [ i ] . ToString ( ) ) ) ;