#include "db/version_set.h"
#include <algorithm>
#include <cstdio>
#include "db/filename.h"
#include "db/log_reader.h"
#include "db/log_writer.h"
#include "db/memtable.h"
#include "db/table_cache.h"
#include "leveldb/env.h"
#include "leveldb/table_builder.h"
#include "table/merger.h"
#include "table/two_level_iterator.h"
#include "util/coding.h"
#include "util/logging.h"
namespace leveldb {
static size_t TargetFileSize(const Options* options) { … }
static int64_t MaxGrandParentOverlapBytes(const Options* options) { … }
static int64_t ExpandedCompactionByteSizeLimit(const Options* options) { … }
static double MaxBytesForLevel(const Options* options, int level) { … }
static uint64_t MaxFileSizeForLevel(const Options* options, int level) { … }
static int64_t TotalFileSize(const std::vector<FileMetaData*>& files) { … }
Version::~Version() { … }
int FindFile(const InternalKeyComparator& icmp,
const std::vector<FileMetaData*>& files, const Slice& key) { … }
static bool AfterFile(const Comparator* ucmp, const Slice* user_key,
const FileMetaData* f) { … }
static bool BeforeFile(const Comparator* ucmp, const Slice* user_key,
const FileMetaData* f) { … }
bool SomeFileOverlapsRange(const InternalKeyComparator& icmp,
bool disjoint_sorted_files,
const std::vector<FileMetaData*>& files,
const Slice* smallest_user_key,
const Slice* largest_user_key) { … }
class Version::LevelFileNumIterator : public Iterator { … };
static Iterator* GetFileIterator(void* arg, const ReadOptions& options,
const Slice& file_value) { … }
Iterator* Version::NewConcatenatingIterator(const ReadOptions& options,
int level) const { … }
void Version::AddIterators(const ReadOptions& options,
std::vector<Iterator*>* iters) { … }
namespace {
enum SaverState { … };
struct Saver { … };
}
static void SaveValue(void* arg, const Slice& ikey, const Slice& v) { … }
static bool NewestFirst(FileMetaData* a, FileMetaData* b) { … }
void Version::ForEachOverlapping(Slice user_key, Slice internal_key, void* arg,
bool (*func)(void*, int, FileMetaData*)) { … }
Status Version::Get(const ReadOptions& options, const LookupKey& k,
std::string* value, GetStats* stats) { … }
bool Version::UpdateStats(const GetStats& stats) { … }
bool Version::RecordReadSample(Slice internal_key) { … }
void Version::Ref() { … }
void Version::Unref() { … }
bool Version::OverlapInLevel(int level, const Slice* smallest_user_key,
const Slice* largest_user_key) { … }
int Version::PickLevelForMemTableOutput(const Slice& smallest_user_key,
const Slice& largest_user_key) { … }
void Version::GetOverlappingInputs(int level, const InternalKey* begin,
const InternalKey* end,
std::vector<FileMetaData*>* inputs) { … }
std::string Version::DebugString() const { … }
class VersionSet::Builder { … };
VersionSet::VersionSet(const std::string& dbname, const Options* options,
TableCache* table_cache,
const InternalKeyComparator* cmp)
: … { … }
VersionSet::~VersionSet() { … }
void VersionSet::AppendVersion(Version* v) { … }
Status VersionSet::LogAndApply(VersionEdit* edit, port::Mutex* mu) { … }
Status VersionSet::Recover(bool* save_manifest) { … }
bool VersionSet::ReuseManifest(const std::string& dscname,
const std::string& dscbase) { … }
void VersionSet::MarkFileNumberUsed(uint64_t number) { … }
void VersionSet::Finalize(Version* v) { … }
Status VersionSet::WriteSnapshot(log::Writer* log) { … }
int VersionSet::NumLevelFiles(int level) const { … }
const char* VersionSet::LevelSummary(LevelSummaryStorage* scratch) const { … }
uint64_t VersionSet::ApproximateOffsetOf(Version* v, const InternalKey& ikey) { … }
void VersionSet::AddLiveFiles(std::set<uint64_t>* live) { … }
int64_t VersionSet::NumLevelBytes(int level) const { … }
int64_t VersionSet::MaxNextLevelOverlappingBytes() { … }
void VersionSet::GetRange(const std::vector<FileMetaData*>& inputs,
InternalKey* smallest, InternalKey* largest) { … }
void VersionSet::GetRange2(const std::vector<FileMetaData*>& inputs1,
const std::vector<FileMetaData*>& inputs2,
InternalKey* smallest, InternalKey* largest) { … }
Iterator* VersionSet::MakeInputIterator(Compaction* c) { … }
Compaction* VersionSet::PickCompaction() { … }
bool FindLargestKey(const InternalKeyComparator& icmp,
const std::vector<FileMetaData*>& files,
InternalKey* largest_key) { … }
FileMetaData* FindSmallestBoundaryFile(
const InternalKeyComparator& icmp,
const std::vector<FileMetaData*>& level_files,
const InternalKey& largest_key) { … }
void AddBoundaryInputs(const InternalKeyComparator& icmp,
const std::vector<FileMetaData*>& level_files,
std::vector<FileMetaData*>* compaction_files) { … }
void VersionSet::SetupOtherInputs(Compaction* c) { … }
Compaction* VersionSet::CompactRange(int level, const InternalKey* begin,
const InternalKey* end) { … }
Compaction::Compaction(const Options* options, int level)
: … { … }
Compaction::~Compaction() { … }
bool Compaction::IsTrivialMove() const { … }
void Compaction::AddInputDeletions(VersionEdit* edit) { … }
bool Compaction::IsBaseLevelForKey(const Slice& user_key) { … }
bool Compaction::ShouldStopBefore(const Slice& internal_key) { … }
void Compaction::ReleaseInputs() { … }
}