make_foreign_reader: don't wrap local readers

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 <bdenes@scylladb.com>
Message-Id: <886ed883b707f163603a40b56b8823f2bb6c47c6.1523873224.git.bdenes@scylladb.com>
This commit is contained in:
Botond Dénes
2018-04-16 15:08:37 +03:00
committed by Avi Kivity
parent 7c01e66d53
commit 07fb2e9c4d
2 changed files with 6 additions and 0 deletions

View File

@@ -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<std::unique_ptr<flat_mutation_reader>> reader,
streamed_mutation::forwarding fwd_sm) {
if (reader.get_owner_shard() == engine().cpu_id()) {
return std::move(*reader);
}
return make_flat_mutation_reader<foreign_reader>(std::move(schema), std::move(reader), fwd_sm);
}

View File

@@ -381,6 +381,9 @@ stable_flattened_mutations_consumer<FlattenedConsumer> 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<std::unique_ptr<flat_mutation_reader>> reader,
streamed_mutation::forwarding fwd_sm = streamed_mutation::forwarding::no);