@ -43,6 +43,16 @@ const std::string kStandard128Ribbon =
test : : Standard128RibbonFilterPolicy : : kClassName ( ) ;
const std : : string kAutoBloom = BloomFilterPolicy : : 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
// DB tests related to bloom filter.
@ -209,57 +219,43 @@ TEST_F(DBBloomFilterTest, GetFilterByPrefixBloomCustomPrefixExtractor) {
ASSERT_OK ( dbfull ( ) - > Flush ( fo ) ) ;
ASSERT_EQ ( " foo " , Get ( " barbarbar " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 0 ) ;
ASSERT_EQ (
0 ,
( * ( get_perf_context ( ) - > level_to_perf_context ) ) [ 0 ] . bloom_filter_useful ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( Pop ( GetLevelPerfContext ( 0 ) . bloom_filter_useful ) , 0 ) ;
ASSERT_EQ ( " foo2 " , Get ( " barbarbar2 " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 0 ) ;
ASSERT_EQ (
0 ,
( * ( get_perf_context ( ) - > level_to_perf_context ) ) [ 0 ] . bloom_filter_useful ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( Pop ( GetLevelPerfContext ( 0 ) . bloom_filter_useful ) , 0 ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " barbarbar3 " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 0 ) ;
ASSERT_EQ (
0 ,
( * ( get_perf_context ( ) - > level_to_perf_context ) ) [ 0 ] . bloom_filter_useful ) ;
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 ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 1 ) ;
ASSERT_EQ (
1 ,
( * ( get_perf_context ( ) - > level_to_perf_context ) ) [ 0 ] . bloom_filter_useful ) ;
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 ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 2 ) ;
ASSERT_EQ (
2 ,
( * ( get_perf_context ( ) - > level_to_perf_context ) ) [ 0 ] . bloom_filter_useful ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 1 ) ;
EXPECT_EQ ( Pop ( GetLevelPerfContext ( 0 ) . bloom_filter_useful ) , 1 ) ;
ro . total_order_seek = true ;
// NOTE: total_order_seek no longer affects Get()
ASSERT_EQ ( " NOT_FOUND " , Get ( " foobarbar " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 3 ) ;
ASSERT_EQ (
3 ,
( * ( get_perf_context ( ) - > level_to_perf_context ) ) [ 0 ] . bloom_filter_useful ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 1 ) ;
EXPECT_EQ ( Pop ( GetLevelPerfContext ( 0 ) . bloom_filter_useful ) , 1 ) ;
// No bloom on extractor changed
ASSERT_OK ( db_ - > SetOptions ( { { " prefix_extractor " , " capped:10 " } } ) ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " foobarbar " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 3 ) ;
ASSERT_EQ (
3 ,
( * ( get_perf_context ( ) - > level_to_perf_context ) ) [ 0 ] . bloom_filter_useful ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( Pop ( GetLevelPerfContext ( 0 ) . bloom_filter_useful ) , 0 ) ;
// No bloom on extractor changed, after re-open
options . prefix_extractor . reset ( NewCappedPrefixTransform ( 10 ) ) ;
Reopen ( options ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " foobarbar " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 3 ) ;
ASSERT_EQ (
3 ,
( * ( get_perf_context ( ) - > level_to_perf_context ) ) [ 0 ] . bloom_filter_useful ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( Pop ( GetLevelPerfContext ( 0 ) . bloom_filter_useful ) , 0 ) ;
get_perf_context ( ) - > Reset ( ) ;
}
@ -294,33 +290,32 @@ TEST_F(DBBloomFilterTest, GetFilterByPrefixBloom) {
ASSERT_OK ( dbfull ( ) - > Flush ( fo ) ) ;
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 ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX _USEFUL ) , 0 ) ;
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 ( 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 ( 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 ;
// NOTE: total_order_seek no longer affects Get()
ASSERT_EQ ( " NOT_FOUND " , Get ( " foobarbar " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 3 ) ;
ASSERT_EQ (
3 ,
( * ( get_perf_context ( ) - > level_to_perf_context ) ) [ 0 ] . bloom_filter_useful ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 1 ) ;
EXPECT_EQ ( Pop ( GetLevelPerfContext ( 0 ) . bloom_filter_useful ) , 1 ) ;
// No bloom on extractor changed
ASSERT_OK ( db_ - > SetOptions ( { { " prefix_extractor " , " capped:10 " } } ) ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " foobarbar " ) ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 3 ) ;
ASSERT_EQ (
3 ,
( * ( get_perf_context ( ) - > level_to_perf_context ) ) [ 0 ] . bloom_filter_useful ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( Pop ( GetLevelPerfContext ( 0 ) . bloom_filter_useful ) , 0 ) ;
get_perf_context ( ) - > Reset ( ) ;
}
@ -357,12 +352,17 @@ TEST_F(DBBloomFilterTest, WholeKeyFilterProp) {
ASSERT_OK ( dbfull ( ) - > Flush ( fo ) ) ;
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 ( 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 ( 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 ( 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
// NULL. Bloom filter should be off for both of whole key and
@ -372,13 +372,17 @@ TEST_F(DBBloomFilterTest, WholeKeyFilterProp) {
options . prefix_extractor . reset ( ) ;
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 ( 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 ( 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 ( 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.
ASSERT_OK ( dbfull ( ) - > Put ( wo , " foobar " , " foo " ) ) ;
// 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 ) ) ;
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 ( 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 ( 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 ( 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:
ASSERT_OK ( dbfull ( ) - > Put ( wo , " foobar " , " foo " ) ) ;
@ -424,61 +432,81 @@ TEST_F(DBBloomFilterTest, WholeKeyFilterProp) {
ASSERT_OK ( Flush ( ) ) ;
// 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.
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 ( 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 ( 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 ( 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 ( 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 ( 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 ( 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 ( 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 ( 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 ( 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
options . prefix_extractor . reset ( NewFixedPrefixTransform ( 3 ) ) ;
bbto . whole_key_filtering = true ;
options . table_factory . reset ( NewBlockBasedTableFactory ( bbto ) ) ;
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 2 will not, as prefix `foo` exists in the file.
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 ( 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 ( 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 ( 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.
options . prefix_extractor . reset ( NewFixedPrefixTransform ( 3 ) ) ;
bbto . whole_key_filtering = false ;
options . table_factory . reset ( NewBlockBasedTableFactory ( bbto ) ) ;
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 ( 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 ( 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 ( 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 ( 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 ;
for ( auto & kv : ( * ( get_perf_context ( ) - > level_to_perf_context ) ) ) {
if ( kv . second . bloom_filter_useful > 0 ) {
@ -696,11 +724,8 @@ TEST_P(DBBloomFilterTestWithParam, SkipFilterOnEssentiallyZeroBpk) {
PutAndGetFn ( ) ;
// Verify filter is accessed (and constructed)
EXPECT_EQ ( TestGetAndResetTickerCount ( options , BLOOM_FILTER_FULL_POSITIVE ) ,
maxKey * 2 ) ;
EXPECT_EQ (
TestGetAndResetTickerCount ( options , BLOOM_FILTER_FULL_TRUE_POSITIVE ) ,
maxKey ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_FULL_POSITIVE ) , maxKey * 2 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_FULL_TRUE_POSITIVE ) , maxKey ) ;
props . clear ( ) ;
ASSERT_TRUE ( db_ - > GetMapProperty ( kAggTableProps , & props ) ) ;
EXPECT_NE ( props [ " filter_size " ] , " 0 " ) ;
@ -715,11 +740,8 @@ TEST_P(DBBloomFilterTestWithParam, SkipFilterOnEssentiallyZeroBpk) {
GetFn ( ) ;
// Verify filter is accessed
EXPECT_EQ ( TestGetAndResetTickerCount ( options , BLOOM_FILTER_FULL_POSITIVE ) ,
maxKey * 2 ) ;
EXPECT_EQ (
TestGetAndResetTickerCount ( options , BLOOM_FILTER_FULL_TRUE_POSITIVE ) ,
maxKey ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_FULL_POSITIVE ) , maxKey * 2 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_FULL_TRUE_POSITIVE ) , maxKey ) ;
// But new filters are not generated (configuration details unknown)
DestroyAndReopen ( options ) ;
@ -783,9 +805,7 @@ TEST_F(DBBloomFilterTest, BloomFilterRate) {
ASSERT_EQ ( " NOT_FOUND " , Get ( 1 , Key ( i + 33333 ) ) ) ;
}
ASSERT_GE ( TestGetTickerCount ( options , BLOOM_FILTER_USEFUL ) , maxKey * 0.98 ) ;
ASSERT_GE (
( * ( get_perf_context ( ) - > level_to_perf_context ) ) [ 0 ] . bloom_filter_useful ,
maxKey * 0.98 ) ;
ASSERT_GE ( GetLevelPerfContext ( 0 ) . bloom_filter_useful , maxKey * 0.98 ) ;
get_perf_context ( ) - > Reset ( ) ;
}
}
@ -864,9 +884,8 @@ TEST_F(DBBloomFilterTest, BloomFilterCompatibility) {
ASSERT_EQ ( " val " , Get ( prefix + " Z " ) ) ; // Filter positive
// Filter negative, with high probability
ASSERT_EQ ( " NOT_FOUND " , Get ( prefix + " Q " ) ) ;
EXPECT_EQ ( TestGetAndResetTickerCount ( options , BLOOM_FILTER_FULL_POSITIVE ) ,
2 ) ;
EXPECT_EQ ( TestGetAndResetTickerCount ( options , BLOOM_FILTER_USEFUL ) , 1 ) ;
EXPECT_EQ ( PopTicker ( options , BLOOM_FILTER_FULL_POSITIVE ) , 2 ) ;
EXPECT_EQ ( PopTicker ( 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
// 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
// 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 ) ) ) ;
}
{
auto useful_count =
TestGetAndResetTickerCount ( options , BLOOM_FILTER_USEFUL ) ;
auto useful_count = PopTicker ( options , BLOOM_FILTER_USEFUL ) ;
EXPECT_GE ( useful_count , maxKey * 2 * ( fifo ? 0.9980 : 0.975 ) ) ;
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 ) ) ) ;
}
{
auto useful_count =
TestGetAndResetTickerCount ( options , BLOOM_FILTER_USEFUL ) ;
auto useful_count = PopTicker ( options , BLOOM_FILTER_USEFUL ) ;
EXPECT_GE ( useful_count , maxKey * 0.90 ) ;
EXPECT_LE ( useful_count , maxKey * 0.91 ) ;
}
@ -2027,13 +2044,14 @@ TEST_P(DBBloomFilterTestVaryPrefixAndFormatVer, PartitionedMultiGet) {
std : : array < Status , Q > statuses ;
std : : array < PinnableSlice , Q > values ;
TestGetAndResetTickerCount ( options , BLOCK_CACHE_FILTER_HIT ) ;
TestGetAndResetTickerCount ( options , BLOCK_CACHE_FILTER_MISS ) ;
TestGetAndResetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) ;
TestGetAndResetTickerCount ( options , BLOOM_FILTER_USEFUL ) ;
TestGetAndResetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) ;
TestGetAndResetTickerCount ( options , BLOOM_FILTER_FULL_POSITIVE ) ;
TestGetAndResetTickerCount ( options , BLOOM_FILTER_FULL_TRUE_POSITIVE ) ;
PopTicker ( options , BLOCK_CACHE_FILTER_HIT ) ;
PopTicker ( options , BLOCK_CACHE_FILTER_MISS ) ;
PopTicker ( options , BLOOM_FILTER_PREFIX_USEFUL ) ;
PopTicker ( options , BLOOM_FILTER_USEFUL ) ;
PopTicker ( options , BLOOM_FILTER_PREFIX_CHECKED ) ;
PopTicker ( options , BLOOM_FILTER_FULL_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
// block cache.
@ -2063,26 +2081,22 @@ TEST_P(DBBloomFilterTestVaryPrefixAndFormatVer, PartitionedMultiGet) {
}
// Confirm correct Bloom stats (no FPs)
uint64_t filter_useful = TestGetAndResetTickerCount (
options ,
use_prefix_ ? BLOOM_FILTER_PREFIX_USEFUL : BLOOM_FILTER_USEFUL ) ;
uint64_t filter_useful =
PopTicker ( options , use_prefix_ ? BLOOM_FILTER_PREFIX_USEFUL
: BLOOM_FILTER_USEFUL ) ;
uint64_t filter_checked =
TestGetAndResetTickerCount ( options , use_prefix_
? BLOOM_FILTER_PREFIX_CHECKED
: BLOOM_FILTER_FULL_POSITIVE ) +
PopTicker ( options , use_prefix_ ? BLOOM_FILTER_PREFIX_CHECKED
: BLOOM_FILTER_FULL_POSITIVE ) +
( use_prefix_ ? 0 : filter_useful ) ;
EXPECT_EQ ( filter_useful , number_not_found ) ;
EXPECT_EQ ( filter_checked , Q ) ;
if ( ! use_prefix_ ) {
EXPECT_EQ (
TestGetAndResetTickerCount ( options , BLOOM_FILTER_FULL_TRUE_POSITIVE ) ,
Q - number_not_found ) ;
}
EXPECT_EQ ( PopTicker ( options , use_prefix_ ? BLOOM_FILTER_PREFIX_TRUE_POSITIVE
: BLOOM_FILTER_FULL_TRUE_POSITIVE ) ,
Q - number_not_found ) ;
// Confirm no duplicate loading same filter partition
uint64_t filter_accesses =
TestGetAndResetTickerCount ( options , BLOCK_CACHE_FILTER_HIT ) +
TestGetAndResetTickerCount ( options , BLOCK_CACHE_FILTER_MISS ) ;
uint64_t filter_accesses = PopTicker ( options , BLOCK_CACHE_FILTER_HIT ) +
PopTicker ( options , BLOCK_CACHE_FILTER_MISS ) ;
if ( stride = = 1 ) {
EXPECT_EQ ( filter_accesses , 1 ) ;
} else {
@ -2118,26 +2132,22 @@ TEST_P(DBBloomFilterTestVaryPrefixAndFormatVer, PartitionedMultiGet) {
}
// Confirm correct Bloom stats (might see some FPs)
uint64_t filter_useful = TestGetAndResetTickerCount (
options ,
use_prefix_ ? BLOOM_FILTER_PREFIX_USEFUL : BLOOM_FILTER_USEFUL ) ;
uint64_t filter_useful =
PopTicker ( options , use_prefix_ ? BLOOM_FILTER_PREFIX_USEFUL
: BLOOM_FILTER_USEFUL ) ;
uint64_t filter_checked =
TestGetAndResetTickerCount ( options , use_prefix_
? BLOOM_FILTER_PREFIX_CHECKED
: BLOOM_FILTER_FULL_POSITIVE ) +
PopTicker ( options , use_prefix_ ? BLOOM_FILTER_PREFIX_CHECKED
: BLOOM_FILTER_FULL_POSITIVE ) +
( use_prefix_ ? 0 : filter_useful ) ;
EXPECT_GE ( filter_useful , number_not_found - 2 ) ; // possible FP
EXPECT_EQ ( filter_checked , Q ) ;
if ( ! use_prefix_ ) {
EXPECT_EQ (
TestGetAndResetTickerCount ( options , BLOOM_FILTER_FULL_TRUE_POSITIVE ) ,
Q - number_not_found ) ;
}
EXPECT_EQ ( PopTicker ( options , use_prefix_ ? BLOOM_FILTER_PREFIX_TRUE_POSITIVE
: BLOOM_FILTER_FULL_TRUE_POSITIVE ) ,
Q - number_not_found ) ;
// Confirm no duplicate loading of same filter partition
uint64_t filter_accesses =
TestGetAndResetTickerCount ( options , BLOCK_CACHE_FILTER_HIT ) +
TestGetAndResetTickerCount ( options , BLOCK_CACHE_FILTER_MISS ) ;
uint64_t filter_accesses = PopTicker ( options , BLOCK_CACHE_FILTER_HIT ) +
PopTicker ( options , BLOCK_CACHE_FILTER_MISS ) ;
if ( filter_accesses = = 2 ) {
// Spanned across partitions.
+ + found_spanning ;
@ -2636,6 +2646,9 @@ int CountIter(std::unique_ptr<Iterator>& iter, const Slice& key) {
int count = 0 ;
for ( iter - > Seek ( key ) ; iter - > Valid ( ) ; iter - > Next ( ) ) {
count + + ;
// Access key & value as if we were using them
( void ) iter - > key ( ) ;
( void ) iter - > value ( ) ;
}
EXPECT_OK ( iter - > status ( ) ) ;
return count ;
@ -2675,6 +2688,12 @@ TEST_F(DBBloomFilterTest, DynamicBloomFilterUpperBound) {
read_options . iterate_upper_bound = & upper_bound ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
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 " ) ;
@ -2683,8 +2702,9 @@ TEST_F(DBBloomFilterTest, DynamicBloomFilterUpperBound) {
read_options . iterate_upper_bound = & upper_bound ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
ASSERT_EQ ( CountIter ( iter , " abcd0000 " ) , 4 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 2 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) ,
2 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 0 ) ;
}
ASSERT_OK ( dbfull ( ) - > SetOptions ( { { " prefix_extractor " , " fixed:5 " } } ) ) ;
ASSERT_EQ ( dbfull ( ) - > GetOptions ( ) . prefix_extractor - > AsString ( ) ,
@ -2698,8 +2718,9 @@ TEST_F(DBBloomFilterTest, DynamicBloomFilterUpperBound) {
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
ASSERT_EQ ( CountIter ( iter , " abcdxx00 " ) , 4 ) ;
// should check bloom filter since upper bound meets requirement
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 3 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) ,
3 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 0 ) ;
}
{
// [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 ) ) ;
ASSERT_EQ ( CountIter ( iter , " abcdxx01 " ) , 4 ) ;
// should skip bloom filter since upper bound is too long
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 3 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) ,
3 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 0 ) ;
}
{
// [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 ) ;
// should check bloom filter since upper bound matches transformed seek
// key
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 4 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) ,
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
@ -2737,8 +2760,9 @@ TEST_F(DBBloomFilterTest, DynamicBloomFilterUpperBound) {
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
ASSERT_EQ ( CountIter ( iter , " aaaaaaaa " ) , 0 ) ;
// should skip bloom filter since mismatch is found
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 4 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) ,
4 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 0 ) ;
}
ASSERT_OK ( dbfull ( ) - > SetOptions ( { { " prefix_extractor " , " fixed:3 " } } ) ) ;
{
@ -2750,8 +2774,9 @@ TEST_F(DBBloomFilterTest, DynamicBloomFilterUpperBound) {
read_options . iterate_upper_bound = & upper_bound ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
ASSERT_EQ ( CountIter ( iter , " abc " ) , 4 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 4 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) ,
4 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 0 ) ;
}
// Same with re-open
options . prefix_extractor . reset ( NewFixedPrefixTransform ( 3 ) ) ;
@ -2763,8 +2788,9 @@ TEST_F(DBBloomFilterTest, DynamicBloomFilterUpperBound) {
read_options . iterate_upper_bound = & upper_bound ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
ASSERT_EQ ( CountIter ( iter , " abc " ) , 4 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 4 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) ,
4 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 0 ) ;
}
// Set back to capped:4 and verify BF is always read
options . prefix_extractor . reset ( NewCappedPrefixTransform ( 4 ) ) ;
@ -2776,8 +2802,9 @@ TEST_F(DBBloomFilterTest, DynamicBloomFilterUpperBound) {
read_options . iterate_upper_bound = & upper_bound ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
ASSERT_EQ ( CountIter ( iter , " abc " ) , 0 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 5 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 1 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) ,
4 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 1 ) ;
}
// Same if there's a problem initally loading prefix transform
SyncPoint : : GetInstance ( ) - > SetCallBack (
@ -2792,8 +2819,9 @@ TEST_F(DBBloomFilterTest, DynamicBloomFilterUpperBound) {
read_options . iterate_upper_bound = & upper_bound ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
ASSERT_EQ ( CountIter ( iter , " abc " ) , 0 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 6 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 2 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) ,
4 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 2 ) ;
}
SyncPoint : : GetInstance ( ) - > DisableProcessing ( ) ;
}
@ -2828,7 +2856,8 @@ TEST_F(DBBloomFilterTest, DynamicBloomFilterMultipleSST) {
dbfull ( ) - > Flush ( FlushOptions ( ) ) ;
std : : unique_ptr < Iterator > iter_old ( db_ - > NewIterator ( read_options ) ) ;
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_EQ ( dbfull ( ) - > GetOptions ( ) . prefix_extractor - > AsString ( ) ,
@ -2836,10 +2865,11 @@ TEST_F(DBBloomFilterTest, DynamicBloomFilterMultipleSST) {
read_options . iterate_upper_bound = & upper_bound ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
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 ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 2 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) , 0 ) ;
// second SST with capped:3 BF
ASSERT_OK ( Put ( " foo3 " , " bar3 " ) ) ;
@ -2851,13 +2881,13 @@ TEST_F(DBBloomFilterTest, DynamicBloomFilterMultipleSST) {
// BF is cappped:3 now
std : : unique_ptr < Iterator > iter_tmp ( db_ - > NewIterator ( read_options ) ) ;
ASSERT_EQ ( CountIter ( iter_tmp , " foo " ) , 4 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 4 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) , 2 ) ;
ASSERT_EQ ( CountIter ( iter_tmp , " gpk " ) , 0 ) ;
// 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.
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 5 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 1 ) ;
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 " , " fixed:2 " } } ) ) ;
@ -2874,33 +2904,34 @@ TEST_F(DBBloomFilterTest, DynamicBloomFilterMultipleSST) {
std : : unique_ptr < Iterator > iter_tmp ( db_ - > NewIterator ( read_options ) ) ;
ASSERT_EQ ( CountIter ( iter_tmp , " foo " ) , 9 ) ;
// the first and last BF are checked
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 7 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 1 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) , 2 ) ;
ASSERT_EQ ( CountIter ( iter_tmp , " gpk " ) , 0 ) ;
// only last BF is checked and not found
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 8 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 2 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 1 ) ;
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 ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 9 ) ;
// iter was created after the first setoptions call so only full filter
// will check the filte r
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) , 1 ) ;
// same with iter, but different prefix extracto r
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
// 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 ) ) ;
ASSERT_EQ ( CountIter ( iter_all , " foo " ) , 9 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 12 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 2 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) , 2 ) ;
ASSERT_EQ ( CountIter ( iter_all , " gpk " ) , 0 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 13 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 3 ) ;
// FIXME? isn't seek key out of SST range?
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_EQ ( dbfull ( ) - > GetOptions ( ) . prefix_extractor - > AsString ( ) ,
@ -2910,11 +2941,12 @@ TEST_F(DBBloomFilterTest, DynamicBloomFilterMultipleSST) {
ASSERT_EQ ( CountIter ( iter_all , " foo " ) , 6 ) ;
// all three SST are checked because the current options has the same as
// the remaining SST (capped:3)
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 16 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 3 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) , 3 ) ;
ASSERT_EQ ( CountIter ( iter_all , " gpk " ) , 0 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 17 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 4 ) ;
// FIXME? isn't seek key out of SST range?
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?
}
@ -3016,13 +3048,13 @@ TEST_F(DBBloomFilterTest, DynamicBloomFilterOptions) {
{
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
ASSERT_EQ ( CountIter ( iter , " foo " ) , 12 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 3 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) , 3 ) ;
}
std : : unique_ptr < Iterator > iter_old ( db_ - > NewIterator ( read_options ) ) ;
ASSERT_EQ ( CountIter ( iter_old , " foo " ) , 12 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 6 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) , 3 ) ;
ASSERT_OK ( dbfull ( ) - > SetOptions ( { { " prefix_extractor " , " capped:3 " } } ) ) ;
ASSERT_EQ ( dbfull ( ) - > GetOptions ( ) . prefix_extractor - > AsString ( ) ,
@ -3031,17 +3063,18 @@ TEST_F(DBBloomFilterTest, DynamicBloomFilterOptions) {
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
// "fp*" should be skipped
ASSERT_EQ ( CountIter ( iter , " foo " ) , 9 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 6 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) , 0 ) ;
}
// iterator created before should not be affected and see all keys
ASSERT_EQ ( CountIter ( iter_old , " foo " ) , 12 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 9 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTERED ) , 0 ) ;
EXPECT_EQ ( PopTicker ( options , NON_LAST_LEVEL_SEEK_FILTER_MATCH ) , 3 ) ;
ASSERT_EQ ( CountIter ( iter_old , " abc " ) , 0 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_CHECKED ) , 12 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , BLOOM_FILTER_PREFIX_USEFUL ) , 3 ) ;
// FIXME? isn't seek key out of SST range?
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 ) {
if ( sst ) {
return {
options . statistics - > getAndResetTickerCount ( BLOOM_FILTER_PREFIX_CHECKED ) ,
options . statistics - > getAndResetTickerCount ( BLOOM_FILTER_PREFIX_USEFUL ) } ;
return { options . statistics - > getAndResetTickerCount (
NON_LAST_LEVEL_SEEK_FILTER_MATCH ) ,
options . statistics - > getAndResetTickerCount (
NON_LAST_LEVEL_SEEK_FILTERED ) } ;
} else {
auto hit = std : : exchange ( get_perf_context ( ) - > bloom_memtable_hit_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 ,
uint64_t useful ) {
return { checked , useful } ;
std : : pair < uint64_t , uint64_t > HitAndMiss ( uint64_t hits , uint64_t misses ) {
return { hits , misses } ;
}
} // anonymous namespace
@ -3186,27 +3219,27 @@ TEST_F(DBBloomFilterTest, WeirdPrefixExtractorWithFilter1) {
if ( flushed ) { // TODO: support auto_prefix_mode in memtable?
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 " ) ;
read_options . iterate_upper_bound = & ub ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
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 " ) ;
read_options . iterate_upper_bound = & ub ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
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 " ) ;
read_options . iterate_upper_bound = & ub ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
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 " ) ;
@ -3214,7 +3247,7 @@ TEST_F(DBBloomFilterTest, WeirdPrefixExtractorWithFilter1) {
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
EXPECT_EQ ( CountIter ( iter , " baa " ) , 3 ) ;
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_miss_count = 0 ;
}
EXPECT_EQ ( GetBloomStat ( options , flushed ) , CheckedAndUseful ( 0 , 0 ) ) ;
EXPECT_EQ ( GetBloomStat ( options , flushed ) , HitAndMiss ( 0 , 0 ) ) ;
{
Slice ub ( " aaaa000 " ) ;
read_options . iterate_upper_bound = & ub ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
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
@ -3274,7 +3307,7 @@ TEST_F(DBBloomFilterTest, WeirdPrefixExtractorWithFilter2) {
read_options . iterate_upper_bound = & ub ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
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
@ -3282,28 +3315,28 @@ TEST_F(DBBloomFilterTest, WeirdPrefixExtractorWithFilter2) {
read_options . iterate_upper_bound = & ub ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
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 " ) ;
read_options . iterate_upper_bound = & ub ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
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 " ) ;
read_options . iterate_upper_bound = & ub ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
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 " ) ;
read_options . iterate_upper_bound = & ub ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
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
@ -3313,7 +3346,7 @@ TEST_F(DBBloomFilterTest, WeirdPrefixExtractorWithFilter2) {
read_options . prefix_same_as_start = true ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
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_miss_count = 0 ;
}
EXPECT_EQ ( GetBloomStat ( options , flushed ) , CheckedAndUseful ( 0 , 0 ) ) ;
EXPECT_EQ ( GetBloomStat ( options , flushed ) , HitAndMiss ( 0 , 0 ) ) ;
{
Slice ub ( " aaaa999 " ) ;
read_options . iterate_upper_bound = & ub ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
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
@ -3420,28 +3453,28 @@ TEST_F(DBBloomFilterTest, WeirdPrefixExtractorWithFilter3) {
read_options . iterate_upper_bound = & ub ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
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 " ) ;
read_options . iterate_upper_bound = & ub ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
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 " ) ;
read_options . iterate_upper_bound = & ub ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
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 " ) ;
read_options . iterate_upper_bound = & ub ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
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
@ -3449,7 +3482,7 @@ TEST_F(DBBloomFilterTest, WeirdPrefixExtractorWithFilter3) {
read_options . iterate_upper_bound = & ub ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
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
@ -3457,14 +3490,14 @@ TEST_F(DBBloomFilterTest, WeirdPrefixExtractorWithFilter3) {
read_options . iterate_upper_bound = & ub ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
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 " ) ;
read_options . iterate_upper_bound = & ub ;
std : : unique_ptr < Iterator > iter ( db_ - > NewIterator ( read_options ) ) ;
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 ) ) ;
}
}
}