|
35 | 35 |
|
36 | 36 | namespace arrow { |
37 | 37 |
|
38 | | -/// Concrete Array class for numeric data. |
| 38 | +/// Concrete Array class for boolean data |
| 39 | +class ARROW_EXPORT BooleanArray : public PrimitiveArray { |
| 40 | + public: |
| 41 | + using TypeClass = BooleanType; |
| 42 | + using IteratorType = stl::ArrayIterator<BooleanArray>; |
| 43 | + |
| 44 | + explicit BooleanArray(const std::shared_ptr<ArrayData>& data); |
| 45 | + |
| 46 | + BooleanArray(int64_t length, const std::shared_ptr<Buffer>& data, |
| 47 | + const std::shared_ptr<Buffer>& null_bitmap = NULLPTR, |
| 48 | + int64_t null_count = kUnknownNullCount, int64_t offset = 0); |
| 49 | + |
| 50 | + bool Value(int64_t i) const { |
| 51 | + return BitUtil::GetBit(reinterpret_cast<const uint8_t*>(raw_values_), |
| 52 | + i + data_->offset); |
| 53 | + } |
| 54 | + |
| 55 | + bool GetView(int64_t i) const { return Value(i); } |
| 56 | + |
| 57 | + /// \brief Return the number of false (0) values among the valid |
| 58 | + /// values. Result is not cached. |
| 59 | + int64_t false_count() const; |
| 60 | + |
| 61 | + /// \brief Return the number of true (1) values among the valid |
| 62 | + /// values. Result is not cached. |
| 63 | + int64_t true_count() const; |
| 64 | + |
| 65 | + IteratorType begin() const { return IteratorType(*this); } |
| 66 | + |
| 67 | + IteratorType end() const { return IteratorType(*this, length()); } |
| 68 | + |
| 69 | + protected: |
| 70 | + using PrimitiveArray::PrimitiveArray; |
| 71 | +}; |
| 72 | + |
| 73 | +/// \addtogroup numeric-arrays |
| 74 | +/// |
| 75 | +/// @{ |
| 76 | + |
| 77 | +/// \brief Concrete Array class for numeric data with a corresponding C type |
| 78 | +/// |
| 79 | +/// This class is templated on the corresponding DataType subclass for the |
| 80 | +/// given data, for example NumericArray<Int8Type> or NumericArray<Date32Type>. |
| 81 | +/// |
| 82 | +/// Note that convenience aliases are available for all accepted types |
| 83 | +/// (for example Int8Array for NumericArray<Int8Type>). |
39 | 84 | template <typename TYPE> |
40 | 85 | class NumericArray : public PrimitiveArray { |
41 | 86 | public: |
@@ -72,41 +117,6 @@ class NumericArray : public PrimitiveArray { |
72 | 117 | using PrimitiveArray::PrimitiveArray; |
73 | 118 | }; |
74 | 119 |
|
75 | | -/// Concrete Array class for boolean data |
76 | | -class ARROW_EXPORT BooleanArray : public PrimitiveArray { |
77 | | - public: |
78 | | - using TypeClass = BooleanType; |
79 | | - using IteratorType = stl::ArrayIterator<BooleanArray>; |
80 | | - |
81 | | - explicit BooleanArray(const std::shared_ptr<ArrayData>& data); |
82 | | - |
83 | | - BooleanArray(int64_t length, const std::shared_ptr<Buffer>& data, |
84 | | - const std::shared_ptr<Buffer>& null_bitmap = NULLPTR, |
85 | | - int64_t null_count = kUnknownNullCount, int64_t offset = 0); |
86 | | - |
87 | | - bool Value(int64_t i) const { |
88 | | - return BitUtil::GetBit(reinterpret_cast<const uint8_t*>(raw_values_), |
89 | | - i + data_->offset); |
90 | | - } |
91 | | - |
92 | | - bool GetView(int64_t i) const { return Value(i); } |
93 | | - |
94 | | - /// \brief Return the number of false (0) values among the valid |
95 | | - /// values. Result is not cached. |
96 | | - int64_t false_count() const; |
97 | | - |
98 | | - /// \brief Return the number of true (1) values among the valid |
99 | | - /// values. Result is not cached. |
100 | | - int64_t true_count() const; |
101 | | - |
102 | | - IteratorType begin() const { return IteratorType(*this); } |
103 | | - |
104 | | - IteratorType end() const { return IteratorType(*this, length()); } |
105 | | - |
106 | | - protected: |
107 | | - using PrimitiveArray::PrimitiveArray; |
108 | | -}; |
109 | | - |
110 | 120 | /// DayTimeArray |
111 | 121 | /// --------------------- |
112 | 122 | /// \brief Array of Day and Millisecond values. |
@@ -163,4 +173,6 @@ class ARROW_EXPORT MonthDayNanoIntervalArray : public PrimitiveArray { |
163 | 173 | const uint8_t* raw_values() const { return raw_values_ + data_->offset * byte_width(); } |
164 | 174 | }; |
165 | 175 |
|
| 176 | +/// @} |
| 177 | + |
166 | 178 | } // namespace arrow |
0 commit comments