42 trace.visit_column(LookupSettings::SRC_SELECTOR, [&](uint32_t row,
const FF&) {
43 auto src_values =
trace.get_multiple(LookupSettings::SRC_COLUMNS, row);
47 }
catch (
const std::runtime_error& e) {
49 throw std::runtime_error(std::string(e.what()) +
" at row " +
std::to_string(row));
52 trace.set(LookupSettings::COUNTS, dst_row,
trace.get(LookupSettings::COUNTS, dst_row) + 1);
56 trace.
set(LookupSettings::DST_SELECTOR, dst_row, 1,
true);
75template <
typename LookupSettings_>
101 LookupSettings::DST_COLUMNS,
111 const auto& rows = it->second;
112 for (uint32_t row : rows) {
118 throw std::runtime_error(
"Failed computing counts for " + std::string(LookupSettings::NAME) +
119 ". Could not find tuple in destination. " +
127 idx.reserve(
trace.get_column_rows(
this->outer_dst_selector));
129 auto dst_values =
trace.get_multiple(LookupSettings::DST_COLUMNS, row);
130 size_t key_hash = std::hash<
decltype(dst_values)>{}(dst_values);
132 auto& rows = idx[key_hash];
134 bool found_match =
false;
135 for (uint32_t existing_row : rows) {
136 if (
trace.get_multiple(LookupSettings::DST_COLUMNS, existing_row) == dst_values) {
177 uint32_t dst_row = 0;
182 std::vector<uint32_t> src_rows_in_order;
183 src_rows_in_order.reserve(
trace.get_column_rows(LookupSettings::SRC_SELECTOR));
184 trace.visit_column(LookupSettings::SRC_SELECTOR,
185 [&](uint32_t row,
const FF&) { src_rows_in_order.push_back(row); });
186 std::ranges::sort(src_rows_in_order.begin(), src_rows_in_order.end());
188 for (uint32_t row : src_rows_in_order) {
189 auto src_values =
trace.get_multiple(LookupSettings::SRC_COLUMNS, row);
193 while (!found && dst_row < max_dst_row) {
198 if (dst_selector == 1 && src_values ==
trace.get_multiple(LookupSettings::DST_COLUMNS, dst_row)) {
199 trace.set(LookupSettings::COUNTS, dst_row,
trace.get(LookupSettings::COUNTS, dst_row) + 1);
204 trace.
set(LookupSettings::DST_SELECTOR, dst_row, 1,
true);
216 throw std::runtime_error(
217 "Failed computing counts for " + std::string(LookupSettings::NAME) +
218 ". Could not find tuple in destination.\nSRC tuple (row " +
std::to_string(row) +
220 "\nNOTE: Remember that you cannot use LookupIntoDynamicTableSequential with a deduplicated trace!");
virtual uint32_t find_in_dst(const TupleType &tup) const =0
LookupSettings_ LookupSettings
virtual void init(TraceContainer &)
Column outer_dst_selector
IndexedLookupTraceBuilder(Column outer_dst_selector)
RefTuple< LookupSettings::LOOKUP_TUPLE_SIZE > TupleType
~IndexedLookupTraceBuilder() override=default
void process(TraceContainer &trace) override
IndexedLookupTraceBuilder()
LookupIntoDynamicTableGeneric(SharedIndexCache &cache, Column outer_dst_selector)
const TraceContainer * trace_ptr_
virtual ~LookupIntoDynamicTableGeneric()=default
const DstIndex * index_ptr_
LookupSettings_ LookupSettings
RefTuple< LookupSettings::LOOKUP_TUPLE_SIZE > TupleType
uint32_t find_in_dst(const TupleType &tup) const override
DstIndex build_index(const TraceContainer &trace)
LookupIntoDynamicTableGeneric(SharedIndexCache &cache)
void init(TraceContainer &trace) override
SharedIndexCache & cache_
size_t get_destination_columns_fingerprint() const override
LookupIntoDynamicTableSequential()
~LookupIntoDynamicTableSequential() override=default
Column outer_dst_selector
LookupIntoDynamicTableSequential(Column outer_dst_selector)
void process(TraceContainer &trace) override
const DstIndex & get_or_build(Column outer_dst_selector, std::span< const ColumnAndShifts > dst_columns, const TraceContainer &trace, const std::function< DstIndex(const TraceContainer &)> &build_fn)
void set(Column col, uint32_t row, const FF &value, bool use_atomic_limbs=false)
auto get_multiple(const std::array< ColumnAndShifts, N > &cols, uint32_t row) const
typename detail::RefTupleHelper< N >::type RefTuple
unordered_flat_map< size_t, std::vector< uint32_t > > DstIndex
std::string column_values_to_string(const std::array< FF, N > &arr, const std::array< ColumnAndShifts, N > &columns)
size_t hash_as_tuple(const Ts &... ts)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
std::string to_string(bb::avm2::ValueTag tag)