@ -43,6 +43,16 @@ const std::string kStandard128Ribbon =
test : : Standard128RibbonFilterPolicy : : kClassName ( ) ;
test : : Standard128RibbonFilterPolicy : : kClassName ( ) ;
const std : : string kAutoBloom = BloomFilterPolicy : : kClassName ( ) ;
const std : : string kAutoBloom = BloomFilterPolicy : : kClassName ( ) ;
const std : : string kAutoRibbon = RibbonFilterPolicy : : kClassName ( ) ;
const std : : string kAutoRibbon = RibbonFilterPolicy : : kClassName ( ) ;
template < typename T >
T Pop ( T & var ) {
auto rv = var ;
var = 0 ;
return rv ;
}
PerfContextByLevel & GetLevelPerfContext ( uint32_t level ) {
return ( * ( get_perf_context ( ) - > level_to_perf_context ) ) [ level ] ;
}
} // anonymous namespace
} // anonymous namespace
// DB tests related to bloom filter.
// DB tests related to bloom filter.
@ -209,57 +219,43 @@ TEST_F(DBBloomFilterTest, GetFilterByPrefixBloomCustomPrefixExtractor) {
ASSERT_OK ( dbfull ( ) - > Flush ( fo ) ) ;
ASSERT_OK ( dbfull ( ) - > Flush ( fo ) ) ;
ASSERT_EQ ( " foo " , Get ( " barbarbar " ) ) ;
ASSERT_EQ ( " foo " , Get ( " barbarbar " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
ASSERT_EQ (
EXPECT_EQ ( Pop ( GetLevelPerfContext ( 0 ) . bloom_filter_useful ) , 0 ) ;
0 ,
( * ( get_perf_context ( ) - > level_to_perf_context ) ) [ 0 ] . bloom_filter_useful ) ;
ASSERT_EQ ( " foo2 " , Get ( " barbarbar2 " ) ) ;
ASSERT_EQ ( " foo2 " , Get ( " barbarbar2 " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
ASSERT_EQ (
EXPECT_EQ ( Pop ( GetLevelPerfContext ( 0 ) . bloom_filter_useful ) , 0 ) ;
0 ,
( * ( get_perf_context ( ) - > level_to_perf_context ) ) [ 0 ] . bloom_filter_useful ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " barbarbar3 " ) ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " barbarbar3 " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
ASSERT_EQ (
EXPECT_EQ ( Pop ( GetLevelPerfContext ( 0 ) . bloom_filter_useful ) , 0 ) ;
0 ,
( * ( get_perf_context ( ) - > level_to_perf_context ) ) [ 0 ] . bloom_filter_useful ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " barfoofoo " ) ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " barfoofoo " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 1 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 1 ) ;
ASSERT_EQ (
EXPECT_EQ ( Pop ( GetLevelPerfContext ( 0 ) . bloom_filter_useful ) , 1 ) ;
1 ,
( * ( get_perf_context ( ) - > level_to_perf_context ) ) [ 0 ] . bloom_filter_useful ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " foobarbar " ) ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " foobarbar " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 2 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 1 ) ;
ASSERT_EQ (
EXPECT_EQ ( Pop ( GetLevelPerfContext ( 0 ) . bloom_filter_useful ) , 1 ) ;
2 ,
( * ( get_perf_context ( ) - > level_to_perf_context ) ) [ 0 ] . bloom_filter_useful ) ;
ro . total_order_seek = true ;
ro . total_order_seek = true ;
// NOTE: total_order_seek no longer affects Get()
// NOTE: total_order_seek no longer affects Get()
ASSERT_EQ ( " NOT_FOUND " , Get ( " foobarbar " ) ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " foobarbar " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 3 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 1 ) ;
ASSERT_EQ (
EXPECT_EQ ( Pop ( GetLevelPerfContext ( 0 ) . bloom_filter_useful ) , 1 ) ;
3 ,
( * ( get_perf_context ( ) - > level_to_perf_context ) ) [ 0 ] . bloom_filter_useful ) ;
// No bloom on extractor changed
// No bloom on extractor changed
ASSERT_OK ( db_ - > SetOptions ( { { " prefix_extractor " , " capped:10 " } } ) ) ;
ASSERT_OK ( db_ - > SetOptions ( { { " prefix_extractor " , " capped:10 " } } ) ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " foobarbar " ) ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " foobarbar " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 3 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
ASSERT_EQ (
EXPECT_EQ ( Pop ( GetLevelPerfContext ( 0 ) . bloom_filter_useful ) , 0 ) ;
3 ,
( * ( get_perf_context ( ) - > level_to_perf_context ) ) [ 0 ] . bloom_filter_useful ) ;
// No bloom on extractor changed, after re-open
// No bloom on extractor changed, after re-open
options . prefix_extractor . reset ( NewCappedPrefixTransform ( 10 ) ) ;
options . prefix_extractor . reset ( NewCappedPrefixTransform ( 10 ) ) ;
Reopen ( options ) ;
Reopen ( options ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " foobarbar " ) ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " foobarbar " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 3 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
ASSERT_EQ (
EXPECT_EQ ( Pop ( GetLevelPerfContext ( 0 ) . bloom_filter_useful ) , 0 ) ;
3 ,
( * ( get_perf_context ( ) - > level_to_perf_context ) ) [ 0 ] . bloom_filter_useful ) ;
get_perf_context ( ) - > Reset ( ) ;
get_perf_context ( ) - > Reset ( ) ;
}
}
@ -294,33 +290,32 @@ TEST_F(DBBloomFilterTest, GetFilterByPrefixBloom) {
ASSERT_OK ( dbfull ( ) - > Flush ( fo ) ) ;
ASSERT_OK ( dbfull ( ) - > Flush ( fo ) ) ;
ASSERT_EQ ( " foo " , Get ( " barbarbar " ) ) ;
ASSERT_EQ ( " foo " , Get ( " barbarbar " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX _USEFUL ) , 0 ) ;
ASSERT_EQ ( " foo2 " , Get ( " barbarbar2 " ) ) ;
ASSERT_EQ ( " foo2 " , Get ( " barbarbar2 " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX _USEFUL ) , 0 ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " barbarbar3 " ) ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " barbarbar3 " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( Pop ( GetLevelPerfContext ( 0 ) . bloom_filter_useful ) , 0 ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " barfoofoo " ) ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " barfoofoo " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 1 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 1 ) ;
EXPECT_EQ ( Pop ( GetLevelPerfContext ( 0 ) . bloom_filter_useful ) , 1 ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " foobarbar " ) ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " foobarbar " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 2 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 1 ) ;
EXPECT_EQ ( Pop ( GetLevelPerfContext ( 0 ) . bloom_filter_useful ) , 1 ) ;
ro . total_order_seek = true ;
ro . total_order_seek = true ;
// NOTE: total_order_seek no longer affects Get()
// NOTE: total_order_seek no longer affects Get()
ASSERT_EQ ( " NOT_FOUND " , Get ( " foobarbar " ) ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " foobarbar " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 3 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 1 ) ;
ASSERT_EQ (
EXPECT_EQ ( Pop ( GetLevelPerfContext ( 0 ) . bloom_filter_useful ) , 1 ) ;
3 ,
( * ( get_perf_context ( ) - > level_to_perf_context ) ) [ 0 ] . bloom_filter_useful ) ;
// No bloom on extractor changed
// No bloom on extractor changed
ASSERT_OK ( db_ - > SetOptions ( { { " prefix_extractor " , " capped:10 " } } ) ) ;
ASSERT_OK ( db_ - > SetOptions ( { { " prefix_extractor " , " capped:10 " } } ) ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " foobarbar " ) ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " foobarbar " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 3 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
ASSERT_EQ (
EXPECT_EQ ( Pop ( GetLevelPerfContext ( 0 ) . bloom_filter_useful ) , 0 ) ;
3 ,
( * ( get_perf_context ( ) - > level_to_perf_context ) ) [ 0 ] . bloom_filter_useful ) ;
get_perf_context ( ) - > Reset ( ) ;
get_perf_context ( ) - > Reset ( ) ;
}
}
@ -357,12 +352,17 @@ TEST_F(DBBloomFilterTest, WholeKeyFilterProp) {
ASSERT_OK ( dbfull ( ) - > Flush ( fo ) ) ;
ASSERT_OK ( dbfull ( ) - > Flush ( fo ) ) ;
Reopen ( options ) ;
Reopen ( options ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_USEFUL ) , 0 ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " foo " ) ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " foo " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_USEFUL ) , 0 ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " bar " ) ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " bar " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 1 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 1 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_USEFUL ) , 0 ) ;
ASSERT_EQ ( " foo " , Get ( " foobar " ) ) ;
ASSERT_EQ ( " foo " , Get ( " foobar " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 1 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_USEFUL ) , 0 ) ;
// Reopen with whole key filtering enabled and prefix extractor
// Reopen with whole key filtering enabled and prefix extractor
// NULL. Bloom filter should be off for both of whole key and
// NULL. Bloom filter should be off for both of whole key and
@ -372,13 +372,17 @@ TEST_F(DBBloomFilterTest, WholeKeyFilterProp) {
options . prefix_extractor . reset ( ) ;
options . prefix_extractor . reset ( ) ;
Reopen ( options ) ;
Reopen ( options ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 1 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_USEFUL ) , 0 ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " foo " ) ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " foo " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 1 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_USEFUL ) , 0 ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " bar " ) ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " bar " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 1 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_USEFUL ) , 0 ) ;
ASSERT_EQ ( " foo " , Get ( " foobar " ) ) ;
ASSERT_EQ ( " foo " , Get ( " foobar " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 1 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_USEFUL ) , 0 ) ;
// Write DB with only full key filtering.
// Write DB with only full key filtering.
ASSERT_OK ( dbfull ( ) - > Put ( wo , " foobar " , " foo " ) ) ;
ASSERT_OK ( dbfull ( ) - > Put ( wo , " foobar " , " foo " ) ) ;
// Needs insert some keys to make sure files are not filtered out by key
// Needs insert some keys to make sure files are not filtered out by key
@ -394,13 +398,17 @@ TEST_F(DBBloomFilterTest, WholeKeyFilterProp) {
options . table_factory . reset ( NewBlockBasedTableFactory ( bbto ) ) ;
options . table_factory . reset ( NewBlockBasedTableFactory ( bbto ) ) ;
Reopen ( options ) ;
Reopen ( options ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 1 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_USEFUL ) , 0 ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " foo " ) ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " foo " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 1 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_USEFUL ) , 0 ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " bar " ) ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " bar " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 1 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_USEFUL ) , 0 ) ;
ASSERT_EQ ( " foo " , Get ( " foobar " ) ) ;
ASSERT_EQ ( " foo " , Get ( " foobar " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 1 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_USEFUL ) , 0 ) ;
// Try to create a DB with mixed files:
// Try to create a DB with mixed files:
ASSERT_OK ( dbfull ( ) - > Put ( wo , " foobar " , " foo " ) ) ;
ASSERT_OK ( dbfull ( ) - > Put ( wo , " foobar " , " foo " ) ) ;
@ -424,61 +432,81 @@ TEST_F(DBBloomFilterTest, WholeKeyFilterProp) {
ASSERT_OK ( Flush ( ) ) ;
ASSERT_OK ( Flush ( ) ) ;
// Now we have two files:
// Now we have two files:
// File 1: An older file with prefix bloom.
// File 1: An older file with prefix bloom (disabled)
// File 2: A newer file with whole bloom filter.
// File 2: A newer file with whole bloom filter.
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 1 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_USEFUL ) , 0 ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " foo " ) ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " foo " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 2 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_USEFUL ) , 1 ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " bar " ) ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " bar " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 3 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_USEFUL ) , 1 ) ;
ASSERT_EQ ( " foo " , Get ( " foobar " ) ) ;
ASSERT_EQ ( " foo " , Get ( " foobar " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 4 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_USEFUL ) , 1 ) ;
ASSERT_EQ ( " bar " , Get ( " barfoo " ) ) ;
ASSERT_EQ ( " bar " , Get ( " barfoo " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 4 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_USEFUL ) , 0 ) ;
// Reopen with the same setting: only whole key is used
// Reopen with the same setting: only whole key is used
Reopen ( options ) ;
Reopen ( options ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 4 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_USEFUL ) , 0 ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " foo " ) ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " foo " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 5 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_USEFUL ) , 1 ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " bar " ) ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " bar " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 6 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_USEFUL ) , 1 ) ;
ASSERT_EQ ( " foo " , Get ( " foobar " ) ) ;
ASSERT_EQ ( " foo " , Get ( " foobar " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 7 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_USEFUL ) , 1 ) ;
ASSERT_EQ ( " bar " , Get ( " barfoo " ) ) ;
ASSERT_EQ ( " bar " , Get ( " barfoo " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 7 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_USEFUL ) , 0 ) ;
// Restart with both filters are allowed
// Restart with both filters are allowed
options . prefix_extractor . reset ( NewFixedPrefixTransform ( 3 ) ) ;
options . prefix_extractor . reset ( NewFixedPrefixTransform ( 3 ) ) ;
bbto . whole_key_filtering = true ;
bbto . whole_key_filtering = true ;
options . table_factory . reset ( NewBlockBasedTableFactory ( bbto ) ) ;
options . table_factory . reset ( NewBlockBasedTableFactory ( bbto ) ) ;
Reopen ( options ) ;
Reopen ( options ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 7 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_USEFUL ) , 0 ) ;
// File 1 will has it filtered out.
// File 1 will has it filtered out.
// File 2 will not, as prefix `foo` exists in the file.
// File 2 will not, as prefix `foo` exists in the file.
ASSERT_EQ ( " NOT_FOUND " , Get ( " foo " ) ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " foo " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 8 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_USEFUL ) , 1 ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " bar " ) ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " bar " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 10 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 1 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_USEFUL ) , 1 ) ;
ASSERT_EQ ( " foo " , Get ( " foobar " ) ) ;
ASSERT_EQ ( " foo " , Get ( " foobar " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 11 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_USEFUL ) , 1 ) ;
ASSERT_EQ ( " bar " , Get ( " barfoo " ) ) ;
ASSERT_EQ ( " bar " , Get ( " barfoo " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 11 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_USEFUL ) , 0 ) ;
// Restart with only prefix bloom is allowed.
// Restart with only prefix bloom is allowed.
options . prefix_extractor . reset ( NewFixedPrefixTransform ( 3 ) ) ;
options . prefix_extractor . reset ( NewFixedPrefixTransform ( 3 ) ) ;
bbto . whole_key_filtering = false ;
bbto . whole_key_filtering = false ;
options . table_factory . reset ( NewBlockBasedTableFactory ( bbto ) ) ;
options . table_factory . reset ( NewBlockBasedTableFactory ( bbto ) ) ;
Reopen ( options ) ;
Reopen ( options ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 11 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_USEFUL ) , 0 ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " foo " ) ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " foo " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 11 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_USEFUL ) , 0 ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " bar " ) ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " bar " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 12 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 1 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_USEFUL ) , 0 ) ;
ASSERT_EQ ( " foo " , Get ( " foobar " ) ) ;
ASSERT_EQ ( " foo " , Get ( " foobar " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 12 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_USEFUL ) , 0 ) ;
ASSERT_EQ ( " bar " , Get ( " barfoo " ) ) ;
ASSERT_EQ ( " bar " , Get ( " barfoo " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 12 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_USEFUL ) , 0 ) ;
uint64_t bloom_filter_useful_all_levels = 0 ;
uint64_t bloom_filter_useful_all_levels = 0 ;
for ( auto & kv : ( * ( get_perf_context ( ) - > level_to_perf_context ) ) ) {
for ( auto & kv : ( * ( get_perf_context ( ) - > level_to_perf_context ) ) ) {
if ( kv . second . bloom_filter_useful > 0 ) {
if ( kv . second . bloom_filter_useful > 0 ) {
@ -696,11 +724,8 @@ TEST_P(DBBloomFilterTestWithParam, SkipFilterOnEssentiallyZeroBpk) {
PutAndGetFn ( ) ;
PutAndGetFn ( ) ;
// Verify filter is accessed (and constructed)
// Verify filter is accessed (and constructed)
EXPECT_EQ ( TestGetAndResetTickerCount ( options , BLOOM_FILTER_FULL_POSITIVE ) ,
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_FULL_POSITIVE ) , maxKey * 2 ) ;
maxKey * 2 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_FULL_TRUE_POSITIVE ) , maxKey ) ;
EXPECT_EQ (
TestGetAndResetTickerCount ( options , BLOOM_FILTER_FULL_TRUE_POSITIVE ) ,
maxKey ) ;
props . clear ( ) ;
props . clear ( ) ;
ASSERT_TRUE ( db_ - > GetMapProperty ( kAggTableProps , & props ) ) ;
ASSERT_TRUE ( db_ - > GetMapProperty ( kAggTableProps , & props ) ) ;
EXPECT_NE ( props [ " filter_size " ] , " 0 " ) ;
EXPECT_NE ( props [ " filter_size " ] , " 0 " ) ;
@ -715,11 +740,8 @@ TEST_P(DBBloomFilterTestWithParam, SkipFilterOnEssentiallyZeroBpk) {
GetFn ( ) ;
GetFn ( ) ;
// Verify filter is accessed
// Verify filter is accessed
EXPECT_EQ ( TestGetAndResetTickerCount ( options , BLOOM_FILTER_FULL_POSITIVE ) ,
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_FULL_POSITIVE ) , maxKey * 2 ) ;
maxKey * 2 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_FULL_TRUE_POSITIVE ) , maxKey ) ;
EXPECT_EQ (
TestGetAndResetTickerCount ( options , BLOOM_FILTER_FULL_TRUE_POSITIVE ) ,
maxKey ) ;
// But new filters are not generated (configuration details unknown)
// But new filters are not generated (configuration details unknown)
DestroyAndReopen ( options ) ;
DestroyAndReopen ( options ) ;
@ -783,9 +805,7 @@ TEST_F(DBBloomFilterTest, BloomFilterRate) {
ASSERT_EQ ( " NOT_FOUND " , Get ( 1 , Key ( i + 33333 ) ) ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( 1 , Key ( i + 33333 ) ) ) ;
}
}
ASSERT_GE ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , maxKey * 0.98 ) ;
ASSERT_GE ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , maxKey * 0.98 ) ;
ASSERT_GE (
ASSERT_GE ( GetLevelPerfContext ( 0 ) . bloom_filter_useful , maxKey * 0.98 ) ;
( * ( get_perf_context ( ) - > level_to_perf_context ) ) [ 0 ] . bloom_filter_useful ,
maxKey * 0.98 ) ;
get_perf_context ( ) - > Reset ( ) ;
get_perf_context ( ) - > Reset ( ) ;
}
}
}
}
@ -864,9 +884,8 @@ TEST_F(DBBloomFilterTest, BloomFilterCompatibility) {
ASSERT_EQ ( " val " , Get ( prefix + " Z " ) ) ; // Filter positive
ASSERT_EQ ( " val " , Get ( prefix + " Z " ) ) ; // Filter positive
// Filter negative, with high probability
// Filter negative, with high probability
ASSERT_EQ ( " NOT_FOUND " , Get ( prefix + " Q " ) ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( prefix + " Q " ) ) ;
EXPECT_EQ ( TestGetAndResetTickerCount ( options , BLOOM_FILTER_FULL_POSITIVE ) ,
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_FULL_POSITIVE ) , 2 ) ;
2 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_USEFUL ) , 1 ) ;
EXPECT_EQ ( TestGetAndResetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 1 ) ;
}
}
}
}
}
}
@ -1705,7 +1724,7 @@ TEST_F(DBBloomFilterTest, ContextCustomFilterPolicy) {
}
}
// Since we have two tables / two filters, we might have Bloom checks on
// Since we have two tables / two filters, we might have Bloom checks on
// our queries, but no more than one "useful" per query on a found key.
// our queries, but no more than one "useful" per query on a found key.
EXPECT_LE ( TestGetAndResetTickerCount ( options , BLOOM_FILTER_USEFUL ) , maxKey ) ;
EXPECT_LE ( PopTicker ( options , BLOOM_FILTER_USEFUL ) , maxKey ) ;
// Check that we have two filters, each about
// Check that we have two filters, each about
// fifo: 0.12% FP rate (15 bits per key)
// fifo: 0.12% FP rate (15 bits per key)
@ -1714,8 +1733,7 @@ TEST_F(DBBloomFilterTest, ContextCustomFilterPolicy) {
ASSERT_EQ ( " NOT_FOUND " , Get ( 1 , Key ( i + 33333 ) ) ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( 1 , Key ( i + 33333 ) ) ) ;
}
}
{
{
auto useful_count =
auto useful_count = PopTicker ( options , BLOOM_FILTER_USEFUL ) ;
TestGetAndResetTickerCount ( options , BLOOM_FILTER_USEFUL ) ;
EXPECT_GE ( useful_count , maxKey * 2 * ( fifo ? 0.9980 : 0.975 ) ) ;
EXPECT_GE ( useful_count , maxKey * 2 * ( fifo ? 0.9980 : 0.975 ) ) ;
EXPECT_LE ( useful_count , maxKey * 2 * ( fifo ? 0.9995 : 0.98 ) ) ;
EXPECT_LE ( useful_count , maxKey * 2 * ( fifo ? 0.9995 : 0.98 ) ) ;
}
}
@ -1732,8 +1750,7 @@ TEST_F(DBBloomFilterTest, ContextCustomFilterPolicy) {
ASSERT_EQ ( " NOT_FOUND " , Get ( 1 , Key ( i + 33333 ) ) ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( 1 , Key ( i + 33333 ) ) ) ;
}
}
{
{
auto useful_count =
auto useful_count = PopTicker ( options , BLOOM_FILTER_USEFUL ) ;
TestGetAndResetTickerCount ( options , BLOOM_FILTER_USEFUL ) ;
EXPECT_GE ( useful_count , maxKey * 0.90 ) ;
EXPECT_GE ( useful_count , maxKey * 0.90 ) ;
EXPECT_LE ( useful_count , maxKey * 0.91 ) ;
EXPECT_LE ( useful_count , maxKey * 0.91 ) ;
}
}
@ -2027,13 +2044,14 @@ TEST_P(DBBloomFilterTestVaryPrefixAndFormatVer, PartitionedMultiGet) {
std : : array < Status , Q > statuses ;
std : : array < Status , Q > statuses ;
std : : array < PinnableSlice , Q > values ;
std : : array < PinnableSlice , Q > values ;
TestGetAndResetTickerCount ( options , BLOCK_CACHE_FILTER_HIT ) ;
PopTicker ( options , BLOCK_CACHE_FILTER_HIT ) ;
TestGetAndResetTickerCount ( options , BLOCK_CACHE_FILTER_MISS ) ;
PopTicker ( options , BLOCK_CACHE_FILTER_MISS ) ;
TestGetAndResetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) ;
PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) ;
TestGetAndResetTickerCount ( options , BLOOM_FILTER_USEFUL ) ;
PopTicker ( options , BLOOM_FILTER_USEFUL ) ;
TestGetAndResetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) ;
PopTicker ( options , BLOOM_FILTER_PREFIX_CHECKED ) ;
TestGetAndResetTickerCount ( options , BLOOM_FILTER_FULL_POSITIVE ) ;
PopTicker ( options , BLOOM_FILTER_FULL_POSITIVE ) ;
TestGetAndResetTickerCount ( options , BLOOM_FILTER_FULL_TRUE_POSITIVE ) ;
PopTicker ( options , BLOOM_FILTER_FULL_TRUE_POSITIVE ) ;
PopTicker ( options , BLOOM_FILTER_PREFIX_TRUE_POSITIVE ) ;
// Check that initial clump of keys only loads one partition filter from
// Check that initial clump of keys only loads one partition filter from
// block cache.
// block cache.
@ -2063,26 +2081,22 @@ TEST_P(DBBloomFilterTestVaryPrefixAndFormatVer, PartitionedMultiGet) {
}
}
// Confirm correct Bloom stats (no FPs)
// Confirm correct Bloom stats (no FPs)
uint64_t filter_useful = TestGetAndResetTickerCount (
uint64_t filter_useful =
options ,
PopTicker ( options , use_prefix_ ? BLOOM_FILTER_PREFIX_USEFUL
use_prefix_ ? BLOOM_FILTER_PREFIX_USEFUL : BLOOM_FILTER_USEFUL ) ;
: BLOOM_FILTER_USEFUL ) ;
uint64_t filter_checked =
uint64_t filter_checked =
TestGetAndResetTickerCount ( options , use_prefix_
PopTicker ( options , use_prefix_ ? BLOOM_FILTER_PREFIX_CHECKED
? BLOOM_FILTER_PREFIX_CHECKED
: BLOOM_FILTER_FULL_POSITIVE ) +
: BLOOM_FILTER_FULL_POSITIVE ) +
( use_prefix_ ? 0 : filter_useful ) ;
( use_prefix_ ? 0 : filter_useful ) ;
EXPECT_EQ ( filter_useful , number_not_found ) ;
EXPECT_EQ ( filter_useful , number_not_found ) ;
EXPECT_EQ ( filter_checked , Q ) ;
EXPECT_EQ ( filter_checked , Q ) ;
if ( ! use_prefix_ ) {
EXPECT_EQ ( PopTicker ( options , use_prefix_ ? BLOOM_FILTER_PREFIX_TRUE_POSITIVE
EXPECT_EQ (
: BLOOM_FILTER_FULL_TRUE_POSITIVE ) ,
TestGetAndResetTickerCount ( options , BLOOM_FILTER_FULL_TRUE_POSITIVE ) ,
Q - number_not_found ) ;
Q - number_not_found ) ;
}
// Confirm no duplicate loading same filter partition
// Confirm no duplicate loading same filter partition
uint64_t filter_accesses =
uint64_t filter_accesses = PopTicker ( options , BLOCK_CACHE_FILTER_HIT ) +
TestGetAndResetTickerCount ( options , BLOCK_CACHE_FILTER_HIT ) +
PopTicker ( options , BLOCK_CACHE_FILTER_MISS ) ;
TestGetAndResetTickerCount ( options , BLOCK_CACHE_FILTER_MISS ) ;
if ( stride = = 1 ) {
if ( stride = = 1 ) {
EXPECT_EQ ( filter_accesses , 1 ) ;
EXPECT_EQ ( filter_accesses , 1 ) ;
} else {
} else {
@ -2118,26 +2132,22 @@ TEST_P(DBBloomFilterTestVaryPrefixAndFormatVer, PartitionedMultiGet) {
}
}
// Confirm correct Bloom stats (might see some FPs)
// Confirm correct Bloom stats (might see some FPs)
uint64_t filter_useful = TestGetAndResetTickerCount (
uint64_t filter_useful =
options ,
PopTicker ( options , use_prefix_ ? BLOOM_FILTER_PREFIX_USEFUL
use_prefix_ ? BLOOM_FILTER_PREFIX_USEFUL : BLOOM_FILTER_USEFUL ) ;
: BLOOM_FILTER_USEFUL ) ;
uint64_t filter_checked =
uint64_t filter_checked =
TestGetAndResetTickerCount ( options , use_prefix_
PopTicker ( options , use_prefix_ ? BLOOM_FILTER_PREFIX_CHECKED
? BLOOM_FILTER_PREFIX_CHECKED
: BLOOM_FILTER_FULL_POSITIVE ) +
: BLOOM_FILTER_FULL_POSITIVE ) +
( use_prefix_ ? 0 : filter_useful ) ;
( use_prefix_ ? 0 : filter_useful ) ;
EXPECT_GE ( filter_useful , number_not_found - 2 ) ; // possible FP
EXPECT_GE ( filter_useful , number_not_found - 2 ) ; // possible FP
EXPECT_EQ ( filter_checked , Q ) ;
EXPECT_EQ ( filter_checked , Q ) ;
if ( ! use_prefix_ ) {
EXPECT_EQ ( PopTicker ( options , use_prefix_ ? BLOOM_FILTER_PREFIX_TRUE_POSITIVE
EXPECT_EQ (
: BLOOM_FILTER_FULL_TRUE_POSITIVE ) ,
TestGetAndResetTickerCount ( options , BLOOM_FILTER_FULL_TRUE_POSITIVE ) ,
Q - number_not_found ) ;
Q - number_not_found ) ;
}
// Confirm no duplicate loading of same filter partition
// Confirm no duplicate loading of same filter partition
uint64_t filter_accesses =
uint64_t filter_accesses = PopTicker ( options , BLOCK_CACHE_FILTER_HIT ) +
TestGetAndResetTickerCount ( options , BLOCK_CACHE_FILTER_HIT ) +
PopTicker ( options , BLOCK_CACHE_FILTER_MISS ) ;
TestGetAndResetTickerCount ( options , BLOCK_CACHE_FILTER_MISS ) ;
if ( filter_accesses = = 2 ) {
if ( filter_accesses = = 2 ) {
// Spanned across partitions.
// Spanned across partitions.
+ + found_spanning ;
+ + found_spanning ;
@ -2636,6 +2646,9 @@ int CountIter(std::unique_ptr<Iterator>& iter, const Slice& key) {
int count = 0 ;
int count = 0 ;
for ( iter - > Seek ( key ) ; iter - > Valid ( ) ; iter - > Next ( ) ) {
for ( iter - > Seek ( key ) ; iter - > Valid ( ) ; iter - > Next ( ) ) {
count + + ;
count + + ;
// Access key & value as if we were using them
( void ) iter - > key ( ) ;
( void ) iter - > value ( ) ;
}
}
EXPECT_OK ( iter - > status ( ) ) ;
EXPECT_OK ( iter - > status ( ) ) ;
return count ;
return count ;
@ -2675,6 +2688,12 @@ TEST_F(DBBloomFilterTest, DynamicBloomFilterUpperBound) {
read_options . iterate_upper_bound = & upper_bound ;
read_options . iterate_upper_bound = & upper_bound ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
ASSERT_EQ ( CountIter ( iter , " abcd0000 " ) , 4 ) ;
ASSERT_EQ ( CountIter ( iter , " abcd0000 " ) , 4 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) ,
1 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 0 ) ;
ASSERT_EQ ( TestGetTickerCount (
options , NON_LAST_LEVEL_SEEK_DATA_USEFUL_FILTER_MATCH ) ,
1 ) ;
}
}
{
{
Slice upper_bound ( " abcdzzzz " ) ;
Slice upper_bound ( " abcdzzzz " ) ;
@ -2683,8 +2702,9 @@ TEST_F(DBBloomFilterTest, DynamicBloomFilterUpperBound) {
read_options . iterate_upper_bound = & upper_bound ;
read_options . iterate_upper_bound = & upper_bound ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
ASSERT_EQ ( CountIter ( iter , " abcd0000 " ) , 4 ) ;
ASSERT_EQ ( CountIter ( iter , " abcd0000 " ) , 4 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 2 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) ,
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
2 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 0 ) ;
}
}
ASSERT_OK ( dbfull ( ) - > SetOptions ( { { " prefix_extractor " , " fixed:5 " } } ) ) ;
ASSERT_OK ( dbfull ( ) - > SetOptions ( { { " prefix_extractor " , " fixed:5 " } } ) ) ;
ASSERT_EQ ( dbfull ( ) - > GetOptions ( ) . prefix_extractor - > AsString ( ) ,
ASSERT_EQ ( dbfull ( ) - > GetOptions ( ) . prefix_extractor - > AsString ( ) ,
@ -2698,8 +2718,9 @@ TEST_F(DBBloomFilterTest, DynamicBloomFilterUpperBound) {
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
ASSERT_EQ ( CountIter ( iter , " abcdxx00 " ) , 4 ) ;
ASSERT_EQ ( CountIter ( iter , " abcdxx00 " ) , 4 ) ;
// should check bloom filter since upper bound meets requirement
// should check bloom filter since upper bound meets requirement
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 3 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) ,
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
3 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 0 ) ;
}
}
{
{
// [abcdxx01, abcey) is not valid bound since upper bound is too long for
// [abcdxx01, abcey) is not valid bound since upper bound is too long for
@ -2711,8 +2732,9 @@ TEST_F(DBBloomFilterTest, DynamicBloomFilterUpperBound) {
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
ASSERT_EQ ( CountIter ( iter , " abcdxx01 " ) , 4 ) ;
ASSERT_EQ ( CountIter ( iter , " abcdxx01 " ) , 4 ) ;
// should skip bloom filter since upper bound is too long
// should skip bloom filter since upper bound is too long
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 3 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) ,
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
3 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 0 ) ;
}
}
{
{
// [abcdxx02, abcdy) is a valid bound since the prefix is the same
// [abcdxx02, abcdy) is a valid bound since the prefix is the same
@ -2724,8 +2746,9 @@ TEST_F(DBBloomFilterTest, DynamicBloomFilterUpperBound) {
ASSERT_EQ ( CountIter ( iter , " abcdxx02 " ) , 4 ) ;
ASSERT_EQ ( CountIter ( iter , " abcdxx02 " ) , 4 ) ;
// should check bloom filter since upper bound matches transformed seek
// should check bloom filter since upper bound matches transformed seek
// key
// key
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 4 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) ,
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
4 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 0 ) ;
}
}
{
{
// [aaaaaaaa, abce) is not a valid bound since 1) they don't share the
// [aaaaaaaa, abce) is not a valid bound since 1) they don't share the
@ -2737,8 +2760,9 @@ TEST_F(DBBloomFilterTest, DynamicBloomFilterUpperBound) {
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
ASSERT_EQ ( CountIter ( iter , " aaaaaaaa " ) , 0 ) ;
ASSERT_EQ ( CountIter ( iter , " aaaaaaaa " ) , 0 ) ;
// should skip bloom filter since mismatch is found
// should skip bloom filter since mismatch is found
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 4 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) ,
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
4 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 0 ) ;
}
}
ASSERT_OK ( dbfull ( ) - > SetOptions ( { { " prefix_extractor " , " fixed:3 " } } ) ) ;
ASSERT_OK ( dbfull ( ) - > SetOptions ( { { " prefix_extractor " , " fixed:3 " } } ) ) ;
{
{
@ -2750,8 +2774,9 @@ TEST_F(DBBloomFilterTest, DynamicBloomFilterUpperBound) {
read_options . iterate_upper_bound = & upper_bound ;
read_options . iterate_upper_bound = & upper_bound ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
ASSERT_EQ ( CountIter ( iter , " abc " ) , 4 ) ;
ASSERT_EQ ( CountIter ( iter , " abc " ) , 4 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 4 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) ,
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
4 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 0 ) ;
}
}
// Same with re-open
// Same with re-open
options . prefix_extractor . reset ( NewFixedPrefixTransform ( 3 ) ) ;
options . prefix_extractor . reset ( NewFixedPrefixTransform ( 3 ) ) ;
@ -2763,8 +2788,9 @@ TEST_F(DBBloomFilterTest, DynamicBloomFilterUpperBound) {
read_options . iterate_upper_bound = & upper_bound ;
read_options . iterate_upper_bound = & upper_bound ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
ASSERT_EQ ( CountIter ( iter , " abc " ) , 4 ) ;
ASSERT_EQ ( CountIter ( iter , " abc " ) , 4 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 4 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) ,
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
4 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 0 ) ;
}
}
// Set back to capped:4 and verify BF is always read
// Set back to capped:4 and verify BF is always read
options . prefix_extractor . reset ( NewCappedPrefixTransform ( 4 ) ) ;
options . prefix_extractor . reset ( NewCappedPrefixTransform ( 4 ) ) ;
@ -2776,8 +2802,9 @@ TEST_F(DBBloomFilterTest, DynamicBloomFilterUpperBound) {
read_options . iterate_upper_bound = & upper_bound ;
read_options . iterate_upper_bound = & upper_bound ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
ASSERT_EQ ( CountIter ( iter , " abc " ) , 0 ) ;
ASSERT_EQ ( CountIter ( iter , " abc " ) , 0 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 5 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) ,
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 1 ) ;
4 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 1 ) ;
}
}
// Same if there's a problem initally loading prefix transform
// Same if there's a problem initally loading prefix transform
SyncPoint : : GetInstance ( ) - > SetCallBack (
SyncPoint : : GetInstance ( ) - > SetCallBack (
@ -2792,8 +2819,9 @@ TEST_F(DBBloomFilterTest, DynamicBloomFilterUpperBound) {
read_options . iterate_upper_bound = & upper_bound ;
read_options . iterate_upper_bound = & upper_bound ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
ASSERT_EQ ( CountIter ( iter , " abc " ) , 0 ) ;
ASSERT_EQ ( CountIter ( iter , " abc " ) , 0 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 6 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) ,
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 2 ) ;
4 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 2 ) ;
}
}
SyncPoint : : GetInstance ( ) - > DisableProcessing ( ) ;
SyncPoint : : GetInstance ( ) - > DisableProcessing ( ) ;
}
}
@ -2828,7 +2856,8 @@ TEST_F(DBBloomFilterTest, DynamicBloomFilterMultipleSST) {
dbfull ( ) - > Flush ( FlushOptions ( ) ) ;
dbfull ( ) - > Flush ( FlushOptions ( ) ) ;
std : : unique_ptr < Iterator > iter_old ( db_ - > NewIterator ( read_options ) ) ;
std : : unique_ptr < Iterator > iter_old ( db_ - > NewIterator ( read_options ) ) ;
ASSERT_EQ ( CountIter ( iter_old , " foo " ) , 4 ) ;
ASSERT_EQ ( CountIter ( iter_old , " foo " ) , 4 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 1 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) , 1 ) ;
ASSERT_OK ( dbfull ( ) - > SetOptions ( { { " prefix_extractor " , " capped:3 " } } ) ) ;
ASSERT_OK ( dbfull ( ) - > SetOptions ( { { " prefix_extractor " , " capped:3 " } } ) ) ;
ASSERT_EQ ( dbfull ( ) - > GetOptions ( ) . prefix_extractor - > AsString ( ) ,
ASSERT_EQ ( dbfull ( ) - > GetOptions ( ) . prefix_extractor - > AsString ( ) ,
@ -2836,10 +2865,11 @@ TEST_F(DBBloomFilterTest, DynamicBloomFilterMultipleSST) {
read_options . iterate_upper_bound = & upper_bound ;
read_options . iterate_upper_bound = & upper_bound ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
ASSERT_EQ ( CountIter ( iter , " foo " ) , 2 ) ;
ASSERT_EQ ( CountIter ( iter , " foo " ) , 2 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 2 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) , 1 ) ;
ASSERT_EQ ( CountIter ( iter , " gpk " ) , 0 ) ;
ASSERT_EQ ( CountIter ( iter , " gpk " ) , 0 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 2 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 0 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) , 0 ) ;
// second SST with capped:3 BF
// second SST with capped:3 BF
ASSERT_OK ( Put ( " foo3 " , " bar3 " ) ) ;
ASSERT_OK ( Put ( " foo3 " , " bar3 " ) ) ;
@ -2851,13 +2881,13 @@ TEST_F(DBBloomFilterTest, DynamicBloomFilterMultipleSST) {
// BF is cappped:3 now
// BF is cappped:3 now
std : : unique_ptr < Iterator > iter_tmp ( db_ - > NewIterator ( read_options ) ) ;
std : : unique_ptr < Iterator > iter_tmp ( db_ - > NewIterator ( read_options ) ) ;
ASSERT_EQ ( CountIter ( iter_tmp , " foo " ) , 4 ) ;
ASSERT_EQ ( CountIter ( iter_tmp , " foo " ) , 4 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 4 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 0 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) , 2 ) ;
ASSERT_EQ ( CountIter ( iter_tmp , " gpk " ) , 0 ) ;
ASSERT_EQ ( CountIter ( iter_tmp , " gpk " ) , 0 ) ;
// both counters are incremented because BF is "not changed" for 1 of the
// both counters are incremented because BF is "not changed" for 1 of the
// 2 SST files, so filter is checked once and found no match.
// 2 SST files, so filter is checked once and found no match.
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 5 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 1 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 1 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) , 0 ) ;
}
}
ASSERT_OK ( dbfull ( ) - > SetOptions ( { { " prefix_extractor " , " fixed:2 " } } ) ) ;
ASSERT_OK ( dbfull ( ) - > SetOptions ( { { " prefix_extractor " , " fixed:2 " } } ) ) ;
@ -2874,33 +2904,34 @@ TEST_F(DBBloomFilterTest, DynamicBloomFilterMultipleSST) {
std : : unique_ptr < Iterator > iter_tmp ( db_ - > NewIterator ( read_options ) ) ;
std : : unique_ptr < Iterator > iter_tmp ( db_ - > NewIterator ( read_options ) ) ;
ASSERT_EQ ( CountIter ( iter_tmp , " foo " ) , 9 ) ;
ASSERT_EQ ( CountIter ( iter_tmp , " foo " ) , 9 ) ;
// the first and last BF are checked
// the first and last BF are checked
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 7 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 0 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 1 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) , 2 ) ;
ASSERT_EQ ( CountIter ( iter_tmp , " gpk " ) , 0 ) ;
ASSERT_EQ ( CountIter ( iter_tmp , " gpk " ) , 0 ) ;
// only last BF is checked and not found
// only last BF is checked and not found
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 8 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 1 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 2 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) , 0 ) ;
}
}
// iter_old can only see the first SST, so checked plus 1
// iter_old can only see the first SST
ASSERT_EQ ( CountIter ( iter_old , " foo " ) , 4 ) ;
ASSERT_EQ ( CountIter ( iter_old , " foo " ) , 4 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 9 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 0 ) ;
// iter was created after the first setoptions call so only full filter
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) , 1 ) ;
// will check the filte r
// same with iter, but different prefix extracto r
ASSERT_EQ ( CountIter ( iter , " foo " ) , 2 ) ;
ASSERT_EQ ( CountIter ( iter , " foo " ) , 2 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 10 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) , 1 ) ;
{
{
// keys in all three SSTs are visible to iterator
// keys in all three SSTs are visible to iterator
// The range of [foo, foz90000] is compatible with (fixed:1) and (fixed:2)
// The range of [foo, foz90000] is compatible with (fixed:1) and (fixed:2)
// so +2 for checked counter
std : : unique_ptr < Iterator > iter_all ( db_ - > NewIterator ( read_options ) ) ;
std : : unique_ptr < Iterator > iter_all ( db_ - > NewIterator ( read_options ) ) ;
ASSERT_EQ ( CountIter ( iter_all , " foo " ) , 9 ) ;
ASSERT_EQ ( CountIter ( iter_all , " foo " ) , 9 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 12 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 0 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 2 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) , 2 ) ;
ASSERT_EQ ( CountIter ( iter_all , " gpk " ) , 0 ) ;
ASSERT_EQ ( CountIter ( iter_all , " gpk " ) , 0 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 13 ) ;
// FIXME? isn't seek key out of SST range?
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 3 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 1 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) , 0 ) ;
}
}
ASSERT_OK ( dbfull ( ) - > SetOptions ( { { " prefix_extractor " , " capped:3 " } } ) ) ;
ASSERT_OK ( dbfull ( ) - > SetOptions ( { { " prefix_extractor " , " capped:3 " } } ) ) ;
ASSERT_EQ ( dbfull ( ) - > GetOptions ( ) . prefix_extractor - > AsString ( ) ,
ASSERT_EQ ( dbfull ( ) - > GetOptions ( ) . prefix_extractor - > AsString ( ) ,
@ -2910,11 +2941,12 @@ TEST_F(DBBloomFilterTest, DynamicBloomFilterMultipleSST) {
ASSERT_EQ ( CountIter ( iter_all , " foo " ) , 6 ) ;
ASSERT_EQ ( CountIter ( iter_all , " foo " ) , 6 ) ;
// all three SST are checked because the current options has the same as
// all three SST are checked because the current options has the same as
// the remaining SST (capped:3)
// the remaining SST (capped:3)
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 16 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 0 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 3 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) , 3 ) ;
ASSERT_EQ ( CountIter ( iter_all , " gpk " ) , 0 ) ;
ASSERT_EQ ( CountIter ( iter_all , " gpk " ) , 0 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 17 ) ;
// FIXME? isn't seek key out of SST range?
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 4 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 1 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) , 0 ) ;
}
}
// TODO(Zhongyi): Maybe also need to add Get calls to test point look up?
// TODO(Zhongyi): Maybe also need to add Get calls to test point look up?
}
}
@ -3016,13 +3048,13 @@ TEST_F(DBBloomFilterTest, DynamicBloomFilterOptions) {
{
{
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
ASSERT_EQ ( CountIter ( iter , " foo " ) , 12 ) ;
ASSERT_EQ ( CountIter ( iter , " foo " ) , 12 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 3 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 0 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) , 3 ) ;
}
}
std : : unique_ptr < Iterator > iter_old ( db_ - > NewIterator ( read_options ) ) ;
std : : unique_ptr < Iterator > iter_old ( db_ - > NewIterator ( read_options ) ) ;
ASSERT_EQ ( CountIter ( iter_old , " foo " ) , 12 ) ;
ASSERT_EQ ( CountIter ( iter_old , " foo " ) , 12 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 6 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 0 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) , 3 ) ;
ASSERT_OK ( dbfull ( ) - > SetOptions ( { { " prefix_extractor " , " capped:3 " } } ) ) ;
ASSERT_OK ( dbfull ( ) - > SetOptions ( { { " prefix_extractor " , " capped:3 " } } ) ) ;
ASSERT_EQ ( dbfull ( ) - > GetOptions ( ) . prefix_extractor - > AsString ( ) ,
ASSERT_EQ ( dbfull ( ) - > GetOptions ( ) . prefix_extractor - > AsString ( ) ,
@ -3031,17 +3063,18 @@ TEST_F(DBBloomFilterTest, DynamicBloomFilterOptions) {
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
// "fp*" should be skipped
// "fp*" should be skipped
ASSERT_EQ ( CountIter ( iter , " foo " ) , 9 ) ;
ASSERT_EQ ( CountIter ( iter , " foo " ) , 9 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 6 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 0 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) , 0 ) ;
}
}
// iterator created before should not be affected and see all keys
// iterator created before should not be affected and see all keys
ASSERT_EQ ( CountIter ( iter_old , " foo " ) , 12 ) ;
ASSERT_EQ ( CountIter ( iter_old , " foo " ) , 12 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 9 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 0 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) , 3 ) ;
ASSERT_EQ ( CountIter ( iter_old , " abc " ) , 0 ) ;
ASSERT_EQ ( CountIter ( iter_old , " abc " ) , 0 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 12 ) ;
// FIXME? isn't seek key out of SST range?
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 3 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 3 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) , 0 ) ;
}
}
}
}
@ -3136,19 +3169,19 @@ class FixedSuffix4Transform : public SliceTransform {
std : : pair < uint64_t , uint64_t > GetBloomStat ( const Options & options , bool sst ) {
std : : pair < uint64_t , uint64_t > GetBloomStat ( const Options & options , bool sst ) {
if ( sst ) {
if ( sst ) {
return {
return { options . statistics - > getAndResetTickerCount (
options . statistics - > getAndResetTickerCount ( BLOOM_FILTER_PREFIX_CHECKED ) ,
NON_LAST_LEVEL_SEEK_FILTER_MATCH ) ,
options . statistics - > getAndResetTickerCount ( BLOOM_FILTER_PREFIX_USEFUL ) } ;
options . statistics - > getAndResetTickerCount (
NON_LAST_LEVEL_SEEK_FILTERED ) } ;
} else {
} else {
auto hit = std : : exchange ( get_perf_context ( ) - > bloom_memtable_hit_count , 0 ) ;
auto hit = std : : exchange ( get_perf_context ( ) - > bloom_memtable_hit_count , 0 ) ;
auto miss = std : : exchange ( get_perf_context ( ) - > bloom_memtable_miss_count , 0 ) ;
auto miss = std : : exchange ( get_perf_context ( ) - > bloom_memtable_miss_count , 0 ) ;
return { hit + miss , miss } ;
return { hit , miss } ;
}
}
}
}
std : : pair < uint64_t , uint64_t > CheckedAndUseful ( uint64_t checked ,
std : : pair < uint64_t , uint64_t > HitAndMiss ( uint64_t hits , uint64_t misses ) {
uint64_t useful ) {
return { hits , misses } ;
return { checked , useful } ;
}
}
} // anonymous namespace
} // anonymous namespace
@ -3186,27 +3219,27 @@ TEST_F(DBBloomFilterTest, WeirdPrefixExtractorWithFilter1) {
if ( flushed ) { // TODO: support auto_prefix_mode in memtable?
if ( flushed ) { // TODO: support auto_prefix_mode in memtable?
read_options . auto_prefix_mode = true ;
read_options . auto_prefix_mode = true ;
}
}
EXPECT_EQ ( GetBloomStat ( options , flushed ) , CheckedAndUseful ( 0 , 0 ) ) ;
EXPECT_EQ ( GetBloomStat ( options , flushed ) , HitAndMiss ( 0 , 0 ) ) ;
{
{
Slice ub ( " 999aaaa " ) ;
Slice ub ( " 999aaaa " ) ;
read_options . iterate_upper_bound = & ub ;
read_options . iterate_upper_bound = & ub ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
EXPECT_EQ ( CountIter ( iter , " aaaa " ) , 3 ) ;
EXPECT_EQ ( CountIter ( iter , " aaaa " ) , 3 ) ;
EXPECT_EQ ( GetBloomStat ( options , flushed ) , CheckedAndUseful ( 1 , 0 ) ) ;
EXPECT_EQ ( GetBloomStat ( options , flushed ) , HitAndMiss ( 1 , 0 ) ) ;
}
}
{
{
Slice ub ( " 999abaa " ) ;
Slice ub ( " 999abaa " ) ;
read_options . iterate_upper_bound = & ub ;
read_options . iterate_upper_bound = & ub ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
EXPECT_EQ ( CountIter ( iter , " abaa " ) , 1 ) ;
EXPECT_EQ ( CountIter ( iter , " abaa " ) , 1 ) ;
EXPECT_EQ ( GetBloomStat ( options , flushed ) , CheckedAndUseful ( 1 , 0 ) ) ;
EXPECT_EQ ( GetBloomStat ( options , flushed ) , HitAndMiss ( 1 , 0 ) ) ;
}
}
{
{
Slice ub ( " 999acaa " ) ;
Slice ub ( " 999acaa " ) ;
read_options . iterate_upper_bound = & ub ;
read_options . iterate_upper_bound = & ub ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
EXPECT_EQ ( CountIter ( iter , " acaa " ) , 0 ) ;
EXPECT_EQ ( CountIter ( iter , " acaa " ) , 0 ) ;
EXPECT_EQ ( GetBloomStat ( options , flushed ) , CheckedAndUseful ( 1 , 1 ) ) ;
EXPECT_EQ ( GetBloomStat ( options , flushed ) , HitAndMiss ( 0 , 1 ) ) ;
}
}
{
{
Slice ub ( " zzzz " ) ;
Slice ub ( " zzzz " ) ;
@ -3214,7 +3247,7 @@ TEST_F(DBBloomFilterTest, WeirdPrefixExtractorWithFilter1) {
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
EXPECT_EQ ( CountIter ( iter , " baa " ) , 3 ) ;
EXPECT_EQ ( CountIter ( iter , " baa " ) , 3 ) ;
if ( flushed ) { // TODO: fix memtable case
if ( flushed ) { // TODO: fix memtable case
EXPECT_EQ ( GetBloomStat ( options , flushed ) , CheckedAndUseful ( 0 , 0 ) ) ;
EXPECT_EQ ( GetBloomStat ( options , flushed ) , HitAndMiss ( 0 , 0 ) ) ;
}
}
}
}
}
}
@ -3260,13 +3293,13 @@ TEST_F(DBBloomFilterTest, WeirdPrefixExtractorWithFilter2) {
get_perf_context ( ) - > bloom_memtable_hit_count = 0 ;
get_perf_context ( ) - > bloom_memtable_hit_count = 0 ;
get_perf_context ( ) - > bloom_memtable_miss_count = 0 ;
get_perf_context ( ) - > bloom_memtable_miss_count = 0 ;
}
}
EXPECT_EQ ( GetBloomStat ( options , flushed ) , CheckedAndUseful ( 0 , 0 ) ) ;
EXPECT_EQ ( GetBloomStat ( options , flushed ) , HitAndMiss ( 0 , 0 ) ) ;
{
{
Slice ub ( " aaaa000 " ) ;
Slice ub ( " aaaa000 " ) ;
read_options . iterate_upper_bound = & ub ;
read_options . iterate_upper_bound = & ub ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
EXPECT_EQ ( CountIter ( iter , " aaaa999 " ) , 3 ) ;
EXPECT_EQ ( CountIter ( iter , " aaaa999 " ) , 3 ) ;
EXPECT_EQ ( GetBloomStat ( options , flushed ) , CheckedAndUseful ( 1 , 0 ) ) ;
EXPECT_EQ ( GetBloomStat ( options , flushed ) , HitAndMiss ( 1 , 0 ) ) ;
}
}
{
{
// Note: prefix does work as upper bound
// Note: prefix does work as upper bound
@ -3274,7 +3307,7 @@ TEST_F(DBBloomFilterTest, WeirdPrefixExtractorWithFilter2) {
read_options . iterate_upper_bound = & ub ;
read_options . iterate_upper_bound = & ub ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
EXPECT_EQ ( CountIter ( iter , " aaaa999 " ) , 3 ) ;
EXPECT_EQ ( CountIter ( iter , " aaaa999 " ) , 3 ) ;
EXPECT_EQ ( GetBloomStat ( options , flushed ) , CheckedAndUseful ( 1 , 0 ) ) ;
EXPECT_EQ ( GetBloomStat ( options , flushed ) , HitAndMiss ( 1 , 0 ) ) ;
}
}
{
{
// Note: prefix does not work here as seek key
// Note: prefix does not work here as seek key
@ -3282,28 +3315,28 @@ TEST_F(DBBloomFilterTest, WeirdPrefixExtractorWithFilter2) {
read_options . iterate_upper_bound = & ub ;
read_options . iterate_upper_bound = & ub ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
EXPECT_EQ ( CountIter ( iter , " aaaa " ) , 0 ) ;
EXPECT_EQ ( CountIter ( iter , " aaaa " ) , 0 ) ;
EXPECT_EQ ( GetBloomStat ( options , flushed ) , CheckedAndUseful ( 1 , 0 ) ) ;
EXPECT_EQ ( GetBloomStat ( options , flushed ) , HitAndMiss ( 1 , 0 ) ) ;
}
}
{
{
Slice ub ( " aaba000 " ) ;
Slice ub ( " aaba000 " ) ;
read_options . iterate_upper_bound = & ub ;
read_options . iterate_upper_bound = & ub ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
EXPECT_EQ ( CountIter ( iter , " aaba999 " ) , 1 ) ;
EXPECT_EQ ( CountIter ( iter , " aaba999 " ) , 1 ) ;
EXPECT_EQ ( GetBloomStat ( options , flushed ) , CheckedAndUseful ( 1 , 0 ) ) ;
EXPECT_EQ ( GetBloomStat ( options , flushed ) , HitAndMiss ( 1 , 0 ) ) ;
}
}
{
{
Slice ub ( " aaca000 " ) ;
Slice ub ( " aaca000 " ) ;
read_options . iterate_upper_bound = & ub ;
read_options . iterate_upper_bound = & ub ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
EXPECT_EQ ( CountIter ( iter , " aaca999 " ) , 0 ) ;
EXPECT_EQ ( CountIter ( iter , " aaca999 " ) , 0 ) ;
EXPECT_EQ ( GetBloomStat ( options , flushed ) , CheckedAndUseful ( 1 , 1 ) ) ;
EXPECT_EQ ( GetBloomStat ( options , flushed ) , HitAndMiss ( 0 , 1 ) ) ;
}
}
{
{
Slice ub ( " aaaz " ) ;
Slice ub ( " aaaz " ) ;
read_options . iterate_upper_bound = & ub ;
read_options . iterate_upper_bound = & ub ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
EXPECT_EQ ( CountIter ( iter , " zzz " ) , 5 ) ;
EXPECT_EQ ( CountIter ( iter , " zzz " ) , 5 ) ;
EXPECT_EQ ( GetBloomStat ( options , flushed ) , CheckedAndUseful ( 0 , 0 ) ) ;
EXPECT_EQ ( GetBloomStat ( options , flushed ) , HitAndMiss ( 0 , 0 ) ) ;
}
}
{
{
// Note: prefix does work here as seek key, but only finds key equal
// Note: prefix does work here as seek key, but only finds key equal
@ -3313,7 +3346,7 @@ TEST_F(DBBloomFilterTest, WeirdPrefixExtractorWithFilter2) {
read_options . prefix_same_as_start = true ;
read_options . prefix_same_as_start = true ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
EXPECT_EQ ( CountIter ( iter , " qqqq " ) , 1 ) ;
EXPECT_EQ ( CountIter ( iter , " qqqq " ) , 1 ) ;
EXPECT_EQ ( GetBloomStat ( options , flushed ) , CheckedAndUseful ( 1 , 0 ) ) ;
EXPECT_EQ ( GetBloomStat ( options , flushed ) , HitAndMiss ( 1 , 0 ) ) ;
}
}
}
}
}
}
@ -3404,13 +3437,13 @@ TEST_F(DBBloomFilterTest, WeirdPrefixExtractorWithFilter3) {
get_perf_context ( ) - > bloom_memtable_hit_count = 0 ;
get_perf_context ( ) - > bloom_memtable_hit_count = 0 ;
get_perf_context ( ) - > bloom_memtable_miss_count = 0 ;
get_perf_context ( ) - > bloom_memtable_miss_count = 0 ;
}
}
EXPECT_EQ ( GetBloomStat ( options , flushed ) , CheckedAndUseful ( 0 , 0 ) ) ;
EXPECT_EQ ( GetBloomStat ( options , flushed ) , HitAndMiss ( 0 , 0 ) ) ;
{
{
Slice ub ( " aaaa999 " ) ;
Slice ub ( " aaaa999 " ) ;
read_options . iterate_upper_bound = & ub ;
read_options . iterate_upper_bound = & ub ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
EXPECT_EQ ( CountIter ( iter , " aaaa000 " ) , 3 ) ;
EXPECT_EQ ( CountIter ( iter , " aaaa000 " ) , 3 ) ;
EXPECT_EQ ( GetBloomStat ( options , flushed ) , CheckedAndUseful ( 1 , 0 ) ) ;
EXPECT_EQ ( GetBloomStat ( options , flushed ) , HitAndMiss ( 1 , 0 ) ) ;
}
}
{
{
// Note: prefix as seek key is not bloom-optimized
// Note: prefix as seek key is not bloom-optimized
@ -3420,28 +3453,28 @@ TEST_F(DBBloomFilterTest, WeirdPrefixExtractorWithFilter3) {
read_options . iterate_upper_bound = & ub ;
read_options . iterate_upper_bound = & ub ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
EXPECT_EQ ( CountIter ( iter , " aaaa " ) , 3 ) ;
EXPECT_EQ ( CountIter ( iter , " aaaa " ) , 3 ) ;
EXPECT_EQ ( GetBloomStat ( options , flushed ) , CheckedAndUseful ( 0 , 0 ) ) ;
EXPECT_EQ ( GetBloomStat ( options , flushed ) , HitAndMiss ( 0 , 0 ) ) ;
}
}
{
{
Slice ub ( " aaba9 " ) ;
Slice ub ( " aaba9 " ) ;
read_options . iterate_upper_bound = & ub ;
read_options . iterate_upper_bound = & ub ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
EXPECT_EQ ( CountIter ( iter , " aaba0 " ) , 1 ) ;
EXPECT_EQ ( CountIter ( iter , " aaba0 " ) , 1 ) ;
EXPECT_EQ ( GetBloomStat ( options , flushed ) , CheckedAndUseful ( 1 , 0 ) ) ;
EXPECT_EQ ( GetBloomStat ( options , flushed ) , HitAndMiss ( 1 , 0 ) ) ;
}
}
{
{
Slice ub ( " aaca9 " ) ;
Slice ub ( " aaca9 " ) ;
read_options . iterate_upper_bound = & ub ;
read_options . iterate_upper_bound = & ub ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
EXPECT_EQ ( CountIter ( iter , " aaca0 " ) , 0 ) ;
EXPECT_EQ ( CountIter ( iter , " aaca0 " ) , 0 ) ;
EXPECT_EQ ( GetBloomStat ( options , flushed ) , CheckedAndUseful ( 1 , 1 ) ) ;
EXPECT_EQ ( GetBloomStat ( options , flushed ) , HitAndMiss ( 0 , 1 ) ) ;
}
}
{
{
Slice ub ( " qqqq9 " ) ;
Slice ub ( " qqqq9 " ) ;
read_options . iterate_upper_bound = & ub ;
read_options . iterate_upper_bound = & ub ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
EXPECT_EQ ( CountIter ( iter , " qqqq0 " ) , 1 ) ;
EXPECT_EQ ( CountIter ( iter , " qqqq0 " ) , 1 ) ;
EXPECT_EQ ( GetBloomStat ( options , flushed ) , CheckedAndUseful ( 1 , 0 ) ) ;
EXPECT_EQ ( GetBloomStat ( options , flushed ) , HitAndMiss ( 1 , 0 ) ) ;
}
}
{
{
// Note: prefix as seek key is not bloom-optimized
// Note: prefix as seek key is not bloom-optimized
@ -3449,7 +3482,7 @@ TEST_F(DBBloomFilterTest, WeirdPrefixExtractorWithFilter3) {
read_options . iterate_upper_bound = & ub ;
read_options . iterate_upper_bound = & ub ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
EXPECT_EQ ( CountIter ( iter , " qqqq " ) , weird_comparator ? 7 : 2 ) ;
EXPECT_EQ ( CountIter ( iter , " qqqq " ) , weird_comparator ? 7 : 2 ) ;
EXPECT_EQ ( GetBloomStat ( options , flushed ) , CheckedAndUseful ( 0 , 0 ) ) ;
EXPECT_EQ ( GetBloomStat ( options , flushed ) , HitAndMiss ( 0 , 0 ) ) ;
}
}
{
{
// Note: prefix as seek key is not bloom-optimized
// Note: prefix as seek key is not bloom-optimized
@ -3457,14 +3490,14 @@ TEST_F(DBBloomFilterTest, WeirdPrefixExtractorWithFilter3) {
read_options . iterate_upper_bound = & ub ;
read_options . iterate_upper_bound = & ub ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
EXPECT_EQ ( CountIter ( iter , " zzzz " ) , weird_comparator ? 8 : 1 ) ;
EXPECT_EQ ( CountIter ( iter , " zzzz " ) , weird_comparator ? 8 : 1 ) ;
EXPECT_EQ ( GetBloomStat ( options , flushed ) , CheckedAndUseful ( 0 , 0 ) ) ;
EXPECT_EQ ( GetBloomStat ( options , flushed ) , HitAndMiss ( 0 , 0 ) ) ;
}
}
{
{
Slice ub ( " zzzz9 " ) ;
Slice ub ( " zzzz9 " ) ;
read_options . iterate_upper_bound = & ub ;
read_options . iterate_upper_bound = & ub ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
EXPECT_EQ ( CountIter ( iter , " aab " ) , weird_comparator ? 6 : 5 ) ;
EXPECT_EQ ( CountIter ( iter , " aab " ) , weird_comparator ? 6 : 5 ) ;
EXPECT_EQ ( GetBloomStat ( options , flushed ) , CheckedAndUseful ( 0 , 0 ) ) ;
EXPECT_EQ ( GetBloomStat ( options , flushed ) , HitAndMiss ( 0 , 0 ) ) ;
}
}
}
}
}
}