From dd19014a7ac3358e1cb89180225039da88b39ea2 Mon Sep 17 00:00:00 2001 From: Peter Dillinger Date: Thu, 24 Oct 2019 13:18:48 -0700 Subject: [PATCH] FilterPolicy consolidation, part 1/2 (#5963) Summary: The parts that are used to implement FilterPolicy / NewBloomFilterPolicy and not used other than for the block-based table should be consolidated under table/block_based/filter_policy*. I don't foresee sharing these APIs with e.g. the Plain Table because they don't expose hashes for reuse in indexing. This change is step 1 of 2: (a) mv table/full_filter_bits_builder.h to table/block_based/filter_policy_internal.h which I expect to expand soon to internally reveal more implementation details for testing. (b) consolidate eventual contents of table/block_based/filter_policy.cc in util/bloom.cc, which has the most elaborate revision history (see step 2 ...) Step 2 soon to follow: mv util/bloom.cc table/block_based/filter_policy.cc This gets its own PR so that git has the best chance of following the rename for blame purposes. Note that low-level shared implementation details of Bloom filters are in util/bloom_impl.h. Pull Request resolved: https://github.com/facebook/rocksdb/pull/5963 Test Plan: make check Differential Revision: D18121199 Pulled By: pdillinger fbshipit-source-id: 8f21732c3d8909777e3240e4ac3123d73140326a --- CMakeLists.txt | 1 - TARGETS | 1 - src.mk | 1 - .../filter_policy_internal.h} | 0 table/block_based/full_filter_block_test.cc | 2 +- .../block_based/partitioned_filter_block_test.cc | 2 +- util/bloom.cc | 4 +++- util/bloom_test.cc | 2 +- util/filter_policy.cc | 16 ---------------- 9 files changed, 6 insertions(+), 23 deletions(-) rename table/{full_filter_bits_builder.h => block_based/filter_policy_internal.h} (100%) delete mode 100644 util/filter_policy.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index 16b3cafc8..ff09290f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -646,7 +646,6 @@ set(SOURCES util/concurrent_task_limiter_impl.cc util/crc32c.cc util/dynamic_bloom.cc - util/filter_policy.cc util/hash.cc util/murmurhash.cc util/random.cc diff --git a/TARGETS b/TARGETS index 1934f1764..68d645a3d 100644 --- a/TARGETS +++ b/TARGETS @@ -274,7 +274,6 @@ cpp_library( "util/concurrent_task_limiter_impl.cc", "util/crc32c.cc", "util/dynamic_bloom.cc", - "util/filter_policy.cc", "util/hash.cc", "util/murmurhash.cc", "util/random.cc", diff --git a/src.mk b/src.mk index 560f06202..85fd83c24 100644 --- a/src.mk +++ b/src.mk @@ -166,7 +166,6 @@ LIB_SOURCES = \ util/concurrent_task_limiter_impl.cc \ util/crc32c.cc \ util/dynamic_bloom.cc \ - util/filter_policy.cc \ util/hash.cc \ util/murmurhash.cc \ util/random.cc \ diff --git a/table/full_filter_bits_builder.h b/table/block_based/filter_policy_internal.h similarity index 100% rename from table/full_filter_bits_builder.h rename to table/block_based/filter_policy_internal.h diff --git a/table/block_based/full_filter_block_test.cc b/table/block_based/full_filter_block_test.cc index 28b2cefaa..0f6a5cdab 100644 --- a/table/block_based/full_filter_block_test.cc +++ b/table/block_based/full_filter_block_test.cc @@ -7,7 +7,7 @@ #include "rocksdb/filter_policy.h" #include "table/block_based/block_based_table_reader.h" #include "table/block_based/mock_block_based_table.h" -#include "table/full_filter_bits_builder.h" +#include "table/block_based/filter_policy_internal.h" #include "test_util/testharness.h" #include "test_util/testutil.h" #include "util/coding.h" diff --git a/table/block_based/partitioned_filter_block_test.cc b/table/block_based/partitioned_filter_block_test.cc index ee93262ad..21583f3e0 100644 --- a/table/block_based/partitioned_filter_block_test.cc +++ b/table/block_based/partitioned_filter_block_test.cc @@ -9,7 +9,7 @@ #include "table/block_based/block_based_table_reader.h" #include "table/block_based/partitioned_filter_block.h" -#include "table/full_filter_bits_builder.h" +#include "table/block_based/filter_policy_internal.h" #include "index_builder.h" #include "logging/logging.h" diff --git a/util/bloom.cc b/util/bloom.cc index 59c9351f5..5eef86be2 100644 --- a/util/bloom.cc +++ b/util/bloom.cc @@ -12,7 +12,7 @@ #include "rocksdb/slice.h" #include "table/block_based/block_based_filter_block.h" #include "table/block_based/full_filter_block.h" -#include "table/full_filter_bits_builder.h" +#include "table/block_based/filter_policy_internal.h" #include "third-party/folly/folly/ConstexprMath.h" #include "util/bloom_impl.h" #include "util/coding.h" @@ -340,4 +340,6 @@ const FilterPolicy* NewBloomFilterPolicy(int bits_per_key, return new BloomFilterPolicy(bits_per_key, use_block_based_builder); } +FilterPolicy::~FilterPolicy() { } + } // namespace rocksdb diff --git a/util/bloom_test.cc b/util/bloom_test.cc index bcea94ef8..76a0541c8 100644 --- a/util/bloom_test.cc +++ b/util/bloom_test.cc @@ -21,7 +21,7 @@ int main() { #include "logging/logging.h" #include "memory/arena.h" #include "rocksdb/filter_policy.h" -#include "table/full_filter_bits_builder.h" +#include "table/block_based/filter_policy_internal.h" #include "test_util/testharness.h" #include "test_util/testutil.h" #include "util/gflags_compat.h" diff --git a/util/filter_policy.cc b/util/filter_policy.cc deleted file mode 100644 index efb9bf476..000000000 --- a/util/filter_policy.cc +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) 2011-present, Facebook, Inc. All rights reserved. -// This source code is licensed under both the GPLv2 (found in the -// COPYING file in the root directory) and Apache 2.0 License -// (found in the LICENSE.Apache file in the root directory). -// -// Copyright (c) 2012 The LevelDB Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. See the AUTHORS file for names of contributors. - -#include "rocksdb/filter_policy.h" - -namespace rocksdb { - -FilterPolicy::~FilterPolicy() { } - -} // namespace rocksdb