37 using native_type =
typename World::runtime_family::native_type;
41 explicit typed_scan(World snapshot, std::optional<key_type> lo = {}, std::optional<key_type> hi = {},
42 range_positioning_work * work =
nullptr)
48 throw std::invalid_argument(
"reversed typed range");
68 if (!
state_ || !
state_->has_row())
throw std::out_of_range(
"typed range iterator end");
72 if (!
state_ || !
state_->has_row())
throw std::out_of_range(
"typed range iterator end");
81 friend bool operator==(
iterator const & value, std::default_sentinel_t) {
return value.at_end(); }
93 if (
failed_)
throw std::logic_error(
"failed typed scan");
96 std::default_sentinel_t
end() const noexcept {
return {}; }
103 if (
failed_)
throw std::logic_error(
"failed typed scan");
104 if (!
row_)
throw std::logic_error(
"typed scan has no row");
105 auto result = std::move(*
row_);
row_.reset();
return result;
107 std::optional<row_type>
next() {
108 if (
failed_)
throw std::logic_error(
"failed typed scan");
112 std::uint64_t
step(std::uint64_t budget) {
113 if (
failed_)
throw std::logic_error(
"failed typed scan");
115 std::uint64_t used = 0;
119 auto current =
sweep_.peek();
125 if (
upper_ && compare_bits<typename policy_type::architecture>(current.key.prefix,
upper_->view()) >= 0) {
finished_ =
true;
break; }
126 if (
lower_ && compare_bits<typename policy_type::architecture>(current.key.prefix,
lower_->view()) < 0) {
sweep_.consume(); ++used;
continue; }
128 if (order > 0) {
finished_ =
true;
break; }
129 if (order < 0) {
sweep_.consume(); ++used;
continue; }
133 auto value = semantics::initial(key);
136 if constexpr (typed_detail::replacement<S>) {
141 typed_detail::value<policy_type, S>(current.value));
147 }
catch (...) {
failed_ =
true;
throw; }
154 if (
failed_)
throw std::logic_error(
"failed typed scan");
156 typename World::contribution_type result{
snapshot_, {}};
157 result.observed_.emplace();
167 }
catch (...) {
failed_ =
true;
throw; }
171 std::shared_ptr<void const>
identity_ = std::make_shared<int const>(0);
183 auto order = compare_bits<typename policy_type::architecture>(key.subview(0, count),
prefix_.
view().
subview(0, count));
188 if constexpr (typed_detail::replacement<S>)
198 template <
class S =
void,
class World>
auto range(World snapshot,
201 std::optional<typed_detail::key_t<std::conditional_t<std::is_void_v<S>,
202 typed_detail::default_sort_t<typename World::policy_type>, S>>> hi = {},
203 range_positioning_work * work =
nullptr) {
204 using selected = std::conditional_t<std::is_void_v<S>, typed_detail::default_sort_t<typename World::policy_type>, S>;
205 return typed_scan<selected, World>(std::move(snapshot), std::move(lo), std::move(hi), work);
207 template <
class S =
void,
class World>
auto erase_range(World snapshot,
210 std::optional<typed_detail::key_t<std::conditional_t<std::is_void_v<S>,
211 typed_detail::default_sort_t<typename World::policy_type>, S>>> hi = {})
213 typed_detail::default_sort_t<typename World::policy_type>, S>> {
214 return range<S>(std::move(snapshot), std::move(lo), std::move(hi)).erase_remaining();
216 template <
class S =
void,
class World>
auto scan(World snapshot) {
224namespace std::ranges {
225 template <
class S,
class World>
226 inline constexpr bool enable_borrowed_range<everett::typed_scan<S, World>> =
true;
constexpr bool replacement
Definition typed_world.h:55
typename sort_codec< S >::key_codec::value_type key_t
Definition typed_world.h:52
typename default_sort< typename registry_detail::info< typename P::registry_type >::leaves >::type default_sort_t
Definition typed_world.h:51
typename sort_semantics< S >::state_type state_t
Definition typed_world.h:54
Definition active_engine.h:18
auto range(World snapshot, std::optional< typed_detail::key_t< std::conditional_t< std::is_void_v< S >, typed_detail::default_sort_t< typename World::policy_type >, S > > > lo={}, std::optional< typed_detail::key_t< std::conditional_t< std::is_void_v< S >, typed_detail::default_sort_t< typename World::policy_type >, S > > > hi={}, range_positioning_work *work=nullptr)
Definition typed_scan.h:198
auto erase_range(World snapshot, std::optional< typed_detail::key_t< std::conditional_t< std::is_void_v< S >, typed_detail::default_sort_t< typename World::policy_type >, S > > > lo={}, std::optional< typed_detail::key_t< std::conditional_t< std::is_void_v< S >, typed_detail::default_sort_t< typename World::policy_type >, S > > > hi={})
Definition typed_scan.h:207
bit_view view() const &
Definition profile.h:178
static bit_string copy(bit_view source)
Definition profile.h:181
std::uint64_t bit_size
Definition profile.h:168
bit_view subview(std::uint64_t first, std::uint64_t count) const
Definition profile.h:73
bit_view prefix(std::uint64_t count) const
Definition profile.h:80
Definition typed_world.h:31
Definition native_sweep.h:32
Definition typed_scan.h:19
typed_detail::key_t< S > key
Definition typed_scan.h:20
typed_detail::state_t< S > value
Definition typed_scan.h:21
Definition typed_scan.h:61
iterator & operator++()
Definition typed_scan.h:71
friend bool operator==(iterator const &a, iterator const &b)
Definition typed_scan.h:77
friend typed_scan
Definition typed_scan.h:83
std::forward_iterator_tag iterator_concept
Definition typed_scan.h:64
std::input_iterator_tag iterator_category
Definition typed_scan.h:65
value_type operator*() const
Definition typed_scan.h:67
iterator operator++(int)
Definition typed_scan.h:76
void settle()
Definition typed_scan.h:90
std::shared_ptr< typed_scan > state_
Definition typed_scan.h:84
bool at_end() const
Definition typed_scan.h:86
friend bool operator==(iterator const &value, std::default_sentinel_t)
Definition typed_scan.h:81
std::ptrdiff_t difference_type
Definition typed_scan.h:63
iterator(typed_scan const &value)
Definition typed_scan.h:85
bool same_position(iterator const &other) const
Definition typed_scan.h:87
Definition typed_scan.h:33
std::uint64_t last_retained_
Definition typed_scan.h:178
bool has_row() const noexcept
Definition typed_scan.h:99
typename World::runtime_family::native_type native_type
Definition typed_scan.h:37
bit_string group_key_
Definition typed_scan.h:173
bool done() const noexcept
Definition typed_scan.h:98
typed_scan(typed_scan const &)=default
iterator begin() const
Definition typed_scan.h:92
bit_string prefix_
Definition typed_scan.h:173
std::uint64_t step(std::uint64_t budget)
Definition typed_scan.h:112
row_type take_row()
Definition typed_scan.h:102
bool failed_
Definition typed_scan.h:179
bit_view last_value_
Definition typed_scan.h:177
std::optional< bit_string > upper_
Definition typed_scan.h:174
void finish_group()
Definition typed_scan.h:186
bool finished_
Definition typed_scan.h:179
std::optional< row_type > next()
Definition typed_scan.h:107
typed_scan(World snapshot, std::optional< key_type > lo={}, std::optional< key_type > hi={}, range_positioning_work *work=nullptr)
Definition typed_scan.h:41
typed_row< S > row_type
Definition typed_scan.h:35
std::default_sentinel_t end() const noexcept
Definition typed_scan.h:96
World snapshot_
Definition typed_scan.h:172
typed_scan & operator=(typed_scan const &)=default
typename World::key_transport key_transport
Definition typed_scan.h:38
std::uint64_t consumed() const noexcept
Definition typed_scan.h:101
typed_scan & operator=(typed_scan &&)=default
typed_scan(typed_scan &&)=default
std::optional< bit_string > lower_
Definition typed_scan.h:174
std::shared_ptr< void const > identity_
Definition typed_scan.h:171
typed_detail::key_t< S > key_type
Definition typed_scan.h:40
int compare_prefix(bit_view key) const
Definition typed_scan.h:181
std::optional< row_type > group_
Definition typed_scan.h:176
typed_detail::native_sweep< World > sweep_
Definition typed_scan.h:175
std::optional< row_type > row_
Definition typed_scan.h:176
typename World::policy_type policy_type
Definition typed_scan.h:34
auto erase_remaining()
Definition typed_scan.h:153
bool failed() const noexcept
Definition typed_scan.h:100
Connects sort-owned semantics to encoded COLA updates and immutable typed snapshots.