diff --git a/cpp/src/arrow/stl_allocator.h b/cpp/src/arrow/stl_allocator.h index 192358f2a2f49..b5ad2b53460f0 100644 --- a/cpp/src/arrow/stl_allocator.h +++ b/cpp/src/arrow/stl_allocator.h @@ -32,7 +32,7 @@ namespace stl { /// \brief A STL allocator delegating allocations to a Arrow MemoryPool template -class allocator : public std::allocator { +class allocator { public: using value_type = T; using pointer = T*; diff --git a/cpp/src/gandiva/gdv_function_stubs.cc b/cpp/src/gandiva/gdv_function_stubs.cc index acf258bf41164..53253b02341d1 100644 --- a/cpp/src/gandiva/gdv_function_stubs.cc +++ b/cpp/src/gandiva/gdv_function_stubs.cc @@ -20,7 +20,6 @@ #include #include -#include "arrow/stl_allocator.h" #include "arrow/util/value_parsing.h" #include "gandiva/engine.h" #include "gandiva/exported_funcs.h" @@ -95,7 +94,7 @@ bool gdv_fn_in_expr_lookup_utf8(int64_t ptr, const char* data, int data_len, } gandiva::InHolder* holder = reinterpret_cast*>(ptr); - return holder->HasValue(std::string(data, data_len, ::arrow::stl::allocator())); + return holder->HasValue(arrow::util::string_view(data, data_len)); } int32_t gdv_fn_populate_varlen_vector(int64_t context_ptr, int8_t* data_ptr, diff --git a/cpp/src/gandiva/in_holder.h b/cpp/src/gandiva/in_holder.h index 3e18c25003834..84da7c3a384d7 100644 --- a/cpp/src/gandiva/in_holder.h +++ b/cpp/src/gandiva/in_holder.h @@ -42,4 +42,23 @@ class InHolder { std::unordered_set values_; }; +template <> +class InHolder { + public: + explicit InHolder(std::unordered_set values) : values_(std::move(values)) { + values_lookup_.max_load_factor(0.25f); + for (const std::string& value : values_) { + values_lookup_.emplace(value); + } + } + + bool HasValue(arrow::util::string_view value) const { + return values_lookup_.count(value) == 1; + } + + private: + std::unordered_set values_lookup_; + const std::unordered_set values_; +}; + } // namespace gandiva