Skip to content

Commit

Permalink
fix file_size always = 0 bug
Browse files Browse the repository at this point in the history
Signed-off-by: Wang Haitao <[email protected]>
  • Loading branch information
apple-ouyang committed Apr 21, 2022
1 parent bdc92e0 commit 49896e5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/blob_file_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ class BlobFileBuilder {
const std::string& GetLargestKey() { return largest_key_; }

uint64_t live_data_size() const { return live_data_size_; }
bool IsFileSizeReachLimit() const {
return file_->GetFileSize() >= cf_options_.blob_file_target_size;
}

private:
BuilderState builder_state_;
Expand Down
8 changes: 2 additions & 6 deletions src/blob_gc_job.cc
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,6 @@ Status BlobGCJob::DoRunGC() {
// uint64_t total_entry_num = 0;
// uint64_t total_entry_size = 0;

uint64_t file_size = 0;

std::string last_key;
bool last_key_valid = false;
gc_iter->SeekToFirst();
Expand Down Expand Up @@ -203,9 +201,8 @@ Status BlobGCJob::DoRunGC() {

// Rewrite entry to new blob file
if ((!blob_file_handle && !blob_file_builder) ||
file_size >= blob_gc_->titan_cf_options().blob_file_target_size) {
if (file_size >= blob_gc_->titan_cf_options().blob_file_target_size) {
assert(blob_file_builder);
(blob_file_builder && blob_file_builder->IsFileSizeReachLimit())) {
if (blob_file_builder && blob_file_builder->IsFileSizeReachLimit()) {
assert(blob_file_handle);
assert(blob_file_builder->status().ok());
blob_file_builders_.emplace_back(std::make_pair(
Expand All @@ -222,7 +219,6 @@ Status BlobGCJob::DoRunGC() {
blob_file_builder = std::unique_ptr<BlobFileBuilder>(
new BlobFileBuilder(db_options_, blob_gc_->titan_cf_options(),
blob_file_handle->GetFile()));
file_size = 0;
}
assert(blob_file_handle);
assert(blob_file_builder);
Expand Down

0 comments on commit 49896e5

Please sign in to comment.