Skip to content

Commit af14652

Browse files
committed
Upgrade rocksdb
Signed-off-by: Yang Zhang <[email protected]>
1 parent 224bed6 commit af14652

File tree

14 files changed

+369
-492
lines changed

14 files changed

+369
-492
lines changed

.gitmodules

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[submodule "rocksdb"]
22
path = librocksdb_sys/rocksdb
3-
url = https://github.com/tikv/rocksdb.git
4-
branch = 6.29.tikv
3+
url = https://github.com/v01dstar/rocksdb.git
4+
branch = 8.10-tikv
55

66
[submodule "titan"]
77
path = librocksdb_sys/libtitan_sys/titan
8-
url = https://github.com/tikv/titan.git
9-
branch = master
8+
url = https://github.com/v01dstar/titan.git
9+
branch = upgrade-rocksdb

librocksdb_sys/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ fn main() {
7676

7777
build.cpp(true).file("crocksdb/c.cc");
7878
if env::var("CARGO_CFG_TARGET_OS").unwrap() != "windows" {
79-
build.flag("-std=c++11");
79+
build.flag("-std=c++17");
8080
build.flag("-fno-rtti");
8181
}
8282
link_cpp(&mut build);

librocksdb_sys/crocksdb/c.cc

Lines changed: 19 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
#include "rocksdb/table_properties.h"
4949
#include "rocksdb/types.h"
5050
#include "rocksdb/universal_compaction.h"
51-
#include "rocksdb/utilities/backupable_db.h"
51+
#include "rocksdb/utilities/backup_engine.h"
5252
#include "rocksdb/utilities/checkpoint.h"
5353
#include "rocksdb/utilities/db_ttl.h"
5454
#include "rocksdb/utilities/debug.h"
@@ -75,8 +75,8 @@
7575
#endif
7676

7777
using rocksdb::BackgroundErrorReason;
78-
using rocksdb::BackupableDBOptions;
7978
using rocksdb::BackupEngine;
79+
using rocksdb::BackupEngineOptions;
8080
using rocksdb::BackupInfo;
8181
using rocksdb::BlockBasedTableOptions;
8282
using rocksdb::BlockCipher;
@@ -524,41 +524,10 @@ struct crocksdb_filterpolicy_t : public FilterPolicy {
524524
void* state_;
525525
void (*destructor_)(void*);
526526
const char* (*name_)(void*);
527-
char* (*create_)(void*, const char* const* key_array,
528-
const size_t* key_length_array, int num_keys,
529-
size_t* filter_length);
530-
unsigned char (*key_match_)(void*, const char* key, size_t length,
531-
const char* filter, size_t filter_length);
532-
void (*delete_filter_)(void*, const char* filter, size_t filter_length);
533527

534528
virtual ~crocksdb_filterpolicy_t() { (*destructor_)(state_); }
535529

536530
virtual const char* Name() const override { return (*name_)(state_); }
537-
538-
virtual void CreateFilter(const Slice* keys, int n,
539-
std::string* dst) const override {
540-
std::vector<const char*> key_pointers(n);
541-
std::vector<size_t> key_sizes(n);
542-
for (int i = 0; i < n; i++) {
543-
key_pointers[i] = keys[i].data();
544-
key_sizes[i] = keys[i].size();
545-
}
546-
size_t len;
547-
char* filter = (*create_)(state_, &key_pointers[0], &key_sizes[0], n, &len);
548-
dst->append(filter, len);
549-
550-
if (delete_filter_ != nullptr) {
551-
(*delete_filter_)(state_, filter, len);
552-
} else {
553-
free(filter);
554-
}
555-
}
556-
557-
virtual bool KeyMayMatch(const Slice& key,
558-
const Slice& filter) const override {
559-
return (*key_match_)(state_, key.data(), key.size(), filter.data(),
560-
filter.size());
561-
}
562531
};
563532

564533
struct crocksdb_mergeoperator_t : public MergeOperator {
@@ -853,7 +822,7 @@ crocksdb_backup_engine_t* crocksdb_backup_engine_open(
853822
const crocksdb_options_t* options, const char* path, char** errptr) {
854823
BackupEngine* be;
855824
if (SaveError(errptr, BackupEngine::Open(options->rep.env,
856-
BackupableDBOptions(path), &be))) {
825+
BackupEngineOptions(path), &be))) {
857826
return nullptr;
858827
}
859828
crocksdb_backup_engine_t* result = new crocksdb_backup_engine_t;
@@ -1189,7 +1158,8 @@ void crocksdb_write_multi_batch(crocksdb_t* db,
11891158
for (size_t i = 0; i < batch_size; i++) {
11901159
ws.push_back(&batches[i]->rep);
11911160
}
1192-
SaveError(errptr, db->rep->MultiBatchWrite(options->rep, std::move(ws)));
1161+
SaveError(errptr,
1162+
db->rep->MultiBatchWrite(options->rep, std::move(ws), nullptr));
11931163
}
11941164

11951165
void crocksdb_write_multi_batch_callback(
@@ -2097,14 +2067,6 @@ void crocksdb_block_based_options_set_block_cache(
20972067
}
20982068
}
20992069

2100-
void crocksdb_block_based_options_set_block_cache_compressed(
2101-
crocksdb_block_based_table_options_t* options,
2102-
crocksdb_cache_t* block_cache_compressed) {
2103-
if (block_cache_compressed) {
2104-
options->rep.block_cache_compressed = block_cache_compressed->rep;
2105-
}
2106-
}
2107-
21082070
void crocksdb_block_based_options_set_whole_key_filtering(
21092071
crocksdb_block_based_table_options_t* options, unsigned char v) {
21102072
options->rep.whole_key_filtering = v;
@@ -2120,11 +2082,6 @@ void crocksdb_block_based_options_set_index_type(
21202082
options->rep.index_type = static_cast<BlockBasedTableOptions::IndexType>(v);
21212083
}
21222084

2123-
void crocksdb_block_based_options_set_hash_index_allow_collision(
2124-
crocksdb_block_based_table_options_t* options, unsigned char v) {
2125-
options->rep.hash_index_allow_collision = v;
2126-
}
2127-
21282085
void crocksdb_block_based_options_set_optimize_filters_for_memory(
21292086
crocksdb_block_based_table_options_t* options, unsigned char v) {
21302087
options->rep.optimize_filters_for_memory = v;
@@ -3068,11 +3025,6 @@ void crocksdb_options_set_is_fd_close_on_exec(crocksdb_options_t* opt,
30683025
opt->rep.is_fd_close_on_exec = v;
30693026
}
30703027

3071-
void crocksdb_options_set_skip_log_error_on_recovery(crocksdb_options_t* opt,
3072-
unsigned char v) {
3073-
opt->rep.skip_log_error_on_recovery = v;
3074-
}
3075-
30763028
void crocksdb_options_set_stats_dump_period_sec(crocksdb_options_t* opt,
30773029
unsigned int v) {
30783030
opt->rep.stats_dump_period_sec = v;
@@ -3197,16 +3149,6 @@ int crocksdb_options_get_max_background_compactions(
31973149
return opt->rep.max_background_compactions;
31983150
}
31993151

3200-
void crocksdb_options_set_base_background_compactions(crocksdb_options_t* opt,
3201-
int n) {
3202-
opt->rep.base_background_compactions = n;
3203-
}
3204-
3205-
int crocksdb_options_get_base_background_compactions(
3206-
const crocksdb_options_t* opt) {
3207-
return opt->rep.base_background_compactions;
3208-
}
3209-
32103152
void crocksdb_options_set_max_background_flushes(crocksdb_options_t* opt,
32113153
int n) {
32123154
opt->rep.max_background_flushes = n;
@@ -3234,14 +3176,6 @@ void crocksdb_options_set_recycle_log_file_num(crocksdb_options_t* opt,
32343176
opt->rep.recycle_log_file_num = v;
32353177
}
32363178

3237-
void crocksdb_options_set_soft_rate_limit(crocksdb_options_t* opt, double v) {
3238-
opt->rep.soft_rate_limit = v;
3239-
}
3240-
3241-
void crocksdb_options_set_hard_rate_limit(crocksdb_options_t* opt, double v) {
3242-
opt->rep.hard_rate_limit = v;
3243-
}
3244-
32453179
void crocksdb_options_set_soft_pending_compaction_bytes_limit(
32463180
crocksdb_options_t* opt, size_t v) {
32473181
opt->rep.soft_pending_compaction_bytes_limit = v;
@@ -3262,11 +3196,6 @@ size_t crocksdb_options_get_hard_pending_compaction_bytes_limit(
32623196
return opt->rep.hard_pending_compaction_bytes_limit;
32633197
}
32643198

3265-
void crocksdb_options_set_rate_limit_delay_max_milliseconds(
3266-
crocksdb_options_t* opt, unsigned int v) {
3267-
opt->rep.rate_limit_delay_max_milliseconds = v;
3268-
}
3269-
32703199
void crocksdb_options_set_max_manifest_file_size(crocksdb_options_t* opt,
32713200
size_t v) {
32723201
opt->rep.max_manifest_file_size = v;
@@ -3609,12 +3538,14 @@ void crocksdb_options_set_track_and_verify_wals_in_manifest(
36093538
}
36103539

36113540
unsigned char crocksdb_load_latest_options(
3612-
const char* dbpath, crocksdb_env_t* env, crocksdb_options_t* db_options,
3541+
const char* dbpath, crocksdb_options_t* db_options,
36133542
crocksdb_column_family_descriptor*** cf_descs, size_t* cf_descs_len,
36143543
unsigned char ignore_unknown_options, char** errptr) {
36153544
std::vector<ColumnFamilyDescriptor> tmp_cf_descs;
3616-
Status s = rocksdb::LoadLatestOptions(dbpath, env->rep, &db_options->rep,
3617-
&tmp_cf_descs, ignore_unknown_options);
3545+
rocksdb::ConfigOptions config_options;
3546+
config_options.ignore_unknown_options = ignore_unknown_options;
3547+
Status s = rocksdb::LoadLatestOptions(rocksdb::ConfigOptions(), dbpath,
3548+
&db_options->rep, &tmp_cf_descs);
36183549

36193550
*errptr = nullptr;
36203551
if (s.IsNotFound()) return false;
@@ -3810,17 +3741,12 @@ unsigned char crocksdb_compactionfiltercontext_is_bottommost_level(
38103741
return context->rep.is_bottommost_level;
38113742
}
38123743

3813-
void crocksdb_compactionfiltercontext_file_numbers(
3814-
crocksdb_compactionfiltercontext_t* context, const uint64_t** buffer,
3815-
size_t* len) {
3816-
*buffer = context->rep.file_numbers.data();
3817-
*len = context->rep.file_numbers.size();
3818-
}
3819-
3820-
crocksdb_table_properties_t* crocksdb_compactionfiltercontext_table_properties(
3821-
crocksdb_compactionfiltercontext_t* context, size_t offset) {
3822-
return (crocksdb_table_properties_t*)context->rep.table_properties[offset]
3823-
.get();
3744+
crocksdb_table_properties_collection_t*
3745+
crocksdb_compactionfiltercontext_input_table_properties(
3746+
crocksdb_compactionfiltercontext_t* context) {
3747+
return (
3748+
crocksdb_table_properties_collection_t*)(&context->rep
3749+
.input_table_properties);
38243750
}
38253751

38263752
const char* crocksdb_compactionfiltercontext_start_key(
@@ -3879,25 +3805,6 @@ crocksdb_comparator_t* crocksdb_comparator_create(
38793805

38803806
void crocksdb_comparator_destroy(crocksdb_comparator_t* cmp) { delete cmp; }
38813807

3882-
crocksdb_filterpolicy_t* crocksdb_filterpolicy_create(
3883-
void* state, void (*destructor)(void*),
3884-
char* (*create_filter)(void*, const char* const* key_array,
3885-
const size_t* key_length_array, int num_keys,
3886-
size_t* filter_length),
3887-
unsigned char (*key_may_match)(void*, const char* key, size_t length,
3888-
const char* filter, size_t filter_length),
3889-
void (*delete_filter)(void*, const char* filter, size_t filter_length),
3890-
const char* (*name)(void*)) {
3891-
crocksdb_filterpolicy_t* result = new crocksdb_filterpolicy_t;
3892-
result->state_ = state;
3893-
result->destructor_ = destructor;
3894-
result->create_ = create_filter;
3895-
result->key_match_ = key_may_match;
3896-
result->delete_filter_ = delete_filter;
3897-
result->name_ = name;
3898-
return result;
3899-
}
3900-
39013808
void crocksdb_filterpolicy_destroy(crocksdb_filterpolicy_t* filter) {
39023809
delete filter;
39033810
}
@@ -3910,11 +3817,8 @@ struct FilterPolicyWrapper : public crocksdb_filterpolicy_t {
39103817
std::string full_name_;
39113818
~FilterPolicyWrapper() override { delete rep_; }
39123819
const char* Name() const override { return full_name_.c_str(); }
3913-
void CreateFilter(const Slice* keys, int n, std::string* dst) const override {
3914-
return rep_->CreateFilter(keys, n, dst);
3915-
}
3916-
bool KeyMayMatch(const Slice& key, const Slice& filter) const override {
3917-
return rep_->KeyMayMatch(key, filter);
3820+
const char* CompatibilityName() const override {
3821+
return rep_->CompatibilityName();
39183822
}
39193823
// No need to override GetFilterBitsBuilder if this one is overridden
39203824
FilterBitsBuilder* GetBuilderWithContext(
@@ -3938,7 +3842,6 @@ crocksdb_filterpolicy_t* crocksdb_filterpolicy_create_bloom_format(
39383842
wrapper->full_name_ += ".FullBloom";
39393843
}
39403844
wrapper->state_ = nullptr;
3941-
wrapper->delete_filter_ = nullptr;
39423845
wrapper->destructor_ = &FilterPolicyWrapper::DoNothing;
39433846
return wrapper;
39443847
}
@@ -3961,7 +3864,6 @@ crocksdb_filterpolicy_t* crocksdb_filterpolicy_create_ribbon(
39613864
wrapper->full_name_ = wrapper->rep_->Name();
39623865
wrapper->full_name_ += ".Ribbon";
39633866
wrapper->state_ = nullptr;
3964-
wrapper->delete_filter_ = nullptr;
39653867
wrapper->destructor_ = &FilterPolicyWrapper::DoNothing;
39663868
return wrapper;
39673869
}
@@ -5821,7 +5723,7 @@ struct ExternalSstFileModifier {
58215723
auto ioptions = *cfd->ioptions();
58225724
auto table_opt =
58235725
TableReaderOptions(ioptions, desc.options.prefix_extractor,
5824-
env_options_, cfd->internal_comparator());
5726+
env_options_, cfd->internal_comparator(), 0);
58255727
// Get around global seqno check.
58265728
table_opt.largest_seqno = kMaxSequenceNumber;
58275729
status = ioptions.table_factory->NewTableReader(

librocksdb_sys/crocksdb/crocksdb/c.h

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -780,10 +780,6 @@ extern C_ROCKSDB_LIBRARY_API void crocksdb_block_based_options_set_block_cache(
780780
crocksdb_block_based_table_options_t* options,
781781
crocksdb_cache_t* block_cache);
782782
extern C_ROCKSDB_LIBRARY_API void
783-
crocksdb_block_based_options_set_block_cache_compressed(
784-
crocksdb_block_based_table_options_t* options,
785-
crocksdb_cache_t* block_cache_compressed);
786-
extern C_ROCKSDB_LIBRARY_API void
787783
crocksdb_block_based_options_set_whole_key_filtering(
788784
crocksdb_block_based_table_options_t*, unsigned char);
789785
extern C_ROCKSDB_LIBRARY_API void
@@ -1167,7 +1163,7 @@ crocksdb_options_get_sst_partitioner_factory(crocksdb_options_t*);
11671163
extern C_ROCKSDB_LIBRARY_API void crocksdb_options_set_sst_partitioner_factory(
11681164
crocksdb_options_t*, crocksdb_sst_partitioner_factory_t*);
11691165
extern C_ROCKSDB_LIBRARY_API unsigned char crocksdb_load_latest_options(
1170-
const char* dbpath, crocksdb_env_t* env, crocksdb_options_t* db_options,
1166+
const char* dbpath, crocksdb_options_t* db_options,
11711167
crocksdb_column_family_descriptor*** cf_descs, size_t* cf_descs_len,
11721168
unsigned char ignore_unknown_options, char** errptr);
11731169

@@ -1222,10 +1218,6 @@ extern C_ROCKSDB_LIBRARY_API void
12221218
crocksdb_options_set_max_background_compactions(crocksdb_options_t*, int);
12231219
extern C_ROCKSDB_LIBRARY_API int
12241220
crocksdb_options_get_max_background_compactions(const crocksdb_options_t*);
1225-
extern C_ROCKSDB_LIBRARY_API void
1226-
crocksdb_options_set_base_background_compactions(crocksdb_options_t*, int);
1227-
extern C_ROCKSDB_LIBRARY_API int
1228-
crocksdb_options_get_base_background_compactions(const crocksdb_options_t*);
12291221
extern C_ROCKSDB_LIBRARY_API void crocksdb_options_set_max_background_flushes(
12301222
crocksdb_options_t*, int);
12311223
extern C_ROCKSDB_LIBRARY_API int crocksdb_options_get_max_background_flushes(
@@ -1238,10 +1230,6 @@ extern C_ROCKSDB_LIBRARY_API void crocksdb_options_set_keep_log_file_num(
12381230
crocksdb_options_t*, size_t);
12391231
extern C_ROCKSDB_LIBRARY_API void crocksdb_options_set_recycle_log_file_num(
12401232
crocksdb_options_t*, size_t);
1241-
extern C_ROCKSDB_LIBRARY_API void crocksdb_options_set_soft_rate_limit(
1242-
crocksdb_options_t*, double);
1243-
extern C_ROCKSDB_LIBRARY_API void crocksdb_options_set_hard_rate_limit(
1244-
crocksdb_options_t*, double);
12451233
extern C_ROCKSDB_LIBRARY_API void
12461234
crocksdb_options_set_soft_pending_compaction_bytes_limit(
12471235
crocksdb_options_t* opt, size_t v);
@@ -1254,9 +1242,6 @@ crocksdb_options_set_hard_pending_compaction_bytes_limit(
12541242
extern C_ROCKSDB_LIBRARY_API size_t
12551243
crocksdb_options_get_hard_pending_compaction_bytes_limit(
12561244
crocksdb_options_t* opt);
1257-
extern C_ROCKSDB_LIBRARY_API void
1258-
crocksdb_options_set_rate_limit_delay_max_milliseconds(crocksdb_options_t*,
1259-
unsigned int);
12601245
extern C_ROCKSDB_LIBRARY_API void crocksdb_options_set_max_manifest_file_size(
12611246
crocksdb_options_t*, size_t);
12621247
extern C_ROCKSDB_LIBRARY_API void crocksdb_options_set_table_cache_numshardbits(
@@ -1293,9 +1278,6 @@ extern C_ROCKSDB_LIBRARY_API void crocksdb_options_set_allow_mmap_writes(
12931278
crocksdb_options_t*, unsigned char);
12941279
extern C_ROCKSDB_LIBRARY_API void crocksdb_options_set_is_fd_close_on_exec(
12951280
crocksdb_options_t*, unsigned char);
1296-
extern C_ROCKSDB_LIBRARY_API void
1297-
crocksdb_options_set_skip_log_error_on_recovery(crocksdb_options_t*,
1298-
unsigned char);
12991281
extern C_ROCKSDB_LIBRARY_API void crocksdb_options_set_stats_dump_period_sec(
13001282
crocksdb_options_t*, unsigned int);
13011283
extern C_ROCKSDB_LIBRARY_API void crocksdb_options_set_stats_persist_period_sec(
@@ -1549,13 +1531,9 @@ extern C_ROCKSDB_LIBRARY_API unsigned char
15491531
crocksdb_compactionfiltercontext_is_bottommost_level(
15501532
crocksdb_compactionfiltercontext_t* context);
15511533

1552-
extern C_ROCKSDB_LIBRARY_API void crocksdb_compactionfiltercontext_file_numbers(
1553-
crocksdb_compactionfiltercontext_t* context, const uint64_t** buffer,
1554-
size_t* len);
1555-
1556-
extern C_ROCKSDB_LIBRARY_API crocksdb_table_properties_t*
1557-
crocksdb_compactionfiltercontext_table_properties(
1558-
crocksdb_compactionfiltercontext_t* context, size_t offset);
1534+
extern C_ROCKSDB_LIBRARY_API crocksdb_table_properties_collection_t*
1535+
crocksdb_compactionfiltercontext_input_table_properties(
1536+
crocksdb_compactionfiltercontext_t* context);
15591537

15601538
extern C_ROCKSDB_LIBRARY_API uint32_t crocksdb_compactionfiltercontext_reason(
15611539
crocksdb_compactionfiltercontext_t* context);
@@ -1584,16 +1562,6 @@ extern C_ROCKSDB_LIBRARY_API void crocksdb_comparator_destroy(
15841562

15851563
/* Filter policy */
15861564

1587-
extern C_ROCKSDB_LIBRARY_API crocksdb_filterpolicy_t*
1588-
crocksdb_filterpolicy_create(
1589-
void* state, void (*destructor)(void*),
1590-
char* (*create_filter)(void*, const char* const* key_array,
1591-
const size_t* key_length_array, int num_keys,
1592-
size_t* filter_length),
1593-
unsigned char (*key_may_match)(void*, const char* key, size_t length,
1594-
const char* filter, size_t filter_length),
1595-
void (*delete_filter)(void*, const char* filter, size_t filter_length),
1596-
const char* (*name)(void*));
15971565
extern C_ROCKSDB_LIBRARY_API void crocksdb_filterpolicy_destroy(
15981566
crocksdb_filterpolicy_t*);
15991567

librocksdb_sys/rocksdb

Submodule rocksdb updated 1603 files

0 commit comments

Comments
 (0)