Skip to content

Commit 3bedd21

Browse files
committed
Add pluggable compression
1 parent e267425 commit 3bedd21

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1169
-153
lines changed

db/blob/blob_file_builder.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ BlobFileBuilder::BlobFileBuilder(
6666
immutable_options_(immutable_options),
6767
min_blob_size_(mutable_cf_options->min_blob_size),
6868
blob_file_size_(mutable_cf_options->blob_file_size),
69-
blob_compressor_(mutable_cf_options->blob_compressor),
69+
blob_compressor_(mutable_cf_options->derived_blob_compressor),
7070
prepopulate_blob_cache_(mutable_cf_options->prepopulate_blob_cache),
7171
file_options_(file_options),
7272
write_options_(write_options),

db/blob/blob_file_builder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212

1313
#include "rocksdb/advanced_options.h"
1414
#include "rocksdb/compression_type.h"
15+
#include "rocksdb/compressor.h"
1516
#include "rocksdb/env.h"
1617
#include "rocksdb/options.h"
1718
#include "rocksdb/rocksdb_namespace.h"
1819
#include "rocksdb/types.h"
19-
#include "util/compressor.h"
2020

2121
namespace ROCKSDB_NAMESPACE {
2222

db/blob/blob_file_reader.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include "rocksdb/compression_type.h"
1414
#include "rocksdb/rocksdb_namespace.h"
1515
#include "util/autovector.h"
16-
#include "util/compressor.h"
1716

1817
namespace ROCKSDB_NAMESPACE {
1918

db/blob/blob_read_request.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
#include <cinttypes>
99

1010
#include "rocksdb/compression_type.h"
11+
#include "rocksdb/compressor.h"
1112
#include "rocksdb/slice.h"
1213
#include "rocksdb/status.h"
1314
#include "util/autovector.h"
14-
#include "util/compressor.h"
1515

1616
namespace ROCKSDB_NAMESPACE {
1717

db/blob/blob_source.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
#include "db/blob/blob_file_cache.h"
1515
#include "db/blob/blob_read_request.h"
1616
#include "rocksdb/cache.h"
17+
#include "rocksdb/compressor.h"
1718
#include "rocksdb/rocksdb_namespace.h"
1819
#include "table/block_based/cachable_entry.h"
1920
#include "util/autovector.h"
20-
#include "util/compressor.h"
2121

2222
namespace ROCKSDB_NAMESPACE {
2323

db/column_family.cc

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -113,17 +113,18 @@ void GetIntTblPropCollectorFactory(
113113
Status CheckCompressionSupported(const ColumnFamilyOptions& cf_options) {
114114
MutableCFOptions moptions(cf_options);
115115
ImmutableCFOptions ioptions(cf_options);
116-
if (moptions.compressor && !moptions.compressor->Supported()) {
116+
if (moptions.derived_compressor &&
117+
!moptions.derived_compressor->Supported()) {
117118
return Status::InvalidArgument("Compression type " +
118-
moptions.compressor->GetId() +
119+
moptions.derived_compressor->GetId() +
119120
" is not linked with the binary.");
120-
} else if (moptions.bottommost_compressor &&
121-
!moptions.bottommost_compressor->Supported()) {
122-
return Status::InvalidArgument("Compression type " +
123-
moptions.bottommost_compressor->GetId() +
124-
" is not linked with the binary.");
125-
} else if (!moptions.compressor_per_level.empty()) {
126-
for (const auto& compressor : moptions.compressor_per_level) {
121+
} else if (moptions.derived_bottommost_compressor &&
122+
!moptions.derived_bottommost_compressor->Supported()) {
123+
return Status::InvalidArgument(
124+
"Compression type " + moptions.derived_bottommost_compressor->GetId() +
125+
" is not linked with the binary.");
126+
} else if (!moptions.derived_compressor_per_level.empty()) {
127+
for (const auto& compressor : moptions.derived_compressor_per_level) {
127128
if (compressor == nullptr) {
128129
return Status::InvalidArgument("Compression type is invalid.");
129130
} else if (!compressor->Supported()) {
@@ -153,9 +154,10 @@ Status CheckCompressionSupported(const ColumnFamilyOptions& cf_options) {
153154
"should be nonzero if we're using zstd's dictionary generator.");
154155
}
155156
}
156-
if (moptions.blob_compressor && !moptions.blob_compressor->Supported()) {
157+
if (moptions.derived_blob_compressor &&
158+
!moptions.derived_blob_compressor->Supported()) {
157159
return Status::InvalidArgument("Blob compression type " +
158-
moptions.blob_compressor->GetId() +
160+
moptions.derived_blob_compressor->GetId() +
159161
" is not linked with the binary.");
160162
}
161163
return Status::OK();

db/compact_files_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111

1212
#include "db/db_impl/db_impl.h"
1313
#include "port/port.h"
14+
#include "rocksdb/compressor.h"
1415
#include "rocksdb/db.h"
1516
#include "rocksdb/env.h"
1617
#include "test_util/sync_point.h"
1718
#include "test_util/testharness.h"
1819
#include "util/cast_util.h"
19-
#include "util/compressor.h"
2020
#include "util/string_util.h"
2121

2222
namespace ROCKSDB_NAMESPACE {

db/compaction/compaction_picker.cc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,12 @@ std::shared_ptr<Compressor> GetCompressor(const VersionStorageInfo* vstorage,
8787
// If bottommost_compression is set and we are compacting to the
8888
// bottommost level then we should use it.
8989
bool bottom_level = (level >= (vstorage->num_non_empty_levels() - 1));
90-
if (moptions.bottommost_compressor != nullptr && bottom_level) {
91-
return moptions.bottommost_compressor;
90+
if (moptions.derived_bottommost_compressor != nullptr && bottom_level) {
91+
return moptions.derived_bottommost_compressor;
9292
}
9393
// If the user has specified a different compression level for each level,
9494
// then pick the compression for that level.
95-
if (!moptions.compressor_per_level.empty()) {
95+
if (!moptions.derived_compressor_per_level.empty()) {
9696
// It is possible for level_ to be -1; in that case, we use level
9797
// 0's compression. This occurs mostly in backwards compatibility
9898
// situations when the builder doesn't know what level the file
@@ -101,7 +101,8 @@ std::shared_ptr<Compressor> GetCompressor(const VersionStorageInfo* vstorage,
101101
assert(level == 0 || level >= base_level);
102102
int lvl = std::max(0, level - base_level + 1);
103103
int idx = std::min(
104-
static_cast<int>(moptions.compressor_per_level.size()) - 1, lvl);
104+
static_cast<int>(moptions.derived_compressor_per_level.size()) - 1,
105+
lvl);
105106
// If not specified directly by the user, compressors in
106107
// compressor_per_level are instantiated using compression_opts. If the user
107108
// enabled bottommost_compression_opts, we need to create a new compressor
@@ -112,10 +113,10 @@ std::shared_ptr<Compressor> GetCompressor(const VersionStorageInfo* vstorage,
112113
moptions.compression_per_level[idx],
113114
moptions.bottommost_compression_opts);
114115
} else {
115-
return moptions.compressor_per_level[idx];
116+
return moptions.derived_compressor_per_level[idx];
116117
}
117118
} else {
118-
return moptions.compressor;
119+
return moptions.derived_compressor;
119120
}
120121
}
121122

db/compaction/compaction_picker_fifo.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ Compaction* FIFOCompactionPicker::PickSizeCompaction(
184184
vstorage, ioptions_, mutable_cf_options, mutable_db_options,
185185
{comp_inputs}, 0, 16 * 1024 * 1024 /* output file size limit */,
186186
0 /* max compaction bytes, not applicable */,
187-
0 /* output path ID */, mutable_cf_options.compressor,
187+
0 /* output path ID */, mutable_cf_options.derived_compressor,
188188
Temperature::kUnknown, 0 /* max_subcompactions */, {},
189189
/* is manual */ false, /* trim_ts */ "",
190190
vstorage->CompactionScore(0),
@@ -419,7 +419,7 @@ Compaction* FIFOCompactionPicker::PickTemperatureChangeCompaction(
419419
vstorage, ioptions_, mutable_cf_options, mutable_db_options,
420420
std::move(inputs), 0, 0 /* output file size limit */,
421421
0 /* max compaction bytes, not applicable */, 0 /* output path ID */,
422-
mutable_cf_options.compressor, compaction_target_temp,
422+
mutable_cf_options.derived_compressor, compaction_target_temp,
423423
/* max_subcompactions */ 0, {}, /* is manual */ false, /* trim_ts */ "",
424424
vstorage->CompactionScore(0),
425425
/* is deletion compaction */ false, /* l0_files_might_overlap */ true,

db/db_basic_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "db/db_test_util.h"
1313
#include "options/options_helper.h"
1414
#include "port/stack_trace.h"
15+
#include "rocksdb/compressor.h"
1516
#include "rocksdb/filter_policy.h"
1617
#include "rocksdb/flush_block_policy.h"
1718
#include "rocksdb/merge_operator.h"
@@ -21,7 +22,6 @@
2122
#include "table/block_based/block_based_table_reader.h"
2223
#include "table/block_based/block_builder.h"
2324
#include "test_util/sync_point.h"
24-
#include "util/compressor.h"
2525
#include "util/file_checksum_helper.h"
2626
#include "util/random.h"
2727
#include "utilities/counted_fs.h"

0 commit comments

Comments
 (0)