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 2016/06/08 18:24:09 UTC
arrow git commit: ARROW-212: Change contract of PrimitiveArray to
reflect its abstractness
Repository: arrow
Updated Branches:
refs/heads/master bc6c4c88f -> 8197f246d
ARROW-212: Change contract of PrimitiveArray to reflect its abstractness
Follow-up based on #80
Author: Micah Kornfield <em...@gmail.com>
Closes #87 from emkornfield/emk_clarify_primitive and squashes the following commits:
14bd5b2 [Micah Kornfield] ARROW-212: Make the fact that PrimitiveArray is a abstract class more apparent fromt the contract
Project: http://git-wip-us.apache.org/repos/asf/arrow/repo
Commit: http://git-wip-us.apache.org/repos/asf/arrow/commit/8197f246
Tree: http://git-wip-us.apache.org/repos/asf/arrow/tree/8197f246
Diff: http://git-wip-us.apache.org/repos/asf/arrow/diff/8197f246
Branch: refs/heads/master
Commit: 8197f246de934db14b3af26a0899d95bffbdc6b2
Parents: bc6c4c8
Author: Micah Kornfield <em...@gmail.com>
Authored: Wed Jun 8 11:24:04 2016 -0700
Committer: Wes McKinney <we...@apache.org>
Committed: Wed Jun 8 11:24:04 2016 -0700
----------------------------------------------------------------------
cpp/src/arrow/types/primitive.cc | 5 +++++
cpp/src/arrow/types/primitive.h | 15 +++++++++------
2 files changed, 14 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/arrow/blob/8197f246/cpp/src/arrow/types/primitive.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/types/primitive.cc b/cpp/src/arrow/types/primitive.cc
index 8e6c0f8..08fc847 100644
--- a/cpp/src/arrow/types/primitive.cc
+++ b/cpp/src/arrow/types/primitive.cc
@@ -162,6 +162,11 @@ BooleanArray::BooleanArray(int32_t length, const std::shared_ptr<Buffer>& data,
: PrimitiveArray(
std::make_shared<BooleanType>(), length, data, null_count, null_bitmap) {}
+BooleanArray::BooleanArray(const TypePtr& type, int32_t length,
+ const std::shared_ptr<Buffer>& data, int32_t null_count,
+ const std::shared_ptr<Buffer>& null_bitmap)
+ : PrimitiveArray(type, length, data, null_count, null_bitmap) {}
+
bool BooleanArray::EqualsExact(const BooleanArray& other) const {
if (this == &other) return true;
if (null_count_ != other.null_count_) { return false; }
http://git-wip-us.apache.org/repos/asf/arrow/blob/8197f246/cpp/src/arrow/types/primitive.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/types/primitive.h b/cpp/src/arrow/types/primitive.h
index 9597fc8..f1ec417 100644
--- a/cpp/src/arrow/types/primitive.h
+++ b/cpp/src/arrow/types/primitive.h
@@ -34,11 +34,10 @@ namespace arrow {
class MemoryPool;
-// Base class for fixed-size logical types
+// Base class for fixed-size logical types. See MakePrimitiveArray
+// (types/construct.h) for constructing a specific subclass.
class PrimitiveArray : public Array {
public:
- PrimitiveArray(const TypePtr& type, int32_t length, const std::shared_ptr<Buffer>& data,
- int32_t null_count = 0, const std::shared_ptr<Buffer>& null_bitmap = nullptr);
virtual ~PrimitiveArray() {}
const std::shared_ptr<Buffer>& data() const { return data_; }
@@ -47,6 +46,8 @@ class PrimitiveArray : public Array {
bool Equals(const std::shared_ptr<Array>& arr) const override;
protected:
+ PrimitiveArray(const TypePtr& type, int32_t length, const std::shared_ptr<Buffer>& data,
+ int32_t null_count = 0, const std::shared_ptr<Buffer>& null_bitmap = nullptr);
std::shared_ptr<Buffer> data_;
const uint8_t* raw_data_;
};
@@ -55,12 +56,14 @@ class PrimitiveArray : public Array {
class NAME : public PrimitiveArray { \
public: \
using value_type = T; \
- using PrimitiveArray::PrimitiveArray; \
\
NAME(int32_t length, const std::shared_ptr<Buffer>& data, int32_t null_count = 0, \
const std::shared_ptr<Buffer>& null_bitmap = nullptr) \
: PrimitiveArray( \
std::make_shared<TypeClass>(), length, data, null_count, null_bitmap) {} \
+ NAME(const TypePtr& type, int32_t length, const std::shared_ptr<Buffer>& data, \
+ int32_t null_count = 0, const std::shared_ptr<Buffer>& null_bitmap = nullptr) \
+ : PrimitiveArray(type, length, data, null_count, null_bitmap) {} \
\
bool EqualsExact(const NAME& other) const { \
return PrimitiveArray::EqualsExact(*static_cast<const PrimitiveArray*>(&other)); \
@@ -261,10 +264,10 @@ typedef NumericBuilder<DoubleType> DoubleBuilder;
class BooleanArray : public PrimitiveArray {
public:
- using PrimitiveArray::PrimitiveArray;
-
BooleanArray(int32_t length, const std::shared_ptr<Buffer>& data,
int32_t null_count = 0, const std::shared_ptr<Buffer>& null_bitmap = nullptr);
+ BooleanArray(const TypePtr& type, int32_t length, const std::shared_ptr<Buffer>& data,
+ int32_t null_count = 0, const std::shared_ptr<Buffer>& null_bitmap = nullptr);
bool EqualsExact(const BooleanArray& other) const;
bool Equals(const ArrayPtr& arr) const override;