Skip to content
This repository has been archived by the owner on Sep 18, 2023. It is now read-only.

Commit

Permalink
reserve space for keys in hashmap
Browse files Browse the repository at this point in the history
Signed-off-by: Yuan Zhou <[email protected]>
  • Loading branch information
zhouyuan committed Feb 7, 2022
1 parent 5bcb60f commit 0732b33
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions native-sql-engine/cpp/src/precompile/hash_map.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace precompile {
typename arrow::internal::HashTraits<arrow::TYPENAME>::MemoTableType; \
class HASHMAPNAME::Impl : public MEMOTABLETYPE { \
public: \
Impl(arrow::MemoryPool* pool) : MEMOTABLETYPE(pool) {} \
Impl(arrow::MemoryPool* pool) : MEMOTABLETYPE(pool, 128) {} \
}; \
\
HASHMAPNAME::HASHMAPNAME(arrow::MemoryPool* pool) { \
Expand Down Expand Up @@ -107,6 +107,6 @@ TYPED_ARROW_HASH_MAP_IMPL(StringHashMap, StringType, arrow::util::string_view,
TYPED_ARROW_HASH_MAP_DECIMAL_IMPL(Decimal128HashMap, Decimal128Type, arrow::Decimal128,
DecimalMemoTableType)
#undef TYPED_ARROW_HASH_MAP_IMPL

#undef TYPED_ARROW_HASH_MAP_DECIMAL_IMPL
} // namespace precompile
} // namespace sparkcolumnarplugin
2 changes: 1 addition & 1 deletion native-sql-engine/cpp/src/precompile/unsafe_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class TypedUnsafeArray<DataType, enable_if_string_like<DataType>> : public Unsaf
if (!skip_null_check_ && typed_array_->IsNull(i)) {
setNullAt((*unsafe_row).get(), idx_);
} else {
auto v = typed_array_->GetString(i);
auto v = typed_array_->GetView(i);
appendToUnsafeRow((*unsafe_row).get(), idx_, v);
}
return arrow::Status::OK();
Expand Down
10 changes: 10 additions & 0 deletions native-sql-engine/cpp/src/third_party/row_wise_memory/unsafe_row.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,17 @@ static inline void appendToUnsafeRow(UnsafeRow* row, const int& index,
// move the cursor forward.
row->cursor += numBytes;
}
static inline void appendToUnsafeRow(UnsafeRow* row, const int& index,
arrow::util::string_view str) {
int numBytes = str.size();
// int roundedSize = roundNumberOfBytesToNearestWord(numBytes);

// zeroOutPaddingBytes(row, numBytes);
memcpy(row->data + row->cursor, str.data(), numBytes);

// move the cursor forward.
row->cursor += numBytes;
}
static inline void appendToUnsafeRow(UnsafeRow* row, const int& index,
const arrow::Decimal128& dcm) {
int numBytes = 16;
Expand Down

0 comments on commit 0732b33

Please sign in to comment.