]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/table/get_context.h
1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2 // This source code is licensed under the BSD-style license found in the
3 // LICENSE file in the root directory of this source tree. An additional grant
4 // of patent rights can be found in the PATENTS file in the same directory.
8 #include "db/merge_context.h"
9 #include "db/range_del_aggregator.h"
10 #include "rocksdb/env.h"
11 #include "rocksdb/types.h"
12 #include "table/block.h"
16 class PinnedIteratorsManager
;
25 kMerge
// saver contains the current merge result (the operands)
28 GetContext(const Comparator
* ucmp
, const MergeOperator
* merge_operator
,
29 Logger
* logger
, Statistics
* statistics
, GetState init_state
,
30 const Slice
& user_key
, PinnableSlice
* value
, bool* value_found
,
31 MergeContext
* merge_context
, RangeDelAggregator
* range_del_agg
,
32 Env
* env
, SequenceNumber
* seq
= nullptr,
33 PinnedIteratorsManager
* _pinned_iters_mgr
= nullptr);
35 void MarkKeyMayExist();
37 // Records this key, value, and any meta-data (such as sequence number and
38 // state) into this GetContext.
40 // Returns True if more keys need to be read (due to merges) or
41 // False if the complete value has been found.
42 bool SaveValue(const ParsedInternalKey
& parsed_key
, const Slice
& value
,
43 Cleanable
* value_pinner
= nullptr);
45 // Simplified version of the previous function. Should only be used when we
46 // know that the operation is a Put.
47 void SaveValue(const Slice
& value
, SequenceNumber seq
);
49 GetState
State() const { return state_
; }
51 RangeDelAggregator
* range_del_agg() { return range_del_agg_
; }
53 PinnedIteratorsManager
* pinned_iters_mgr() { return pinned_iters_mgr_
; }
55 // If a non-null string is passed, all the SaveValue calls will be
56 // logged into the string. The operations can then be replayed on
57 // another GetContext with replayGetContextLog.
58 void SetReplayLog(std::string
* replay_log
) { replay_log_
= replay_log
; }
60 // Do we need to fetch the SequenceNumber for this key?
61 bool NeedToReadSequence() const { return (seq_
!= nullptr); }
64 const Comparator
* ucmp_
;
65 const MergeOperator
* merge_operator_
;
66 // the merge operations encountered;
68 Statistics
* statistics_
;
72 PinnableSlice
* pinnable_val_
;
73 bool* value_found_
; // Is value set correctly? Used by KeyMayExist
74 MergeContext
* merge_context_
;
75 RangeDelAggregator
* range_del_agg_
;
77 // If a key is found, seq_ will be set to the SequenceNumber of most recent
78 // write to the key or kMaxSequenceNumber if unknown
80 std::string
* replay_log_
;
81 // Used to temporarily pin blocks when state_ == GetContext::kMerge
82 PinnedIteratorsManager
* pinned_iters_mgr_
;
85 void replayGetContextLog(const Slice
& replay_log
, const Slice
& user_key
,
86 GetContext
* get_context
);
88 } // namespace rocksdb