// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
-// This source code is licensed under the BSD-style license found in the
-// LICENSE file in the root directory of this source tree. An additional grant
-// of patent rights can be found in the PATENTS file in the same directory.
+// This source code is licensed under both the GPLv2 (found in the
+// COPYING file in the root directory) and Apache 2.0 License
+// (found in the LICENSE.Apache file in the root directory).
//
-#ifndef MERGE_HELPER_H
-#define MERGE_HELPER_H
+#pragma once
#include <deque>
#include <string>
#include "db/dbformat.h"
#include "db/merge_context.h"
#include "db/range_del_aggregator.h"
+#include "db/snapshot_checker.h"
#include "rocksdb/compaction_filter.h"
#include "rocksdb/env.h"
#include "rocksdb/slice.h"
class Logger;
class MergeOperator;
class Statistics;
-class InternalIterator;
class MergeHelper {
public:
const MergeOperator* user_merge_operator,
const CompactionFilter* compaction_filter, Logger* logger,
bool assert_valid_internal_key, SequenceNumber latest_snapshot,
- int level = 0, Statistics* stats = nullptr,
- const std::atomic<bool>* shutting_down = nullptr)
- : env_(env),
- user_comparator_(user_comparator),
- user_merge_operator_(user_merge_operator),
- compaction_filter_(compaction_filter),
- shutting_down_(shutting_down),
- logger_(logger),
- assert_valid_internal_key_(assert_valid_internal_key),
- latest_snapshot_(latest_snapshot),
- level_(level),
- keys_(),
- filter_timer_(env_),
- total_filter_time_(0U),
- stats_(stats) {
- assert(user_comparator_ != nullptr);
- }
+ const SnapshotChecker* snapshot_checker = nullptr, int level = 0,
+ Statistics* stats = nullptr,
+ const std::atomic<bool>* shutting_down = nullptr);
// Wrapper around MergeOperator::FullMergeV2() that records perf statistics.
// Result of merge will be written to result if status returned is OK.
// If operands is empty, the value will simply be copied to result.
+ // Set `update_num_ops_stats` to true if it is from a user read, so that
+ // the latency is sensitive.
// Returns one of the following statuses:
// - OK: Entries were successfully merged.
// - Corruption: Merge operator reported unsuccessful merge.
const std::vector<Slice>& operands,
std::string* result, Logger* logger,
Statistics* statistics, Env* env,
- Slice* result_operand = nullptr);
+ Slice* result_operand = nullptr,
+ bool update_num_ops_stats = false);
// Merge entries until we hit
// - a corrupted key
const std::atomic<bool>* shutting_down_;
Logger* logger_;
bool assert_valid_internal_key_; // enforce no internal key corruption?
+ bool allow_single_operand_;
SequenceNumber latest_snapshot_;
+ const SnapshotChecker* const snapshot_checker_;
int level_;
// the scratch area that holds the result of MergeUntil
};
} // namespace rocksdb
-
-#endif