Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve Release compilation errors for macOS #1135

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Editors.
*.sw*
.vscode
.cache/
.vscode/
.DS_Store

# Build directory.
Expand Down
2 changes: 1 addition & 1 deletion db/dbformat.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ LookupKey::LookupKey(const Slice& user_key, SequenceNumber s) {
dst = new char[needed];
}
start_ = dst;
dst = EncodeVarint32(dst, usize + 8);
dst = EncodeVarint32(dst, uint32_t(usize + 8));
kstart_ = dst;
std::memcpy(dst, user_key.data(), usize);
dst += usize;
Expand Down
63 changes: 31 additions & 32 deletions db/version_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class Version {
int PickLevelForMemTableOutput(const Slice& smallest_user_key,
const Slice& largest_user_key);

int NumFiles(int level) const { return files_[level].size(); }
int NumFiles(int level) const { return static_cast<int>(files_[level].size()); }

// Return a human readable string that describes this version's contents.
std::string DebugString() const;
Expand Down Expand Up @@ -317,6 +317,35 @@ class VersionSet {

// A Compaction encapsulates information about a compaction.
class Compaction {
friend class Version;
friend class VersionSet;

int level_;
uint64_t max_output_file_size_;
Version* input_version_;
VersionEdit edit_;

// Each compaction reads inputs from "level_" and "level_+1"
std::vector<FileMetaData*> inputs_[2]; // The two sets of inputs

// State used to check for number of overlapping grandparent files
// (parent == level_ + 1, grandparent == level_ + 2)
std::vector<FileMetaData*> grandparents_;
size_t grandparent_index_; // Index in grandparent_starts_
bool seen_key_; // Some output key has been seen
int64_t overlapped_bytes_; // Bytes of overlap between current output
// and grandparent files

// State for implementing IsBaseLevelForKey

// level_ptrs_ holds indices into input_version_->levels_: our state
// is that we are positioned at one of the file ranges for each
// higher level than the ones involved in this compaction (i.e. for
// all L >= level_ + 2).
size_t level_ptrs_[config::kNumLevels];

Compaction(const Options* options, int level);

public:
~Compaction();

Expand All @@ -329,7 +358,7 @@ class Compaction {
VersionEdit* edit() { return &edit_; }

// "which" must be either 0 or 1
int num_input_files(int which) const { return inputs_[which].size(); }
int num_input_files(int which) const { return static_cast<int>(inputs_[which].size()); }

// Return the ith input file at "level()+which" ("which" must be 0 or 1).
FileMetaData* input(int which, int i) const { return inputs_[which][i]; }
Expand All @@ -356,36 +385,6 @@ class Compaction {
// Release the input version for the compaction, once the compaction
// is successful.
void ReleaseInputs();

private:
friend class Version;
friend class VersionSet;

Compaction(const Options* options, int level);

int level_;
uint64_t max_output_file_size_;
Version* input_version_;
VersionEdit edit_;

// Each compaction reads inputs from "level_" and "level_+1"
std::vector<FileMetaData*> inputs_[2]; // The two sets of inputs

// State used to check for number of overlapping grandparent files
// (parent == level_ + 1, grandparent == level_ + 2)
std::vector<FileMetaData*> grandparents_;
size_t grandparent_index_; // Index in grandparent_starts_
bool seen_key_; // Some output key has been seen
int64_t overlapped_bytes_; // Bytes of overlap between current output
// and grandparent files

// State for implementing IsBaseLevelForKey

// level_ptrs_ holds indices into input_version_->levels_: our state
// is that we are positioned at one of the file ranges for each
// higher level than the ones involved in this compaction (i.e. for
// all L >= level_ + 2).
size_t level_ptrs_[config::kNumLevels];
};

} // namespace leveldb
Expand Down