Skip to content

Commit 4c89ff1

Browse files
hx235meta-codesync[bot]
authored andcommitted
Remove deprecated SstFileWriter::Add() and skip_filters parameter (#14352)
Summary: **Context/Summary:** Remove `SstFileWriter::Add()` (deprecated in favor of `Put()`) and the `skip_filters` parameter from `SstFileWriter` constructors (deprecated in favor of setting `BlockBasedTableOptions::filter_policy` to `nullptr`). Both APIs have zero active callers. The `skip_filters` field is also removed from `TableBuilderOptions` (write-side only; the read-side `TableReaderOptions::skip_filters` is unchanged). Pull Request resolved: #14352 Test Plan: make check Reviewed By: xingbowang Differential Revision: D93812389 Pulled By: hx235 fbshipit-source-id: 236b36a6e664758ab5ad90e606bc195d0a6de70f
1 parent f1a6759 commit 4c89ff1

File tree

6 files changed

+16
-37
lines changed

6 files changed

+16
-37
lines changed

db/external_sst_file_test.cc

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2569,14 +2569,19 @@ TEST_F(ExternalSSTFileTest, SkipBloomFilter) {
25692569
options.statistics->getTickerCount(Tickers::BLOCK_CACHE_FILTER_ADD), 1);
25702570
}
25712571

2572-
// Create external SST file but skip bloom filters
2572+
// Create external SST file but skip bloom filters by using options
2573+
// with no filter policy
25732574
options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
25742575
DestroyAndReopen(options);
25752576
{
25762577
std::string file_path = sst_files_dir_ + "sst_with_no_bloom.sst";
2577-
SstFileWriter sst_file_writer(EnvOptions(), options, nullptr, true,
2578-
Env::IOPriority::IO_TOTAL,
2579-
true /* skip_filters */);
2578+
// Use options with no filter policy to skip bloom filters
2579+
Options no_filter_options = options;
2580+
BlockBasedTableOptions no_filter_table_options = table_options;
2581+
no_filter_table_options.filter_policy.reset();
2582+
no_filter_options.table_factory.reset(
2583+
NewBlockBasedTableFactory(no_filter_table_options));
2584+
SstFileWriter sst_file_writer(EnvOptions(), no_filter_options);
25802585
ASSERT_OK(sst_file_writer.Open(file_path));
25812586
ASSERT_OK(sst_file_writer.Put("Key1", "Value1"));
25822587
ASSERT_OK(sst_file_writer.Finish());

include/rocksdb/sst_file_writer.h

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -82,37 +82,26 @@ class SstFileWriter {
8282
// hint that this file pages is not needed every time we write 1MB to the
8383
// file. To use the rate limiter an io_priority smaller than IO_TOTAL can be
8484
// passed.
85-
// The `skip_filters` option is DEPRECATED and could be removed in the
86-
// future. Use `BlockBasedTableOptions::filter_policy` to control filter
87-
// generation.
8885
SstFileWriter(const EnvOptions& env_options, const Options& options,
8986
ColumnFamilyHandle* column_family = nullptr,
9087
bool invalidate_page_cache = true,
91-
Env::IOPriority io_priority = Env::IOPriority::IO_TOTAL,
92-
bool skip_filters = false)
88+
Env::IOPriority io_priority = Env::IOPriority::IO_TOTAL)
9389
: SstFileWriter(env_options, options, options.comparator, column_family,
94-
invalidate_page_cache, io_priority, skip_filters) {}
90+
invalidate_page_cache, io_priority) {}
9591

9692
// Deprecated API
9793
SstFileWriter(const EnvOptions& env_options, const Options& options,
9894
const Comparator* user_comparator,
9995
ColumnFamilyHandle* column_family = nullptr,
10096
bool invalidate_page_cache = true,
101-
Env::IOPriority io_priority = Env::IOPriority::IO_TOTAL,
102-
bool skip_filters = false);
97+
Env::IOPriority io_priority = Env::IOPriority::IO_TOTAL);
10398

10499
~SstFileWriter();
105100

106101
// Prepare SstFileWriter to write into file located at "file_path".
107102
Status Open(const std::string& file_path,
108103
Temperature temp = Temperature::kUnknown);
109104

110-
// Add a Put key with value to currently opened file (deprecated)
111-
// REQUIRES: user_key is after any previously added point (Put/Merge/Delete)
112-
// key according to the comparator.
113-
// REQUIRES: comparator is *not* timestamp-aware.
114-
[[deprecated]] Status Add(const Slice& user_key, const Slice& value);
115-
116105
// Add a Put key with value to currently opened file
117106
// REQUIRES: user_key is after any previously added point (Put/Merge/Delete)
118107
// key according to the comparator.

table/block_based/block_based_table_builder.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,9 +1269,6 @@ struct BlockBasedTableBuilder::Rep {
12691269
// Apply optimize_filters_for_hits setting here when applicable by
12701270
// skipping filter generation
12711271
filter_builder.reset();
1272-
} else if (tbo.skip_filters) {
1273-
// For SstFileWriter skip_filters
1274-
filter_builder.reset();
12751272
} else if (!table_options.filter_policy) {
12761273
// Null filter_policy -> no filter
12771274
filter_builder.reset();

table/sst_file_writer.cc

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const size_t kFadviseTrigger = 1024 * 1024; // 1MB
3030
struct SstFileWriter::Rep {
3131
Rep(const EnvOptions& _env_options, const Options& options,
3232
Env::IOPriority _io_priority, const Comparator* _user_comparator,
33-
ColumnFamilyHandle* _cfh, bool _invalidate_page_cache, bool _skip_filters,
33+
ColumnFamilyHandle* _cfh, bool _invalidate_page_cache,
3434
std::string _db_session_id)
3535
: env_options(_env_options),
3636
ioptions(options),
@@ -39,7 +39,6 @@ struct SstFileWriter::Rep {
3939
internal_comparator(_user_comparator),
4040
cfh(_cfh),
4141
invalidate_page_cache(_invalidate_page_cache),
42-
skip_filters(_skip_filters),
4342
db_session_id(_db_session_id),
4443
ts_sz(_user_comparator->timestamp_size()),
4544
strip_timestamp(ts_sz > 0 &&
@@ -67,7 +66,6 @@ struct SstFileWriter::Rep {
6766
// The size of the file during the last time we called Fadvise to remove
6867
// cached pages from page cache.
6968
uint64_t last_fadvise_size = 0;
70-
bool skip_filters;
7169
std::string db_session_id;
7270
uint64_t next_file_number = 1;
7371
size_t ts_sz;
@@ -305,9 +303,9 @@ SstFileWriter::SstFileWriter(const EnvOptions& env_options,
305303
const Comparator* user_comparator,
306304
ColumnFamilyHandle* column_family,
307305
bool invalidate_page_cache,
308-
Env::IOPriority io_priority, bool skip_filters)
306+
Env::IOPriority io_priority)
309307
: rep_(new Rep(env_options, options, io_priority, user_comparator,
310-
column_family, invalidate_page_cache, skip_filters,
308+
column_family, invalidate_page_cache,
311309
DBImpl::GenerateDbSessionId(options.env))) {
312310
// SstFileWriter is used to create sst files that can be added to database
313311
// later. Therefore, no real db_id and db_session_id are associated with it.
@@ -403,9 +401,6 @@ Status SstFileWriter::Open(const std::string& file_path, Temperature temp) {
403401
// assign fake file numbers to each file (into table properties) and keep
404402
// the same session id for the life of the SstFileWriter.
405403
r->next_file_number++;
406-
// XXX: when we can remove skip_filters from the SstFileWriter public API
407-
// we can remove it from TableBuilderOptions.
408-
table_builder_options.skip_filters = r->skip_filters;
409404
FileTypeSet tmp_set = r->ioptions.checksum_handoff_file_types;
410405
r->file_writer.reset(new WritableFileWriter(
411406
std::move(sst_file), file_path, r->env_options, r->ioptions.clock,
@@ -424,10 +419,6 @@ Status SstFileWriter::Open(const std::string& file_path, Temperature temp) {
424419
return s;
425420
}
426421

427-
Status SstFileWriter::Add(const Slice& user_key, const Slice& value) {
428-
return rep_->Add(user_key, value, ValueType::kTypeValue);
429-
}
430-
431422
Status SstFileWriter::Put(const Slice& user_key, const Slice& value) {
432423
return rep_->Add(user_key, value, ValueType::kTypeValue);
433424
}

table/table_builder.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,6 @@ struct TableBuilderOptions : public TablePropertiesCollectorFactory::Context {
164164
const TableFileCreationReason reason;
165165
// END for FilterBuildingContext
166166

167-
// XXX: only used by BlockBasedTableBuilder for SstFileWriter. If you
168-
// want to skip filters, that should be (for example) null filter_policy
169-
// in the table options of the ioptions.table_factory
170-
bool skip_filters = false;
171167
const uint64_t cur_file_num;
172168
};
173169

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove deprecated `SstFileWriter::Add()` method (use `Put()` instead) and the deprecated `skip_filters` parameter from `SstFileWriter` constructors (use `BlockBasedTableOptions::filter_policy` set to `nullptr` to skip filter generation instead).

0 commit comments

Comments
 (0)