flat_mutation_reader_v2 was introduced in a pair of commits in 2021:e3309322c3"Clone flat_mutation_reader related classes into v2 variants"08b5773c12"Adapt flat_mutation_reader_v2 to the new version of the API" as a replacement for flat_mutation_reader, using range_tombstone_change instead of range_tombstone to represent represent range tombstones. See those commits for more information. The transition was incremental; the last use of the original flat_mutation_reader was removed in 2022 in commit026f8cc1e7"db: Use mutation_partition_v2 in mvcc" In turn, flat_mutation_reader was introduced in 2017 in commit748205ca75"Introduce flat_mutation_reader" To transition from a mutation_reader that nested rows within a partition in a separate stream, to a flat reader that streamed partitions and rows in the same stream. Here, we reclaim the original name and rename the awkward flat_mutation_reader_v2 to mutation_reader. Note that mutation_fragment_v2 remains since we still use the original for compatibilty, sometimes. Some notes about the transition: - files were also renamed. In one case (flat_mutation_reader_test.cc), the rename target already existed, so we rename to mutation_reader_another_test.cc. - a namespace 'mutation_reader' with two definitions existed (in mutation_reader_fwd.hh). Its contents was folded into the mutation_reader class. As a result, a few #includes had to be adjusted. Closes scylladb/scylladb#19356
70 lines
2.0 KiB
C++
70 lines
2.0 KiB
C++
/*
|
|
* Copyright (C) 2020-present ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
#include "readers/clustering_combined.hh"
|
|
#include "readers/mutation_reader.hh"
|
|
|
|
/*
|
|
* Single-partition reader, a lower bound and an upper bound for the set of positions
|
|
* of fragments returned by the reader. The bounds don't need to be exact.
|
|
*/
|
|
struct reader_bounds {
|
|
mutation_reader r;
|
|
position_in_partition lower;
|
|
position_in_partition upper;
|
|
};
|
|
|
|
/*
|
|
* Returns readers from an a-priori prepared set of readers with determined lower and upper bounds
|
|
* on the positions of their fragments.
|
|
*/
|
|
struct simple_position_reader_queue : public position_reader_queue {
|
|
position_in_partition::tri_compare _cmp;
|
|
|
|
using container_t = std::vector<reader_bounds>;
|
|
container_t _rs;
|
|
container_t::iterator _it;
|
|
|
|
simple_position_reader_queue(const schema& s, std::vector<reader_bounds> rs)
|
|
// precondition: rs sorted w.r.t lower.
|
|
// `s` must be kept alive until the last call to `pop` or `empty`.
|
|
: _cmp(s), _rs(std::move(rs)), _it(_rs.begin())
|
|
{ }
|
|
|
|
virtual ~simple_position_reader_queue() override = default;
|
|
|
|
virtual std::vector<reader_and_upper_bound> pop(position_in_partition_view bound) override {
|
|
if (empty(bound)) {
|
|
return {};
|
|
}
|
|
|
|
// !empty(bound) implies that _it->lower <= bound.
|
|
|
|
std::vector<reader_and_upper_bound> ret;
|
|
auto it = _it;
|
|
for (; it != _rs.end() && _cmp(_it->lower, it->lower) == 0; ++it) {
|
|
ret.emplace_back(std::move(it->r), std::move(it->upper));
|
|
}
|
|
_it = it;
|
|
return ret;
|
|
}
|
|
|
|
virtual bool empty(position_in_partition_view bound) const override {
|
|
return _it == _rs.end() || _cmp(bound, _it->lower) < 0;
|
|
}
|
|
|
|
virtual future<> close() noexcept override {
|
|
return do_for_each(_it, _rs.end(), [] (reader_bounds& rb) {
|
|
auto r = std::move(rb.r);
|
|
return r.close();
|
|
}).finally([this] {
|
|
_it = _rs.end();
|
|
});
|
|
}
|
|
};
|