From 07fb2e9c4dfd8363c9852f3fc3fad5670860d672 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Botond=20D=C3=A9nes?= Date: Mon, 16 Apr 2018 15:08:37 +0300 Subject: [PATCH] make_foreign_reader: don't wrap local readers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the to-be-wrapped reader is local (lives on the same shard where make_foreign_reader() is called) there is no need to wrap it with foreign_reader. Just return it as is. Signed-off-by: Botond Dénes Message-Id: <886ed883b707f163603a40b56b8823f2bb6c47c6.1523873224.git.bdenes@scylladb.com> --- mutation_reader.cc | 3 +++ mutation_reader.hh | 3 +++ 2 files changed, 6 insertions(+) diff --git a/mutation_reader.cc b/mutation_reader.cc index d816470719..8eb89110bf 100644 --- a/mutation_reader.cc +++ b/mutation_reader.cc @@ -977,6 +977,9 @@ future<> foreign_reader::fast_forward_to(position_range pr, db::timeout_clock::t flat_mutation_reader make_foreign_reader(schema_ptr schema, foreign_ptr> reader, streamed_mutation::forwarding fwd_sm) { + if (reader.get_owner_shard() == engine().cpu_id()) { + return std::move(*reader); + } return make_flat_mutation_reader(std::move(schema), std::move(reader), fwd_sm); } diff --git a/mutation_reader.hh b/mutation_reader.hh index e2556a6258..0a0d0477ce 100644 --- a/mutation_reader.hh +++ b/mutation_reader.hh @@ -381,6 +381,9 @@ stable_flattened_mutations_consumer make_stable_flattened_mut /// fast_forward_to() a read-ahead (a fill_buffer() on the remote reader) is /// issued. This read-ahead runs in the background and is brough back to /// foreground on the next fill_buffer() or fast_forward_to() call. +/// If the reader resides on this shard (the shard where make_foreign_reader() +/// is called) there is no need to wrap it in foreign_reader, just return it as +/// is. flat_mutation_reader make_foreign_reader(schema_ptr schema, foreign_ptr> reader, streamed_mutation::forwarding fwd_sm = streamed_mutation::forwarding::no);