From a2b1bd45750ebc13a41ba169d377547cc54bc4f8 Mon Sep 17 00:00:00 2001 From: Marcel Maltry Date: Thu, 4 Apr 2024 13:26:31 +0200 Subject: [PATCH] [Wasm] Add CLI argument to choose indexes for `IndexScan` --- src/backend/WasmOperator.cpp | 24 ++++++++++++++++++++++-- src/backend/WasmOperator.hpp | 9 +++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/backend/WasmOperator.cpp b/src/backend/WasmOperator.cpp index 0153b3be..bfe4e40c 100644 --- a/src/backend/WasmOperator.cpp +++ b/src/backend/WasmOperator.cpp @@ -100,6 +100,24 @@ static void add_wasm_operator_args() } } ); + C.arg_parser().add>( + /* group= */ "Wasm", + /* short= */ nullptr, + /* long= */ "--index-implementations", + /* description= */ "a comma separated list of index implementations to consider for index scans (`Array`, or" + " `Rmi`)", + /* callback= */ [](std::vector impls){ + options::index_implementations = option_configs::IndexImplementation(0UL); + for (const auto &elem : impls) { + if (strneq(elem.data(), "Array", elem.size())) + options::index_implementations |= option_configs::IndexImplementation::ARRAY; + else if (strneq(elem.data(), "Rmi", elem.size())) + options::index_implementations |= option_configs::IndexImplementation::RMI; + else + std::cerr << "warning: ignore invalid index implementation " << elem << std::endl; + } + } + ); C.arg_parser().add( /* group= */ "Wasm", /* short= */ nullptr, @@ -534,8 +552,10 @@ void m::register_wasm_operators(PhysicalOptimizer &phys_opt) phys_opt.register_operator>(); } if (bool(options::scan_implementations bitand option_configs::ScanImplementation::INDEX_SCAN)) { - phys_opt.register_operator>(); - phys_opt.register_operator>(); + if (bool(options::index_implementations bitand option_configs::IndexImplementation::ARRAY)) + phys_opt.register_operator>(); + if (bool(options::index_implementations bitand option_configs::IndexImplementation::RMI)) + phys_opt.register_operator>(); } if (bool(options::filter_selection_strategy bitand option_configs::SelectionStrategy::BRANCHING)) phys_opt.register_operator>(); diff --git a/src/backend/WasmOperator.hpp b/src/backend/WasmOperator.hpp index facd68e6..bbff9c7c 100644 --- a/src/backend/WasmOperator.hpp +++ b/src/backend/WasmOperator.hpp @@ -44,6 +44,12 @@ enum class JoinImplementation : uint64_t { SORT_MERGE = 0b100, }; +enum class IndexImplementation : uint64_t { + ALL = 0b11, + ARRAY = 0b01, + RMI = 0b10, +}; + enum class SoftPipelineBreakerStrategy : uint64_t { AFTER_ALL = 0b1111111, AFTER_SCAN = 0b0000001, @@ -120,6 +126,9 @@ inline option_configs::SortingImplementation sorting_implementations = option_co /** Which implementations should be considered for a `JoinOperator`. */ inline option_configs::JoinImplementation join_implementations = option_configs::JoinImplementation::ALL; +/** Which index implementations should be considered for an `IndexScan`. */ +inline option_configs::IndexImplementation index_implementations = option_configs::IndexImplementation::ALL; + /** Which index scan strategy should be used for `wasm::IndexScan`. */ inline option_configs::IndexScanStrategy index_scan_strategy = option_configs::IndexScanStrategy::INTERPRETATION;