Skip to content

Commit e816838

Browse files
committed
Merge branch 'master' into columnfamilies
Conflicts: db/db_impl.cc include/rocksdb/options.h util/options.cc
2 parents 275832a + ebaff6f commit e816838

29 files changed

+1280
-281
lines changed

HISTORY.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,21 @@
1313
* Removed arena.h from public header files.
1414
* By default, checksums are verified on every read from database
1515
* Added is_manual_compaction to CompactionFilter::Context
16-
* Added "virtual void WaitForJoin() = 0" in class Env
16+
* Added "virtual void WaitForJoin()" in class Env. Default operation is no-op.
1717
* Removed BackupEngine::DeleteBackupsNewerThan() function
1818
* Added new option -- verify_checksums_in_compaction
1919
* Chagned Options.prefix_extractor from raw pointer to shared_ptr (take ownership)
2020
Changed HashSkipListRepFactory and HashLinkListRepFactory constructor to not take SliceTransform object (use Options.prefix_extractor implicitly)
2121
* Added Env::GetThreadPoolQueueLen(), which returns the waiting queue length of thread pools
2222
* Added a command "checkconsistency" in ldb tool, which checks
2323
if file system state matches DB state (file existence and file sizes)
24+
* CompactionFilter::Context is now CompactionFilterContext. It is shared by CompactionFilter and CompactionFilterV2
2425

2526
### New Features
2627
* If we find one truncated record at the end of the MANIFEST or WAL files,
2728
we will ignore it. We assume that writers of these records were interrupted
2829
and that we can safely ignore it.
30+
* Now compaction filter has a V2 interface. It buffers the kv-pairs sharing the same key prefix, process them in batches, and return the batched results back to DB.
2931

3032
## 2.7.0 (01/28/2014)
3133

db/builder.cc

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ Status BuildTable(const std::string& dbname, Env* env, const Options& options,
7373

7474
MergeHelper merge(internal_comparator.user_comparator(),
7575
options.merge_operator.get(), options.info_log.get(),
76+
options.min_partial_merge_operands,
7677
true /* internal key corruption is not ok */);
7778

7879
if (purge) {

db/c.cc

+29-35
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,10 @@ struct rocksdb_mergeoperator_t : public MergeOperator {
159159
const char* const* operands_list, const size_t* operands_list_length,
160160
int num_operands,
161161
unsigned char* success, size_t* new_value_length);
162-
char* (*partial_merge_)(
163-
void*,
164-
const char* key, size_t key_length,
165-
const char* left_operand, size_t left_operand_length,
166-
const char* right_operand, size_t right_operand_length,
167-
unsigned char* success, size_t* new_value_length);
162+
char* (*partial_merge_)(void*, const char* key, size_t key_length,
163+
const char* const* operands_list,
164+
const size_t* operands_list_length, int num_operands,
165+
unsigned char* success, size_t* new_value_length);
168166
void (*delete_value_)(
169167
void*,
170168
const char* value, size_t value_length);
@@ -219,21 +217,23 @@ struct rocksdb_mergeoperator_t : public MergeOperator {
219217
return success;
220218
}
221219

222-
virtual bool PartialMerge(
223-
const Slice& key,
224-
const Slice& left_operand,
225-
const Slice& right_operand,
226-
std::string* new_value,
227-
Logger* logger) const {
220+
virtual bool PartialMergeMulti(const Slice& key,
221+
const std::deque<Slice>& operand_list,
222+
std::string* new_value, Logger* logger) const {
223+
size_t operand_count = operand_list.size();
224+
std::vector<const char*> operand_pointers(operand_count);
225+
std::vector<size_t> operand_sizes(operand_count);
226+
for (size_t i = 0; i < operand_count; ++i) {
227+
Slice operand(operand_list[i]);
228+
operand_pointers[i] = operand.data();
229+
operand_sizes[i] = operand.size();
230+
}
228231

229232
unsigned char success;
230233
size_t new_value_len;
231234
char* tmp_new_value = (*partial_merge_)(
232-
state_,
233-
key.data(), key.size(),
234-
left_operand.data(), left_operand.size(),
235-
right_operand.data(), right_operand.size(),
236-
&success, &new_value_len);
235+
state_, key.data(), key.size(), &operand_pointers[0], &operand_sizes[0],
236+
operand_count, &success, &new_value_len);
237237
new_value->assign(tmp_new_value, new_value_len);
238238

239239
if (delete_value_ != nullptr) {
@@ -1094,24 +1094,18 @@ rocksdb_filterpolicy_t* rocksdb_filterpolicy_create_bloom(int bits_per_key) {
10941094
}
10951095

10961096
rocksdb_mergeoperator_t* rocksdb_mergeoperator_create(
1097-
void* state,
1098-
void (*destructor)(void*),
1099-
char* (*full_merge)(
1100-
void*,
1101-
const char* key, size_t key_length,
1102-
const char* existing_value, size_t existing_value_length,
1103-
const char* const* operands_list, const size_t* operands_list_length,
1104-
int num_operands,
1105-
unsigned char* success, size_t* new_value_length),
1106-
char* (*partial_merge)(
1107-
void*,
1108-
const char* key, size_t key_length,
1109-
const char* left_operand, size_t left_operand_length,
1110-
const char* right_operand, size_t right_operand_length,
1111-
unsigned char* success, size_t* new_value_length),
1112-
void (*delete_value)(
1113-
void*,
1114-
const char* value, size_t value_length),
1097+
void* state, void (*destructor)(void*),
1098+
char* (*full_merge)(void*, const char* key, size_t key_length,
1099+
const char* existing_value,
1100+
size_t existing_value_length,
1101+
const char* const* operands_list,
1102+
const size_t* operands_list_length, int num_operands,
1103+
unsigned char* success, size_t* new_value_length),
1104+
char* (*partial_merge)(void*, const char* key, size_t key_length,
1105+
const char* const* operands_list,
1106+
const size_t* operands_list_length, int num_operands,
1107+
unsigned char* success, size_t* new_value_length),
1108+
void (*delete_value)(void*, const char* value, size_t value_length),
11151109
const char* (*name)(void*)) {
11161110
rocksdb_mergeoperator_t* result = new rocksdb_mergeoperator_t;
11171111
result->state_ = state;

db/c_test.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ static char* MergeOperatorFullMerge(
175175
static char* MergeOperatorPartialMerge(
176176
void* arg,
177177
const char* key, size_t key_length,
178-
const char* left_operand, size_t left_operand_length,
179-
const char* right_operand, size_t right_operand_length,
178+
const char* const* operands_list, const size_t* operands_list_length,
179+
int num_operands,
180180
unsigned char* success, size_t* new_value_length) {
181181
*new_value_length = 4;
182182
*success = 1;

0 commit comments

Comments
 (0)