// 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).
//
#pragma once
-#include <string>
+#include <deque>
+#include <limits>
#include <list>
-#include <vector>
#include <set>
-#include <deque>
+#include <string>
+#include <vector>
#include "db/dbformat.h"
+#include "db/logs_with_prep_tracker.h"
#include "db/memtable.h"
#include "db/range_del_aggregator.h"
#include "monitoring/instrumented_mutex.h"
// returned). Otherwise, *seq will be set to kMaxSequenceNumber.
bool Get(const LookupKey& key, std::string* value, Status* s,
MergeContext* merge_context, RangeDelAggregator* range_del_agg,
- SequenceNumber* seq, const ReadOptions& read_opts);
+ SequenceNumber* seq, const ReadOptions& read_opts,
+ ReadCallback* callback = nullptr, bool* is_blob_index = nullptr);
bool Get(const LookupKey& key, std::string* value, Status* s,
MergeContext* merge_context, RangeDelAggregator* range_del_agg,
- const ReadOptions& read_opts) {
+ const ReadOptions& read_opts, ReadCallback* callback = nullptr,
+ bool* is_blob_index = nullptr) {
SequenceNumber seq;
- return Get(key, value, s, merge_context, range_del_agg, &seq, read_opts);
+ return Get(key, value, s, merge_context, range_del_agg, &seq, read_opts,
+ callback, is_blob_index);
}
// Similar to Get(), but searches the Memtable history of memtables that
bool GetFromHistory(const LookupKey& key, std::string* value, Status* s,
MergeContext* merge_context,
RangeDelAggregator* range_del_agg, SequenceNumber* seq,
- const ReadOptions& read_opts);
+ const ReadOptions& read_opts,
+ bool* is_blob_index = nullptr);
bool GetFromHistory(const LookupKey& key, std::string* value, Status* s,
MergeContext* merge_context,
RangeDelAggregator* range_del_agg,
- const ReadOptions& read_opts) {
+ const ReadOptions& read_opts,
+ bool* is_blob_index = nullptr) {
SequenceNumber seq;
return GetFromHistory(key, value, s, merge_context, range_del_agg, &seq,
- read_opts);
+ read_opts, is_blob_index);
}
Status AddRangeTombstoneIterators(const ReadOptions& read_opts, Arena* arena,
RangeDelAggregator* range_del_agg);
+ Status AddRangeTombstoneIterators(
+ const ReadOptions& read_opts,
+ std::vector<InternalIterator*>* range_del_iters);
void AddIterators(const ReadOptions& options,
std::vector<InternalIterator*>* iterator_list,
bool GetFromList(std::list<MemTable*>* list, const LookupKey& key,
std::string* value, Status* s, MergeContext* merge_context,
RangeDelAggregator* range_del_agg, SequenceNumber* seq,
- const ReadOptions& read_opts);
+ const ReadOptions& read_opts,
+ ReadCallback* callback = nullptr,
+ bool* is_blob_index = nullptr);
void AddMemTable(MemTable* m);
// Commit a successful flush in the manifest file
Status InstallMemtableFlushResults(
ColumnFamilyData* cfd, const MutableCFOptions& mutable_cf_options,
- const autovector<MemTable*>& m, VersionSet* vset, InstrumentedMutex* mu,
- uint64_t file_number, autovector<MemTable*>* to_delete,
- Directory* db_directory, LogBuffer* log_buffer);
+ const autovector<MemTable*>& m, LogsWithPrepTracker* prep_tracker,
+ VersionSet* vset, InstrumentedMutex* mu, uint64_t file_number,
+ autovector<MemTable*>* to_delete, Directory* db_directory,
+ LogBuffer* log_buffer);
// New memtables are inserted at the front of the list.
// Takes ownership of the referenced held on *m by the caller of Add().
// the unflushed mem-tables.
size_t ApproximateUnflushedMemTablesMemoryUsage();
+ // Returns an estimate of the timestamp of the earliest key.
+ uint64_t ApproximateOldestKeyTime() const;
+
// Request a flush of all existing memtables to storage. This will
// cause future calls to IsFlushPending() to return true if this list is
// non-empty (regardless of the min_write_buffer_number_to_merge
size_t* current_memory_usage() { return ¤t_memory_usage_; }
- uint64_t GetMinLogContainingPrepSection();
+ // Returns the min log containing the prep section after memtables listsed in
+ // `memtables_to_flush` are flushed and their status is persisted in manifest.
+ uint64_t PrecomputeMinLogContainingPrepSection(
+ const autovector<MemTable*>& memtables_to_flush);
+
+ uint64_t GetEarliestMemTableID() const {
+ auto& memlist = current_->memlist_;
+ if (memlist.empty()) {
+ return std::numeric_limits<uint64_t>::max();
+ }
+ return memlist.back()->GetID();
+ }
+
+ uint64_t GetLatestMemTableID() const {
+ auto& memlist = current_->memlist_;
+ if (memlist.empty()) {
+ return 0;
+ }
+ return memlist.front()->GetID();
+ }
private:
// DB mutex held