This is an automated email from the ASF dual-hosted git repository.
wjones127 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new 131f3eaa5a GH-34802: [C++][Parquet] Allow passing pool to decoder
(#34803)
131f3eaa5a is described below
commit 131f3eaa5a61902b49f6c82c83c2535e225cdf79
Author: mwish <[email protected]>
AuthorDate: Fri Mar 31 01:15:11 2023 +0800
GH-34802: [C++][Parquet] Allow passing pool to decoder (#34803)
### Rationale for this change
### What changes are included in this PR?
Add `::arrow::MemoryPool` to Decoder builder.
### Are these changes tested?
no
### Are there any user-facing changes?
Parquet user can pass memory pool to decoder now
* Closes: #34802
Authored-by: mwish <[email protected]>
Signed-off-by: Will Jones <[email protected]>
---
cpp/src/parquet/encoding.cc | 11 ++++++-----
cpp/src/parquet/encoding.h | 10 ++++++----
2 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/cpp/src/parquet/encoding.cc b/cpp/src/parquet/encoding.cc
index bfc81ad252..b4a08456b1 100644
--- a/cpp/src/parquet/encoding.cc
+++ b/cpp/src/parquet/encoding.cc
@@ -3417,7 +3417,8 @@ std::unique_ptr<Encoder> MakeEncoder(Type::type type_num,
Encoding::type encodin
}
std::unique_ptr<Decoder> MakeDecoder(Type::type type_num, Encoding::type
encoding,
- const ColumnDescriptor* descr) {
+ const ColumnDescriptor* descr,
+ ::arrow::MemoryPool* pool) {
if (encoding == Encoding::PLAIN) {
switch (type_num) {
case Type::BOOLEAN:
@@ -3451,21 +3452,21 @@ std::unique_ptr<Decoder> MakeDecoder(Type::type
type_num, Encoding::type encodin
} else if (encoding == Encoding::DELTA_BINARY_PACKED) {
switch (type_num) {
case Type::INT32:
- return std::make_unique<DeltaBitPackDecoder<Int32Type>>(descr);
+ return std::make_unique<DeltaBitPackDecoder<Int32Type>>(descr, pool);
case Type::INT64:
- return std::make_unique<DeltaBitPackDecoder<Int64Type>>(descr);
+ return std::make_unique<DeltaBitPackDecoder<Int64Type>>(descr, pool);
default:
throw ParquetException(
"DELTA_BINARY_PACKED decoder only supports INT32 and INT64");
}
} else if (encoding == Encoding::DELTA_BYTE_ARRAY) {
if (type_num == Type::BYTE_ARRAY) {
- return std::make_unique<DeltaByteArrayDecoder>(descr);
+ return std::make_unique<DeltaByteArrayDecoder>(descr, pool);
}
throw ParquetException("DELTA_BYTE_ARRAY only supports BYTE_ARRAY");
} else if (encoding == Encoding::DELTA_LENGTH_BYTE_ARRAY) {
if (type_num == Type::BYTE_ARRAY) {
- return std::make_unique<DeltaLengthByteArrayDecoder>(descr);
+ return std::make_unique<DeltaLengthByteArrayDecoder>(descr, pool);
}
throw ParquetException("DELTA_LENGTH_BYTE_ARRAY only supports BYTE_ARRAY");
} else if (encoding == Encoding::RLE) {
diff --git a/cpp/src/parquet/encoding.h b/cpp/src/parquet/encoding.h
index a1ab397ef9..9f9b740ff3 100644
--- a/cpp/src/parquet/encoding.h
+++ b/cpp/src/parquet/encoding.h
@@ -435,8 +435,9 @@ std::unique_ptr<typename EncodingTraits<DType>::Encoder>
MakeTypedEncoder(
}
PARQUET_EXPORT
-std::unique_ptr<Decoder> MakeDecoder(Type::type type_num, Encoding::type
encoding,
- const ColumnDescriptor* descr = NULLPTR);
+std::unique_ptr<Decoder> MakeDecoder(
+ Type::type type_num, Encoding::type encoding, const ColumnDescriptor*
descr = NULLPTR,
+ ::arrow::MemoryPool* pool = ::arrow::default_memory_pool());
namespace detail {
@@ -458,9 +459,10 @@ std::unique_ptr<DictDecoder<DType>> MakeDictDecoder(
template <typename DType>
std::unique_ptr<typename EncodingTraits<DType>::Decoder> MakeTypedDecoder(
- Encoding::type encoding, const ColumnDescriptor* descr = NULLPTR) {
+ Encoding::type encoding, const ColumnDescriptor* descr = NULLPTR,
+ ::arrow::MemoryPool* pool = ::arrow::default_memory_pool()) {
using OutType = typename EncodingTraits<DType>::Decoder;
- std::unique_ptr<Decoder> base = MakeDecoder(DType::type_num, encoding,
descr);
+ std::unique_ptr<Decoder> base = MakeDecoder(DType::type_num, encoding,
descr, pool);
return std::unique_ptr<OutType>(dynamic_cast<OutType*>(base.release()));
}