Skip to content

Commit b8936d5

Browse files
committed
specialize in holder impl for strings
1 parent 903dfd6 commit b8936d5

3 files changed

Lines changed: 21 additions & 3 deletions

File tree

cpp/src/arrow/stl_allocator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace stl {
3232

3333
/// \brief A STL allocator delegating allocations to a Arrow MemoryPool
3434
template <class T>
35-
class allocator : public std::allocator<T> {
35+
class allocator {
3636
public:
3737
using value_type = T;
3838
using pointer = T*;

cpp/src/gandiva/gdv_function_stubs.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include <string>
2121
#include <vector>
2222

23-
#include "arrow/stl_allocator.h"
2423
#include "arrow/util/value_parsing.h"
2524
#include "gandiva/engine.h"
2625
#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,
9594
}
9695
gandiva::InHolder<std::string>* holder =
9796
reinterpret_cast<gandiva::InHolder<std::string>*>(ptr);
98-
return holder->HasValue(std::string(data, data_len, ::arrow::stl::allocator<char>()));
97+
return holder->HasValue(arrow::util::string_view(data, data_len));
9998
}
10099

101100
int32_t gdv_fn_populate_varlen_vector(int64_t context_ptr, int8_t* data_ptr,

cpp/src/gandiva/in_holder.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,23 @@ class InHolder {
4242
std::unordered_set<Type> values_;
4343
};
4444

45+
template <>
46+
class InHolder<std::string> {
47+
public:
48+
explicit InHolder(std::unordered_set<std::string> values) : values_(std::move(values)) {
49+
values_lookup_.max_load_factor(0.25f);
50+
for (const std::string& value : values_) {
51+
values_lookup_.emplace(value);
52+
}
53+
}
54+
55+
bool HasValue(arrow::util::string_view value) const {
56+
return values_lookup_.count(value) == 1;
57+
}
58+
59+
private:
60+
std::unordered_set<arrow::util::string_view> values_lookup_;
61+
const std::unordered_set<std::string> values_;
62+
};
63+
4564
} // namespace gandiva

0 commit comments

Comments
 (0)