Skip to content

Commit 9634ba4

Browse files
committed
Merge branch 'master' into columnfamilies
Conflicts: db/compaction_picker.cc db/db_impl.cc db/db_impl.h db/tailing_iter.cc db/version_set.h include/rocksdb/options.h util/options.cc
2 parents d4f2c61 + d5de22d commit 9634ba4

38 files changed

+403
-363
lines changed

HISTORY.md

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
* Added is_manual_compaction to CompactionFilter::Context
1515
* Added "virtual void WaitForJoin() = 0" in class Env
1616
* Removed BackupEngine::DeleteBackupsNewerThan() function
17+
* Added new option -- verify_checksums_in_compaction
18+
* Chagned Options.prefix_extractor from raw pointer to shared_ptr (take ownership)
19+
Changed HashSkipListRepFactory and HashLinkListRepFactory constructor to not take SliceTransform object (use Options.prefix_extractor implicitly)
1720

1821
### New Features
1922
* If we find one truncated record at the end of the MANIFEST or WAL files,

db/c.cc

+14-14
Original file line numberDiff line numberDiff line change
@@ -294,10 +294,10 @@ struct rocksdb_universal_compaction_options_t {
294294
};
295295

296296
static bool SaveError(char** errptr, const Status& s) {
297-
assert(errptr != NULL);
297+
assert(errptr != nullptr);
298298
if (s.ok()) {
299299
return false;
300-
} else if (*errptr == NULL) {
300+
} else if (*errptr == nullptr) {
301301
*errptr = strdup(s.ToString().c_str());
302302
} else {
303303
// TODO(sanjay): Merge with existing error?
@@ -319,7 +319,7 @@ rocksdb_t* rocksdb_open(
319319
char** errptr) {
320320
DB* db;
321321
if (SaveError(errptr, DB::Open(options->rep, std::string(name), &db))) {
322-
return NULL;
322+
return nullptr;
323323
}
324324
rocksdb_t* result = new rocksdb_t;
325325
result->rep = db;
@@ -373,7 +373,7 @@ char* rocksdb_get(
373373
const char* key, size_t keylen,
374374
size_t* vallen,
375375
char** errptr) {
376-
char* result = NULL;
376+
char* result = nullptr;
377377
std::string tmp;
378378
Status s = db->rep->Get(options->rep, Slice(key, keylen), &tmp);
379379
if (s.ok()) {
@@ -418,7 +418,7 @@ char* rocksdb_property_value(
418418
// We use strdup() since we expect human readable output.
419419
return strdup(tmp.c_str());
420420
} else {
421-
return NULL;
421+
return nullptr;
422422
}
423423
}
424424

@@ -456,9 +456,9 @@ void rocksdb_compact_range(
456456
const char* limit_key, size_t limit_key_len) {
457457
Slice a, b;
458458
db->rep->CompactRange(
459-
// Pass NULL Slice if corresponding "const char*" is NULL
460-
(start_key ? (a = Slice(start_key, start_key_len), &a) : NULL),
461-
(limit_key ? (b = Slice(limit_key, limit_key_len), &b) : NULL));
459+
// Pass nullptr Slice if corresponding "const char*" is nullptr
460+
(start_key ? (a = Slice(start_key, start_key_len), &a) : nullptr),
461+
(limit_key ? (b = Slice(limit_key, limit_key_len), &b) : nullptr));
462462
}
463463

464464
void rocksdb_flush(
@@ -647,7 +647,7 @@ void rocksdb_options_set_paranoid_checks(
647647
}
648648

649649
void rocksdb_options_set_env(rocksdb_options_t* opt, rocksdb_env_t* env) {
650-
opt->rep.env = (env ? env->rep : NULL);
650+
opt->rep.env = (env ? env->rep : nullptr);
651651
}
652652

653653
void rocksdb_options_set_info_log(rocksdb_options_t* opt, rocksdb_logger_t* l) {
@@ -765,7 +765,7 @@ void rocksdb_options_set_compression_options(
765765

766766
void rocksdb_options_set_prefix_extractor(
767767
rocksdb_options_t* opt, rocksdb_slicetransform_t* prefix_extractor) {
768-
opt->rep.prefix_extractor = prefix_extractor;
768+
opt->rep.prefix_extractor.reset(prefix_extractor);
769769
}
770770

771771
void rocksdb_options_set_whole_key_filtering(
@@ -1087,8 +1087,8 @@ rocksdb_filterpolicy_t* rocksdb_filterpolicy_create_bloom(int bits_per_key) {
10871087
};
10881088
Wrapper* wrapper = new Wrapper;
10891089
wrapper->rep_ = NewBloomFilterPolicy(bits_per_key);
1090-
wrapper->state_ = NULL;
1091-
wrapper->delete_filter_ = NULL;
1090+
wrapper->state_ = nullptr;
1091+
wrapper->delete_filter_ = nullptr;
10921092
wrapper->destructor_ = &Wrapper::DoNothing;
10931093
return wrapper;
10941094
}
@@ -1154,7 +1154,7 @@ void rocksdb_readoptions_set_prefix_seek(
11541154
void rocksdb_readoptions_set_snapshot(
11551155
rocksdb_readoptions_t* opt,
11561156
const rocksdb_snapshot_t* snap) {
1157-
opt->rep.snapshot = (snap ? snap->rep : NULL);
1157+
opt->rep.snapshot = (snap ? snap->rep : nullptr);
11581158
}
11591159

11601160
void rocksdb_readoptions_set_prefix(
@@ -1280,7 +1280,7 @@ rocksdb_slicetransform_t* rocksdb_slicetransform_create_fixed_prefix(size_t pref
12801280
};
12811281
Wrapper* wrapper = new Wrapper;
12821282
wrapper->rep_ = rocksdb::NewFixedPrefixTransform(prefixLen);
1283-
wrapper->state_ = NULL;
1283+
wrapper->state_ = nullptr;
12841284
wrapper->destructor_ = &Wrapper::DoNothing;
12851285
return wrapper;
12861286
}

db/column_family.cc

+8-8
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ ColumnFamilyHandleImpl::~ColumnFamilyHandleImpl() {
4040
}
4141
db_->FindObsoleteFiles(deletion_state, false, true);
4242
mutex_->Unlock();
43-
db_->PurgeObsoleteFiles(deletion_state);
43+
if (deletion_state.HaveSomethingToDelete()) {
44+
db_->PurgeObsoleteFiles(deletion_state);
45+
}
4446
}
4547
}
4648

@@ -84,13 +86,11 @@ ColumnFamilyOptions SanitizeOptions(const InternalKeyComparator* icmp,
8486
if (result.soft_rate_limit > result.hard_rate_limit) {
8587
result.soft_rate_limit = result.hard_rate_limit;
8688
}
87-
if (result.prefix_extractor) {
88-
// If a prefix extractor has been supplied and a HashSkipListRepFactory is
89-
// being used, make sure that the latter uses the former as its transform
90-
// function.
91-
auto factory =
92-
dynamic_cast<HashSkipListRepFactory*>(result.memtable_factory.get());
93-
if (factory && factory->GetTransform() != result.prefix_extractor) {
89+
if (!result.prefix_extractor) {
90+
assert(result.memtable_factory);
91+
Slice name = result.memtable_factory->Name();
92+
if (name.compare("HashSkipListRepFactory") == 0 ||
93+
name.compare("HashLinkListRepFactory") == 0) {
9494
result.memtable_factory = std::make_shared<SkipListFactory>();
9595
}
9696
}

db/column_family.h

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class InternalKey;
3333
class InternalStats;
3434
class ColumnFamilyData;
3535
class DBImpl;
36+
class LogBuffer;
3637

3738
class ColumnFamilyHandleImpl : public ColumnFamilyHandle {
3839
public:

db/compaction_picker.cc

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include "db/compaction_picker.h"
1111

1212
#include <limits>
13+
#include "util/log_buffer.h"
14+
#include "util/statistics.h"
1315

1416
namespace rocksdb {
1517

db/db_bench.cc

+4-5
Original file line numberDiff line numberDiff line change
@@ -1538,9 +1538,10 @@ class Benchmark {
15381538
options.compaction_style = FLAGS_compaction_style_e;
15391539
options.block_size = FLAGS_block_size;
15401540
options.filter_policy = filter_policy_;
1541-
options.prefix_extractor =
1542-
(FLAGS_use_plain_table || FLAGS_use_prefix_blooms) ? prefix_extractor_
1543-
: nullptr;
1541+
if (FLAGS_use_plain_table || FLAGS_use_prefix_blooms) {
1542+
options.prefix_extractor.reset(
1543+
NewFixedPrefixTransform(FLAGS_prefix_size));
1544+
}
15441545
options.memtable_prefix_bloom_bits = FLAGS_memtable_bloom_bits;
15451546
options.max_open_files = FLAGS_open_files;
15461547
options.statistics = dbstats;
@@ -1564,15 +1565,13 @@ class Benchmark {
15641565
switch (FLAGS_rep_factory) {
15651566
case kPrefixHash:
15661567
options.memtable_factory.reset(NewHashSkipListRepFactory(
1567-
prefix_extractor_,
15681568
FLAGS_hash_bucket_count));
15691569
break;
15701570
case kSkipList:
15711571
// no need to do anything
15721572
break;
15731573
case kHashLinkedList:
15741574
options.memtable_factory.reset(NewHashLinkListRepFactory(
1575-
prefix_extractor_,
15761575
FLAGS_hash_bucket_count));
15771576
break;
15781577
case kVectorRep:

0 commit comments

Comments
 (0)