15 #ifndef STORAGE_LEVELDB_DB_VERSION_SET_H_ 16 #define STORAGE_LEVELDB_DB_VERSION_SET_H_ 23 #include "port/port.h" 24 #include "port/thread_annotations.h" 28 namespace log {
class Writer; }
42 extern int FindFile(
const InternalKeyComparator& icmp,
43 const std::vector<FileMetaData*>& files,
53 const InternalKeyComparator& icmp,
54 bool disjoint_sorted_files,
55 const std::vector<FileMetaData*>& files,
56 const Slice* smallest_user_key,
57 const Slice* largest_user_key);
64 void AddIterators(
const ReadOptions&, std::vector<Iterator*>* iters);
79 bool UpdateStats(
const GetStats& stats);
85 bool RecordReadSample(
Slice key);
92 void GetOverlappingInputs(
96 std::vector<FileMetaData*>* inputs);
102 bool OverlapInLevel(
int level,
103 const Slice* smallest_user_key,
104 const Slice* largest_user_key);
108 int PickLevelForMemTableOutput(
const Slice& smallest_user_key,
109 const Slice& largest_user_key);
111 int NumFiles(
int level)
const {
return files_[level].size(); }
114 std::string DebugString()
const;
128 void ForEachOverlapping(
Slice user_key,
Slice internal_key,
151 : vset_(vset), next_(this), prev_(this), refs_(0),
152 file_to_compact_(NULL),
153 file_to_compact_level_(-1),
154 compaction_score_(-1),
155 compaction_level_(-1) {
162 void operator=(
const Version&);
179 EXCLUSIVE_LOCKS_REQUIRED(mu);
182 Status Recover(
bool *save_manifest);
197 if (next_file_number_ == file_number + 1) {
198 next_file_number_ = file_number;
203 int NumLevelFiles(
int level)
const;
206 int64_t NumLevelBytes(
int level)
const;
213 assert(s >= last_sequence_);
218 void MarkFileNumberUsed(uint64_t number);
244 int64_t MaxNextLevelOverlappingBytes();
258 void AddLiveFiles(std::set<uint64_t>* live);
277 bool ReuseManifest(
const std::string& dscname,
const std::string& dscbase);
281 void GetRange(
const std::vector<FileMetaData*>& inputs,
285 void GetRange2(
const std::vector<FileMetaData*>& inputs1,
286 const std::vector<FileMetaData*>& inputs2,
295 void AppendVersion(
Version* v);
330 int level()
const {
return level_; }
347 bool IsTrivialMove()
const;
355 bool IsBaseLevelForKey(
const Slice& user_key);
359 bool ShouldStopBefore(
const Slice& internal_key);
363 void ReleaseInputs();
377 std::vector<FileMetaData*> inputs_[2];
398 #endif // STORAGE_LEVELDB_DB_VERSION_SET_H_ FileMetaData * input(int which, int i) const
WritableFile * descriptor_file_
TableCache *const table_cache_
uint64_t PrevLogNumber() const
Version * current() const
const std::string dbname_
static const int kNumLevels
int FindFile(const InternalKeyComparator &icmp, const std::vector< FileMetaData *> &files, const Slice &key)
Version(VersionSet *vset)
uint64_t MaxOutputFileSize() const
bool SomeFileOverlapsRange(const InternalKeyComparator &icmp, bool disjoint_sorted_files, const std::vector< FileMetaData *> &files, const Slice *smallest_user_key, const Slice *largest_user_key)
uint64_t ManifestFileNumber() const
uint64_t next_file_number_
uint64_t max_output_file_size_
int file_to_compact_level_
const InternalKeyComparator icmp_
FileMetaData * file_to_compact_
bool NeedsCompaction() const
log::Writer * descriptor_log_
void ReuseFileNumber(uint64_t file_number)
uint64_t LogNumber() const
int NumFiles(int level) const
uint64_t LastSequence() const
int64_t overlapped_bytes_
uint64_t manifest_file_number_
void SetLastSequence(uint64_t s)
std::vector< FileMetaData * > grandparents_
uint64_t prev_log_number_
const Options *const options_
size_t grandparent_index_
int num_input_files(int which) const