| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| |
| |
|
|
| #pragma once |
|
|
| #include <cstdint> |
| #include <memory> |
|
|
| #include "arrow/array/array_base.h" |
| #include "arrow/array/data.h" |
| #include "arrow/stl_iterator.h" |
| #include "arrow/type.h" |
| #include "arrow/type_fwd.h" |
| #include "arrow/type_traits.h" |
| #include "arrow/util/bit_util.h" |
| #include "arrow/util/macros.h" |
| #include "arrow/util/visibility.h" |
|
|
| namespace arrow { |
|
|
| |
| class ARROW_EXPORT BooleanArray : public PrimitiveArray { |
| public: |
| using TypeClass = BooleanType; |
| using IteratorType = stl::ArrayIterator<BooleanArray>; |
|
|
| explicit BooleanArray(const std::shared_ptr<ArrayData>& data); |
|
|
| BooleanArray(int64_t length, const std::shared_ptr<Buffer>& data, |
| const std::shared_ptr<Buffer>& null_bitmap = NULLPTR, |
| int64_t null_count = kUnknownNullCount, int64_t offset = 0); |
|
|
| bool Value(int64_t i) const { |
| return bit_util::GetBit(reinterpret_cast<const uint8_t*>(raw_values_), |
| i + data_->offset); |
| } |
|
|
| bool GetView(int64_t i) const { return Value(i); } |
|
|
| std::optional<bool> operator[](int64_t i) const { return *IteratorType(*this, i); } |
|
|
| |
| |
| int64_t false_count() const; |
|
|
| |
| |
| int64_t true_count() const; |
|
|
| IteratorType begin() const { return IteratorType(*this); } |
|
|
| IteratorType end() const { return IteratorType(*this, length()); } |
|
|
| protected: |
| using PrimitiveArray::PrimitiveArray; |
| }; |
|
|
| |
| |
| |
|
|
| |
| |
| |
| |
| |
| |
| |
| template <typename TYPE> |
| class NumericArray : public PrimitiveArray { |
| public: |
| using TypeClass = TYPE; |
| using value_type = typename TypeClass::c_type; |
| using IteratorType = stl::ArrayIterator<NumericArray<TYPE>>; |
|
|
| explicit NumericArray(const std::shared_ptr<ArrayData>& data) { |
| NumericArray::SetData(data); |
| } |
|
|
| |
| |
| template <typename T1 = TYPE> |
| NumericArray(enable_if_parameter_free<T1, int64_t> length, |
| const std::shared_ptr<Buffer>& data, |
| const std::shared_ptr<Buffer>& null_bitmap = NULLPTR, |
| int64_t null_count = kUnknownNullCount, int64_t offset = 0) { |
| NumericArray::SetData(ArrayData::Make(TypeTraits<T1>::type_singleton(), length, |
| {null_bitmap, data}, null_count, offset)); |
| } |
|
|
| NumericArray(std::shared_ptr<DataType> type, int64_t length, |
| const std::shared_ptr<Buffer>& data, |
| const std::shared_ptr<Buffer>& null_bitmap = NULLPTR, |
| int64_t null_count = kUnknownNullCount, int64_t offset = 0) { |
| NumericArray::SetData(ArrayData::Make(std::move(type), length, {null_bitmap, data}, |
| null_count, offset)); |
| } |
|
|
| const value_type* raw_values() const { return values_; } |
|
|
| value_type Value(int64_t i) const { return values_[i]; } |
|
|
| |
| value_type GetView(int64_t i) const { return values_[i]; } |
|
|
| std::optional<value_type> operator[](int64_t i) const { |
| return *IteratorType(*this, i); |
| } |
|
|
| IteratorType begin() const { return IteratorType(*this); } |
|
|
| IteratorType end() const { return IteratorType(*this, length()); } |
|
|
| protected: |
| NumericArray() : values_(NULLPTR) {} |
|
|
| void SetData(const std::shared_ptr<ArrayData>& data) { |
| this->PrimitiveArray::SetData(data); |
| values_ = raw_values_ |
| ? (reinterpret_cast<const value_type*>(raw_values_) + data_->offset) |
| : NULLPTR; |
| } |
|
|
| const value_type* values_; |
| }; |
|
|
| |
| |
| |
| class ARROW_EXPORT DayTimeIntervalArray : public PrimitiveArray { |
| public: |
| using TypeClass = DayTimeIntervalType; |
| using IteratorType = stl::ArrayIterator<DayTimeIntervalArray>; |
|
|
| explicit DayTimeIntervalArray(const std::shared_ptr<ArrayData>& data); |
|
|
| DayTimeIntervalArray(const std::shared_ptr<DataType>& type, int64_t length, |
| const std::shared_ptr<Buffer>& data, |
| const std::shared_ptr<Buffer>& null_bitmap = NULLPTR, |
| int64_t null_count = kUnknownNullCount, int64_t offset = 0); |
|
|
| DayTimeIntervalArray(int64_t length, const std::shared_ptr<Buffer>& data, |
| const std::shared_ptr<Buffer>& null_bitmap = NULLPTR, |
| int64_t null_count = kUnknownNullCount, int64_t offset = 0); |
|
|
| TypeClass::DayMilliseconds GetValue(int64_t i) const; |
| TypeClass::DayMilliseconds Value(int64_t i) const { return GetValue(i); } |
|
|
| |
| TypeClass::DayMilliseconds GetView(int64_t i) const { return GetValue(i); } |
|
|
| IteratorType begin() const { return IteratorType(*this); } |
|
|
| IteratorType end() const { return IteratorType(*this, length()); } |
|
|
| std::optional<TypeClass::DayMilliseconds> operator[](int64_t i) const { |
| return *IteratorType(*this, i); |
| } |
|
|
| int32_t byte_width() const { return sizeof(TypeClass::DayMilliseconds); } |
|
|
| const uint8_t* raw_values() const { return raw_values_ + data_->offset * byte_width(); } |
| }; |
|
|
| |
| class ARROW_EXPORT MonthDayNanoIntervalArray : public PrimitiveArray { |
| public: |
| using TypeClass = MonthDayNanoIntervalType; |
| using IteratorType = stl::ArrayIterator<MonthDayNanoIntervalArray>; |
|
|
| explicit MonthDayNanoIntervalArray(const std::shared_ptr<ArrayData>& data); |
|
|
| MonthDayNanoIntervalArray(const std::shared_ptr<DataType>& type, int64_t length, |
| const std::shared_ptr<Buffer>& data, |
| const std::shared_ptr<Buffer>& null_bitmap = NULLPTR, |
| int64_t null_count = kUnknownNullCount, int64_t offset = 0); |
|
|
| MonthDayNanoIntervalArray(int64_t length, const std::shared_ptr<Buffer>& data, |
| const std::shared_ptr<Buffer>& null_bitmap = NULLPTR, |
| int64_t null_count = kUnknownNullCount, int64_t offset = 0); |
|
|
| TypeClass::MonthDayNanos GetValue(int64_t i) const; |
| TypeClass::MonthDayNanos Value(int64_t i) const { return GetValue(i); } |
|
|
| |
| TypeClass::MonthDayNanos GetView(int64_t i) const { return GetValue(i); } |
|
|
| IteratorType begin() const { return IteratorType(*this); } |
|
|
| IteratorType end() const { return IteratorType(*this, length()); } |
|
|
| std::optional<TypeClass::MonthDayNanos> operator[](int64_t i) const { |
| return *IteratorType(*this, i); |
| } |
|
|
| int32_t byte_width() const { return sizeof(TypeClass::MonthDayNanos); } |
|
|
| const uint8_t* raw_values() const { return raw_values_ + data_->offset * byte_width(); } |
| }; |
|
|
| |
|
|
| } |
|
|