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

Delegate Cleanables #1711

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
22 changes: 10 additions & 12 deletions table/block_based_table_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1539,7 +1539,6 @@ Status BlockBasedTable::Get(const ReadOptions& read_options, const Slice& key,

PinnedIteratorsManager* pinned_iters_mgr = get_context->pinned_iters_mgr();
bool pin_blocks = pinned_iters_mgr && pinned_iters_mgr->PinningEnabled();
BlockIter* biter = nullptr;

bool done = false;
for (iiter.Seek(key); iiter.Valid() && !done; iiter.Next()) {
Expand All @@ -1558,40 +1557,39 @@ Status BlockBasedTable::Get(const ReadOptions& read_options, const Slice& key,
RecordTick(rep_->ioptions.statistics, BLOOM_FILTER_USEFUL);
break;
} else {
BlockIter stack_biter;
biter = &stack_biter;
NewDataBlockIterator(rep_, read_options, iiter.value(), biter);
BlockIter biter;
NewDataBlockIterator(rep_, read_options, iiter.value(), &biter);

if (read_options.read_tier == kBlockCacheTier &&
biter->status().IsIncomplete()) {
biter.status().IsIncomplete()) {
// couldn't get block from block_cache
// Update Saver.state to Found because we are only looking for whether
// we can guarantee the key is not there when "no_io" is set
get_context->MarkKeyMayExist();
break;
}
if (!biter->status().ok()) {
s = biter->status();
if (!biter.status().ok()) {
s = biter.status();
break;
}

// Call the *saver function on each entry/block until it returns false
for (biter->Seek(key); biter->Valid(); biter->Next()) {
for (biter.Seek(key); biter.Valid(); biter.Next()) {
ParsedInternalKey parsed_key;
if (!ParseInternalKey(biter->key(), &parsed_key)) {
if (!ParseInternalKey(biter.key(), &parsed_key)) {
s = Status::Corruption(Slice());
}

if (!get_context->SaveValue(parsed_key, biter->value(), pin_blocks)) {
if (!get_context->SaveValue(parsed_key, biter.value(), pin_blocks)) {
done = true;
break;
}
}
s = biter->status();
s = biter.status();

if (pin_blocks && get_context->State() == GetContext::kMerge) {
// Pin blocks as long as we are merging
biter->DelegateCleanupsTo(pinned_iters_mgr);
biter.DelegateCleanupsTo(pinned_iters_mgr);
}
}
}
Expand Down
4 changes: 0 additions & 4 deletions table/cleanable_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
// 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.
//
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. See the AUTHORS file for names of contributors.

#include <functional>

Expand Down