You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by we...@apache.org on 2018/07/24 01:19:56 UTC
[arrow] branch master updated: ARROW-2586: [C++] Changing the type
of ListBuilder's and StructBuilder's children from unique_ptr to shared_ptr
so that it can support deserialization from Parquet to Arrow with arbitrary
nesting
This is an automated email from the ASF dual-hosted git repository.
wesm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new 566e398 ARROW-2586: [C++] Changing the type of ListBuilder's and StructBuilder's children from unique_ptr to shared_ptr so that it can support deserialization from Parquet to Arrow with arbitrary nesting
566e398 is described below
commit 566e398650b40292b1f6293eb80c8f09d2451f98
Author: Joshua Storck <jo...@twosigma.com>
AuthorDate: Mon Jul 23 21:16:38 2018 -0400
ARROW-2586: [C++] Changing the type of ListBuilder's and StructBuilder's children from unique_ptr to shared_ptr so that it can support deserialization from Parquet to Arrow with arbitrary nesting
This allows the class that is responsible for deserializing to hold a shared_ptr to the concrete type without having to static_cast from the (List|Struct)Builder's getters.
This was needed for https://github.com/apache/parquet-cpp/pull/462.
Author: Joshua Storck <jo...@twosigma.com>
Closes #2034 from joshuastorck/shared_ptr_in_builders and squashes the following commits:
d5aac220 <Joshua Storck> Fixing format errors
d6c6945f <Joshua Storck> Changing the type of ListBuilder's and StructBuilder's children from unique_ptr to shared_ptr so that it can support deserialization from Parquet to Arrow with arbitrary nesting. This allows the class that is responsible for deserializing to hold a shared_ptr to the concrete type without having to static_cast from the (List|Struct)Builder's getters.
---
cpp/src/arrow/builder.cc | 13 ++++++-------
cpp/src/arrow/builder.h | 9 +++++----
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/cpp/src/arrow/builder.cc b/cpp/src/arrow/builder.cc
index 152f1fc..b81d914 100644
--- a/cpp/src/arrow/builder.cc
+++ b/cpp/src/arrow/builder.cc
@@ -1273,14 +1273,15 @@ Status Decimal128Builder::FinishInternal(std::shared_ptr<ArrayData>* out) {
// ----------------------------------------------------------------------
// ListBuilder
-ListBuilder::ListBuilder(MemoryPool* pool, std::unique_ptr<ArrayBuilder> value_builder,
+ListBuilder::ListBuilder(MemoryPool* pool,
+ std::shared_ptr<ArrayBuilder> const& value_builder,
const std::shared_ptr<DataType>& type)
: ArrayBuilder(type ? type
: std::static_pointer_cast<DataType>(
std::make_shared<ListType>(value_builder->type())),
pool),
offsets_builder_(pool),
- value_builder_(std::move(value_builder)) {}
+ value_builder_(value_builder) {}
Status ListBuilder::AppendValues(const int32_t* offsets, int64_t length,
const uint8_t* valid_bytes) {
@@ -1620,10 +1621,8 @@ const uint8_t* FixedSizeBinaryBuilder::GetValue(int64_t i) const {
// Struct
StructBuilder::StructBuilder(const std::shared_ptr<DataType>& type, MemoryPool* pool,
- std::vector<std::unique_ptr<ArrayBuilder>>&& field_builders)
- : ArrayBuilder(type, pool) {
- field_builders_ = std::move(field_builders);
-}
+ std::vector<std::shared_ptr<ArrayBuilder>>&& field_builders)
+ : ArrayBuilder(type, pool), field_builders_(std::move(field_builders)) {}
void StructBuilder::Reset() {
ArrayBuilder::Reset();
@@ -1700,7 +1699,7 @@ Status MakeBuilder(MemoryPool* pool, const std::shared_ptr<DataType>& type,
case Type::STRUCT: {
const std::vector<std::shared_ptr<Field>>& fields = type->children();
- std::vector<std::unique_ptr<ArrayBuilder>> values_builder;
+ std::vector<std::shared_ptr<ArrayBuilder>> values_builder;
for (auto it : fields) {
std::unique_ptr<ArrayBuilder> builder;
diff --git a/cpp/src/arrow/builder.h b/cpp/src/arrow/builder.h
index 06093a2..0d60dbd 100644
--- a/cpp/src/arrow/builder.h
+++ b/cpp/src/arrow/builder.h
@@ -658,6 +658,7 @@ class ARROW_EXPORT AdaptiveIntBuilder : public internal::AdaptiveIntBuilderBase
class ARROW_EXPORT BooleanBuilder : public ArrayBuilder {
public:
+ using value_type = bool;
explicit BooleanBuilder(MemoryPool* pool ARROW_MEMORY_POOL_DEFAULT);
explicit BooleanBuilder(const std::shared_ptr<DataType>& type, MemoryPool* pool);
@@ -860,7 +861,7 @@ class ARROW_EXPORT ListBuilder : public ArrayBuilder {
public:
/// Use this constructor to incrementally build the value array along with offsets and
/// null bitmap.
- ListBuilder(MemoryPool* pool, std::unique_ptr<ArrayBuilder> value_builder,
+ ListBuilder(MemoryPool* pool, std::shared_ptr<ArrayBuilder> const& value_builder,
const std::shared_ptr<DataType>& type = NULLPTR);
Status Init(int64_t elements) override;
@@ -891,7 +892,7 @@ class ARROW_EXPORT ListBuilder : public ArrayBuilder {
protected:
TypedBufferBuilder<int32_t> offsets_builder_;
- std::unique_ptr<ArrayBuilder> value_builder_;
+ std::shared_ptr<ArrayBuilder> value_builder_;
std::shared_ptr<Array> values_;
Status AppendNextOffset();
@@ -1065,7 +1066,7 @@ using DecimalBuilder = Decimal128Builder;
class ARROW_EXPORT StructBuilder : public ArrayBuilder {
public:
StructBuilder(const std::shared_ptr<DataType>& type, MemoryPool* pool,
- std::vector<std::unique_ptr<ArrayBuilder>>&& field_builders);
+ std::vector<std::shared_ptr<ArrayBuilder>>&& field_builders);
Status FinishInternal(std::shared_ptr<ArrayData>* out) override;
@@ -1101,7 +1102,7 @@ class ARROW_EXPORT StructBuilder : public ArrayBuilder {
int num_fields() const { return static_cast<int>(field_builders_.size()); }
protected:
- std::vector<std::unique_ptr<ArrayBuilder>> field_builders_;
+ std::vector<std::shared_ptr<ArrayBuilder>> field_builders_;
};
// ----------------------------------------------------------------------