Apache Arrow (C++)
A columnar in-memory analytics layer designed to accelerate big data.
array.h
Go to the documentation of this file.
1 // Licensed to the Apache Software Foundation (ASF) under one
2 // or more contributor license agreements. See the NOTICE file
3 // distributed with this work for additional information
4 // regarding copyright ownership. The ASF licenses this file
5 // to you under the Apache License, Version 2.0 (the
6 // "License"); you may not use this file except in compliance
7 // with the License. You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing,
12 // software distributed under the License is distributed on an
13 // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 // KIND, either express or implied. See the License for the
15 // specific language governing permissions and limitations
16 // under the License.
17 
18 #ifndef ARROW_ARRAY_H
19 #define ARROW_ARRAY_H
20 
21 #include <cstddef>
22 #include <cstdint>
23 #include <iosfwd>
24 #include <memory>
25 #include <string>
26 #include <type_traits>
27 #include <utility>
28 #include <vector>
29 
30 #include "arrow/buffer.h"
31 #include "arrow/type.h"
32 #include "arrow/type_traits.h"
33 #include "arrow/util/bit-util.h"
35 #include "arrow/util/macros.h"
36 #include "arrow/util/visibility.h"
37 
38 namespace arrow {
39 
40 class Array;
41 class ArrayVisitor;
42 
43 using BufferVector = std::vector<std::shared_ptr<Buffer>>;
44 
45 // When slicing, we do not know the null count of the sliced range without
46 // doing some computation. To avoid doing this eagerly, we set the null count
47 // to -1 (any negative number will do). When Array::null_count is called the
48 // first time, the null count will be computed. See ARROW-33
49 constexpr int64_t kUnknownNullCount = -1;
50 
51 class MemoryPool;
52 class Status;
53 
54 // ----------------------------------------------------------------------
55 // Generic array data container
56 
88 struct ARROW_EXPORT ArrayData {
89  ArrayData() : length(0) {}
90 
91  ArrayData(const std::shared_ptr<DataType>& type, int64_t length,
92  int64_t null_count = kUnknownNullCount, int64_t offset = 0)
93  : type(type), length(length), null_count(null_count), offset(offset) {}
94 
95  ArrayData(const std::shared_ptr<DataType>& type, int64_t length,
96  const std::vector<std::shared_ptr<Buffer>>& buffers,
97  int64_t null_count = kUnknownNullCount, int64_t offset = 0)
98  : ArrayData(type, length, null_count, offset) {
99  this->buffers = buffers;
100  }
101 
102  ArrayData(const std::shared_ptr<DataType>& type, int64_t length,
103  const std::vector<std::shared_ptr<Buffer>>& buffers,
104  const std::vector<std::shared_ptr<ArrayData>>& child_data,
105  int64_t null_count = kUnknownNullCount, int64_t offset = 0)
106  : ArrayData(type, length, null_count, offset) {
107  this->buffers = buffers;
108  this->child_data = child_data;
109  }
110 
111  ArrayData(const std::shared_ptr<DataType>& type, int64_t length,
112  std::vector<std::shared_ptr<Buffer>>&& buffers,
113  int64_t null_count = kUnknownNullCount, int64_t offset = 0)
114  : ArrayData(type, length, null_count, offset) {
115  this->buffers = std::move(buffers);
116  }
117 
118  static std::shared_ptr<ArrayData> Make(const std::shared_ptr<DataType>& type,
119  int64_t length,
120  std::vector<std::shared_ptr<Buffer>>&& buffers,
121  int64_t null_count = kUnknownNullCount,
122  int64_t offset = 0);
123 
124  static std::shared_ptr<ArrayData> Make(
125  const std::shared_ptr<DataType>& type, int64_t length,
126  const std::vector<std::shared_ptr<Buffer>>& buffers,
127  int64_t null_count = kUnknownNullCount, int64_t offset = 0);
128 
129  static std::shared_ptr<ArrayData> Make(
130  const std::shared_ptr<DataType>& type, int64_t length,
131  const std::vector<std::shared_ptr<Buffer>>& buffers,
132  const std::vector<std::shared_ptr<ArrayData>>& child_data,
133  int64_t null_count = kUnknownNullCount, int64_t offset = 0);
134 
135  static std::shared_ptr<ArrayData> Make(const std::shared_ptr<DataType>& type,
136  int64_t length,
137  int64_t null_count = kUnknownNullCount,
138  int64_t offset = 0);
139 
140  // Move constructor
141  ArrayData(ArrayData&& other) noexcept
142  : type(std::move(other.type)),
143  length(other.length),
144  null_count(other.null_count),
145  offset(other.offset),
146  buffers(std::move(other.buffers)),
147  child_data(std::move(other.child_data)) {}
148 
149  ArrayData(const ArrayData& other) noexcept
150  : type(other.type),
151  length(other.length),
152  null_count(other.null_count),
153  offset(other.offset),
154  buffers(other.buffers),
155  child_data(other.child_data) {}
156 
157  // Move assignment
159  type = std::move(other.type);
160  length = other.length;
161  null_count = other.null_count;
162  offset = other.offset;
163  buffers = std::move(other.buffers);
164  child_data = std::move(other.child_data);
165  return *this;
166  }
167 
168  std::shared_ptr<ArrayData> Copy() const { return std::make_shared<ArrayData>(*this); }
169 
170  std::shared_ptr<DataType> type;
171  int64_t length;
172  int64_t null_count;
173  // The logical start point into the physical buffers (in values, not bytes).
174  // Note that, for child data, this must be *added* to the child data's own offset.
175  int64_t offset;
176  std::vector<std::shared_ptr<Buffer>> buffers;
177  std::vector<std::shared_ptr<ArrayData>> child_data;
178 };
179 
183 ARROW_EXPORT
184 std::shared_ptr<Array> MakeArray(const std::shared_ptr<ArrayData>& data);
185 
186 // ----------------------------------------------------------------------
187 // User array accessor types
188 
200 class ARROW_EXPORT Array {
201  public:
202  virtual ~Array() = default;
203 
205  bool IsNull(int64_t i) const {
206  return null_bitmap_data_ != NULLPTR &&
207  !BitUtil::GetBit(null_bitmap_data_, i + data_->offset);
208  }
209 
212  bool IsValid(int64_t i) const {
213  return null_bitmap_data_ == NULLPTR ||
214  BitUtil::GetBit(null_bitmap_data_, i + data_->offset);
215  }
216 
218  int64_t length() const { return data_->length; }
219 
222  int64_t offset() const { return data_->offset; }
223 
228  int64_t null_count() const;
229 
230  std::shared_ptr<DataType> type() const { return data_->type; }
231  Type::type type_id() const { return data_->type->id(); }
232 
237  std::shared_ptr<Buffer> null_bitmap() const { return data_->buffers[0]; }
238 
243  const uint8_t* null_bitmap_data() const { return null_bitmap_data_; }
244 
245  bool Equals(const Array& arr) const;
246  bool Equals(const std::shared_ptr<Array>& arr) const;
247 
248  bool ApproxEquals(const std::shared_ptr<Array>& arr) const;
249  bool ApproxEquals(const Array& arr) const;
250 
253  bool RangeEquals(int64_t start_idx, int64_t end_idx, int64_t other_start_idx,
254  const std::shared_ptr<Array>& other) const;
255 
256  bool RangeEquals(const Array& other, int64_t start_idx, int64_t end_idx,
257  int64_t other_start_idx) const;
258 
259  Status Accept(ArrayVisitor* visitor) const;
260 
270  std::shared_ptr<Array> Slice(int64_t offset, int64_t length) const;
271 
273  std::shared_ptr<Array> Slice(int64_t offset) const;
274 
275  std::shared_ptr<ArrayData> data() const { return data_; }
276 
277  int num_fields() const { return static_cast<int>(data_->child_data.size()); }
278 
280  std::string ToString() const;
281 
282  protected:
283  Array() {}
284 
285  std::shared_ptr<ArrayData> data_;
286  const uint8_t* null_bitmap_data_;
287 
289  inline void SetData(const std::shared_ptr<ArrayData>& data) {
290  if (data->buffers.size() > 0 && data->buffers[0]) {
291  null_bitmap_data_ = data->buffers[0]->data();
292  } else {
293  null_bitmap_data_ = NULLPTR;
294  }
295  data_ = data;
296  }
297 
298  private:
300 };
301 
302 using ArrayVector = std::vector<std::shared_ptr<Array>>;
303 
304 namespace internal {
305 
310 ARROW_EXPORT
311 std::vector<ArrayVector> RechunkArraysConsistently(const std::vector<ArrayVector>&);
312 
313 } // namespace internal
314 
315 static inline std::ostream& operator<<(std::ostream& os, const Array& x) {
316  os << x.ToString();
317  return os;
318 }
319 
321 class ARROW_EXPORT FlatArray : public Array {
322  protected:
323  using Array::Array;
324 };
325 
327 class ARROW_EXPORT NullArray : public FlatArray {
328  public:
330 
331  explicit NullArray(const std::shared_ptr<ArrayData>& data) { SetData(data); }
332  explicit NullArray(int64_t length);
333 
334  private:
335  inline void SetData(const std::shared_ptr<ArrayData>& data) {
336  null_bitmap_data_ = NULLPTR;
337  data->null_count = data->length;
338  data_ = data;
339  }
340 };
341 
343 class ARROW_EXPORT PrimitiveArray : public FlatArray {
344  public:
345  PrimitiveArray(const std::shared_ptr<DataType>& type, int64_t length,
346  const std::shared_ptr<Buffer>& data,
347  const std::shared_ptr<Buffer>& null_bitmap = NULLPTR,
348  int64_t null_count = 0, int64_t offset = 0);
349 
351  std::shared_ptr<Buffer> values() const { return data_->buffers[1]; }
352 
353  protected:
355 
356  inline void SetData(const std::shared_ptr<ArrayData>& data) {
357  auto values = data->buffers[1];
358  this->Array::SetData(data);
359  raw_values_ = values == NULLPTR ? NULLPTR : values->data();
360  }
361 
362  explicit inline PrimitiveArray(const std::shared_ptr<ArrayData>& data) {
363  SetData(data);
364  }
365 
366  const uint8_t* raw_values_;
367 };
368 
369 template <typename TYPE>
370 class ARROW_EXPORT NumericArray : public PrimitiveArray {
371  public:
372  using TypeClass = TYPE;
373  using value_type = typename TypeClass::c_type;
374 
375  explicit NumericArray(const std::shared_ptr<ArrayData>& data);
376 
377  // Only enable this constructor without a type argument for types without additional
378  // metadata
379  template <typename T1 = TYPE>
381  typename std::enable_if<TypeTraits<T1>::is_parameter_free, int64_t>::type length,
382  const std::shared_ptr<Buffer>& data,
383  const std::shared_ptr<Buffer>& null_bitmap = NULLPTR, int64_t null_count = 0,
384  int64_t offset = 0)
385  : PrimitiveArray(TypeTraits<T1>::type_singleton(), length, data, null_bitmap,
386  null_count, offset) {}
387 
388  const value_type* raw_values() const {
389  return reinterpret_cast<const value_type*>(raw_values_) + data_->offset;
390  }
391 
392  value_type Value(int64_t i) const { return raw_values()[i]; }
393 
394  protected:
396 };
397 
399 class ARROW_EXPORT BooleanArray : public PrimitiveArray {
400  public:
402 
403  explicit BooleanArray(const std::shared_ptr<ArrayData>& data);
404 
405  BooleanArray(int64_t length, const std::shared_ptr<Buffer>& data,
406  const std::shared_ptr<Buffer>& null_bitmap = NULLPTR,
407  int64_t null_count = 0, int64_t offset = 0);
408 
409  bool Value(int64_t i) const {
410  return BitUtil::GetBit(reinterpret_cast<const uint8_t*>(raw_values_),
411  i + data_->offset);
412  }
413 
414  protected:
416 };
417 
418 // ----------------------------------------------------------------------
419 // ListArray
420 
422 class ARROW_EXPORT ListArray : public Array {
423  public:
425 
426  explicit ListArray(const std::shared_ptr<ArrayData>& data);
427 
428  ListArray(const std::shared_ptr<DataType>& type, int64_t length,
429  const std::shared_ptr<Buffer>& value_offsets,
430  const std::shared_ptr<Array>& values,
431  const std::shared_ptr<Buffer>& null_bitmap = NULLPTR, int64_t null_count = 0,
432  int64_t offset = 0);
433 
447  static Status FromArrays(const Array& offsets, const Array& values, MemoryPool* pool,
448  std::shared_ptr<Array>* out);
449 
451  std::shared_ptr<Array> values() const;
452 
454  std::shared_ptr<Buffer> value_offsets() const { return data_->buffers[1]; }
455 
456  std::shared_ptr<DataType> value_type() const;
457 
459  const int32_t* raw_value_offsets() const { return raw_value_offsets_ + data_->offset; }
460 
461  // Neither of these functions will perform boundschecking
462  int32_t value_offset(int64_t i) const { return raw_value_offsets_[i + data_->offset]; }
463  int32_t value_length(int64_t i) const {
464  i += data_->offset;
465  return raw_value_offsets_[i + 1] - raw_value_offsets_[i];
466  }
467 
468  protected:
469  void SetData(const std::shared_ptr<ArrayData>& data);
470  const int32_t* raw_value_offsets_;
471 
472  private:
473  std::shared_ptr<Array> values_;
474 };
475 
476 // ----------------------------------------------------------------------
477 // Binary and String
478 
480 class ARROW_EXPORT BinaryArray : public FlatArray {
481  public:
483 
484  explicit BinaryArray(const std::shared_ptr<ArrayData>& data);
485 
486  BinaryArray(int64_t length, const std::shared_ptr<Buffer>& value_offsets,
487  const std::shared_ptr<Buffer>& data,
488  const std::shared_ptr<Buffer>& null_bitmap = NULLPTR,
489  int64_t null_count = 0, int64_t offset = 0);
490 
491  // Return the pointer to the given elements bytes
492  // TODO(emkornfield) introduce a StringPiece or something similar to capture zero-copy
493  // pointer + offset
494  const uint8_t* GetValue(int64_t i, int32_t* out_length) const {
495  // Account for base offset
496  i += data_->offset;
497 
498  const int32_t pos = raw_value_offsets_[i];
499  *out_length = raw_value_offsets_[i + 1] - pos;
500  return raw_data_ + pos;
501  }
502 
507  std::string GetString(int64_t i) const {
508  int32_t length = 0;
509  const uint8_t* bytes = GetValue(i, &length);
510  return std::string(reinterpret_cast<const char*>(bytes), static_cast<size_t>(length));
511  }
512 
514  std::shared_ptr<Buffer> value_offsets() const { return data_->buffers[1]; }
515 
517  std::shared_ptr<Buffer> value_data() const { return data_->buffers[2]; }
518 
519  const int32_t* raw_value_offsets() const { return raw_value_offsets_ + data_->offset; }
520 
521  // Neither of these functions will perform boundschecking
522  int32_t value_offset(int64_t i) const { return raw_value_offsets_[i + data_->offset]; }
523  int32_t value_length(int64_t i) const {
524  i += data_->offset;
525  return raw_value_offsets_[i + 1] - raw_value_offsets_[i];
526  }
527 
528  protected:
529  // For subclasses
531 
533  void SetData(const std::shared_ptr<ArrayData>& data);
534 
535  // Constructor that allows sub-classes/builders to propagate there logical type up the
536  // class hierarchy.
537  BinaryArray(const std::shared_ptr<DataType>& type, int64_t length,
538  const std::shared_ptr<Buffer>& value_offsets,
539  const std::shared_ptr<Buffer>& data,
540  const std::shared_ptr<Buffer>& null_bitmap = NULLPTR,
541  int64_t null_count = 0, int64_t offset = 0);
542 
543  const int32_t* raw_value_offsets_;
544  const uint8_t* raw_data_;
545 };
546 
548 class ARROW_EXPORT StringArray : public BinaryArray {
549  public:
551 
552  explicit StringArray(const std::shared_ptr<ArrayData>& data);
553 
554  StringArray(int64_t length, const std::shared_ptr<Buffer>& value_offsets,
555  const std::shared_ptr<Buffer>& data,
556  const std::shared_ptr<Buffer>& null_bitmap = NULLPTR,
557  int64_t null_count = 0, int64_t offset = 0);
558 
559  // Construct a std::string
560  // TODO: std::bad_alloc possibility
561  std::string GetString(int64_t i) const {
562  int32_t nchars;
563  const uint8_t* str = GetValue(i, &nchars);
564  return std::string(reinterpret_cast<const char*>(str), nchars);
565  }
566 };
567 
568 // ----------------------------------------------------------------------
569 // Fixed width binary
570 
572 class ARROW_EXPORT FixedSizeBinaryArray : public PrimitiveArray {
573  public:
575 
576  explicit FixedSizeBinaryArray(const std::shared_ptr<ArrayData>& data);
577 
578  FixedSizeBinaryArray(const std::shared_ptr<DataType>& type, int64_t length,
579  const std::shared_ptr<Buffer>& data,
580  const std::shared_ptr<Buffer>& null_bitmap = NULLPTR,
581  int64_t null_count = 0, int64_t offset = 0);
582 
583  const uint8_t* GetValue(int64_t i) const;
584  const uint8_t* Value(int64_t i) const { return GetValue(i); }
585 
586  int32_t byte_width() const { return byte_width_; }
587 
588  const uint8_t* raw_values() const { return raw_values_ + data_->offset * byte_width_; }
589 
590  protected:
591  inline void SetData(const std::shared_ptr<ArrayData>& data) {
592  this->PrimitiveArray::SetData(data);
593  byte_width_ =
594  internal::checked_cast<const FixedSizeBinaryType&>(*type()).byte_width();
595  }
596 
597  int32_t byte_width_;
598 };
599 
600 // ----------------------------------------------------------------------
601 // Decimal128Array
602 
604 class ARROW_EXPORT Decimal128Array : public FixedSizeBinaryArray {
605  public:
607 
609 
611  explicit Decimal128Array(const std::shared_ptr<ArrayData>& data);
612 
613  std::string FormatValue(int64_t i) const;
614 };
615 
616 // Backward compatibility
618 
619 // ----------------------------------------------------------------------
620 // Struct
621 
623 class ARROW_EXPORT StructArray : public Array {
624  public:
626 
627  explicit StructArray(const std::shared_ptr<ArrayData>& data);
628 
629  StructArray(const std::shared_ptr<DataType>& type, int64_t length,
630  const std::vector<std::shared_ptr<Array>>& children,
631  std::shared_ptr<Buffer> null_bitmap = NULLPTR, int64_t null_count = 0,
632  int64_t offset = 0);
633 
634  // Return a shared pointer in case the requestor desires to share ownership
635  // with this array. The returned array has its offset, length and null
636  // count adjusted.
637  std::shared_ptr<Array> field(int pos) const;
638 
643  Status Flatten(MemoryPool* pool, ArrayVector* out) const;
644 
645  private:
646  // For caching boxed child data
647  mutable std::vector<std::shared_ptr<Array>> boxed_fields_;
648 };
649 
650 // ----------------------------------------------------------------------
651 // Union
652 
654 class ARROW_EXPORT UnionArray : public Array {
655  public:
657  using type_id_t = uint8_t;
658 
659  explicit UnionArray(const std::shared_ptr<ArrayData>& data);
660 
661  UnionArray(const std::shared_ptr<DataType>& type, int64_t length,
662  const std::vector<std::shared_ptr<Array>>& children,
663  const std::shared_ptr<Buffer>& type_ids,
664  const std::shared_ptr<Buffer>& value_offsets = NULLPTR,
665  const std::shared_ptr<Buffer>& null_bitmap = NULLPTR, int64_t null_count = 0,
666  int64_t offset = 0);
667 
680  static Status MakeDense(const Array& type_ids, const Array& value_offsets,
681  const std::vector<std::shared_ptr<Array>>& children,
682  std::shared_ptr<Array>* out);
683 
693  static Status MakeSparse(const Array& type_ids,
694  const std::vector<std::shared_ptr<Array>>& children,
695  std::shared_ptr<Array>* out);
696 
698  std::shared_ptr<Buffer> type_ids() const { return data_->buffers[1]; }
699 
701  std::shared_ptr<Buffer> value_offsets() const { return data_->buffers[2]; }
702 
703  int32_t value_offset(int64_t i) const { return raw_value_offsets_[i + data_->offset]; }
704 
705  const type_id_t* raw_type_ids() const { return raw_type_ids_ + data_->offset; }
706  const int32_t* raw_value_offsets() const { return raw_value_offsets_ + data_->offset; }
707 
709  return internal::checked_cast<const UnionType&>(*type()).mode();
710  }
711 
712  // Return the given field as an individual array.
713  // For sparse unions, the returned array has its offset, length and null
714  // count adjusted.
715  // For dense unions, the returned array is unchanged.
716  std::shared_ptr<Array> child(int pos) const;
717 
719  const Array* UnsafeChild(int pos) const;
720 
721  protected:
722  void SetData(const std::shared_ptr<ArrayData>& data);
723 
725  const int32_t* raw_value_offsets_;
726 
727  // For caching boxed child data
728  mutable std::vector<std::shared_ptr<Array>> boxed_fields_;
729 };
730 
731 // ----------------------------------------------------------------------
732 // DictionaryArray (categorical and dictionary-encoded in memory)
733 
751 class ARROW_EXPORT DictionaryArray : public Array {
752  public:
754 
755  explicit DictionaryArray(const std::shared_ptr<ArrayData>& data);
756 
757  DictionaryArray(const std::shared_ptr<DataType>& type,
758  const std::shared_ptr<Array>& indices);
759 
769  static Status FromArrays(const std::shared_ptr<DataType>& type,
770  const std::shared_ptr<Array>& indices,
771  std::shared_ptr<Array>* out);
772 
773  std::shared_ptr<Array> indices() const;
774  std::shared_ptr<Array> dictionary() const;
775 
776  const DictionaryType* dict_type() const { return dict_type_; }
777 
778  private:
779  void SetData(const std::shared_ptr<ArrayData>& data);
780 
781  const DictionaryType* dict_type_;
782  std::shared_ptr<Array> indices_;
783 };
784 
785 // ----------------------------------------------------------------------
786 // extern templates and other details
787 
788 // Only instantiate these templates once
805 
813 ARROW_EXPORT
814 Status ValidateArray(const Array& array);
815 
816 } // namespace arrow
817 
818 #endif // ARROW_ARRAY_H
Concrete type class for struct data.
Definition: type.h:494
Concrete Array class for fixed-size binary data.
Definition: array.h:572
void SetData(const std::shared_ptr< ArrayData > &data)
Definition: array.h:591
Definition: array.h:370
int64_t offset() const
A relative position into another array&#39;s data, to enable zero-copy slicing.
Definition: array.h:222
const int32_t * raw_value_offsets() const
Return pointer to raw value offsets accounting for any slice offset.
Definition: array.h:459
BinaryArray()
Definition: array.h:530
const uint8_t * Value(int64_t i) const
Definition: array.h:584
#define NULLPTR
Definition: macros.h:69
ArrayData()
Definition: array.h:89
bool IsValid(int64_t i) const
Return true if value at index is valid (not null).
Definition: array.h:212
Status ValidateArray(const Array &array)
Perform any validation checks to determine obvious inconsistencies with the array&#39;s internal data...
const uint8_t * GetValue(int64_t i, int32_t *out_length) const
Definition: array.h:494
int64_t offset
Definition: array.h:175
std::shared_ptr< Buffer > type_ids() const
Note that this buffer does not account for any slice offset.
Definition: array.h:698
type
Definition: type.h:48
std::vector< std::shared_ptr< Buffer > > buffers
Definition: array.h:176
const uint8_t * null_bitmap_data() const
Raw pointer to the null bitmap.
Definition: array.h:243
PrimitiveArray(const std::shared_ptr< ArrayData > &data)
Definition: array.h:362
#define ARROW_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition: macros.h:23
int32_t byte_width() const
Definition: array.h:586
int64_t length
Definition: array.h:171
Concrete Array class for boolean data.
Definition: array.h:399
int32_t value_offset(int64_t i) const
Definition: array.h:462
std::shared_ptr< Buffer > null_bitmap() const
Buffer for the null bitmap.
Definition: array.h:237
Base class for non-nested arrays.
Definition: array.h:321
const int32_t * raw_value_offsets_
Definition: array.h:470
std::shared_ptr< ArrayData > data() const
Definition: array.h:275
const type_id_t * raw_type_ids_
Definition: array.h:724
std::vector< std::shared_ptr< Buffer > > BufferVector
Definition: array.h:43
std::vector< std::shared_ptr< Array > > ArrayVector
Definition: array.h:302
int32_t value_offset(int64_t i) const
Definition: array.h:522
Definition: status.h:95
std::string GetString(int64_t i) const
Definition: array.h:561
PrimitiveArray()
Definition: array.h:354
Definition: type_traits.h:34
std::shared_ptr< DataType > dictionary(const std::shared_ptr< DataType > &index_type, const std::shared_ptr< Array > &values, bool ordered=false)
Create a DictionaryType instance.
const int32_t * raw_value_offsets_
Definition: array.h:725
const type_id_t * raw_type_ids() const
Definition: array.h:705
Array()
Definition: array.h:283
type
Definition: type.h:548
const DictionaryType * dict_type() const
Definition: array.h:776
Type::type type_id() const
Definition: array.h:231
int64_t null_count
Definition: array.h:172
ArrayData(const std::shared_ptr< DataType > &type, int64_t length, std::vector< std::shared_ptr< Buffer >> &&buffers, int64_t null_count=kUnknownNullCount, int64_t offset=0)
Definition: array.h:111
Concrete type class for always-null data.
Definition: type.h:311
std::shared_ptr< Array > MakeArray(const std::shared_ptr< ArrayData > &data)
Create a strongly-typed Array instance from generic ArrayData.
const uint8_t * raw_values_
Definition: array.h:366
Concrete type class for variable-size binary data.
Definition: type.h:445
std::shared_ptr< Field > field(const std::string &name, const std::shared_ptr< DataType > &type, bool nullable=true, const std::shared_ptr< const KeyValueMetadata > &metadata=NULLPTR)
Create a Field instance.
Concrete type class for boolean data.
Definition: type.h:324
Concrete type class for list data.
Definition: type.h:422
int32_t value_offset(int64_t i) const
Definition: array.h:703
return os str()
ArrayData(const std::shared_ptr< DataType > &type, int64_t length, const std::vector< std::shared_ptr< Buffer >> &buffers, int64_t null_count=kUnknownNullCount, int64_t offset=0)
Definition: array.h:95
TYPE TypeClass
Definition: array.h:372
bool IsNull(int64_t i) const
Return true if value at index is null. Does not boundscheck.
Definition: array.h:205
void SetData(const std::shared_ptr< ArrayData > &data)
Protected method for constructors.
Definition: array.h:289
const uint8_t * raw_data_
Definition: array.h:544
Concrete type class for variable-size string data, utf8-encoded.
Definition: type.h:482
ArrayData(const std::shared_ptr< DataType > &type, int64_t length, int64_t null_count=kUnknownNullCount, int64_t offset=0)
Definition: array.h:91
const int32_t * raw_value_offsets_
Definition: array.h:543
DataType< Type::BOOLEAN > BooleanType
Definition: types.h:276
const int32_t * raw_value_offsets() const
Definition: array.h:519
typename TypeClass::c_type value_type
Definition: array.h:373
Definition: visitor.h:27
ArrayData & operator=(ArrayData &&other)
Definition: array.h:158
Concrete Array class for variable-size string (utf-8) data.
Definition: array.h:548
std::shared_ptr< Buffer > value_offsets() const
Note that this buffer does not account for any slice offset.
Definition: array.h:514
std::string GetString(int64_t i) const
Get binary value as a std::string.
Definition: array.h:507
constexpr int64_t kUnknownNullCount
Definition: array.h:49
void SetData(const std::shared_ptr< ArrayData > &data)
Definition: array.h:356
Top-level namespace for Apache Arrow C++ API.
Definition: adapter.h:32
std::shared_ptr< DataType > type
Definition: array.h:170
std::shared_ptr< Buffer > value_offsets() const
Note that this buffer does not account for any slice offset.
Definition: array.h:701
Array base type Immutable data array with some logical type and some length.
Definition: array.h:200
Concrete Array class for list data.
Definition: array.h:422
std::shared_ptr< DataType > type() const
Definition: array.h:230
Concrete type class for 128-bit decimal data.
Definition: type.h:535
std::shared_ptr< Buffer > value_offsets() const
Note that this buffer does not account for any slice offset.
Definition: array.h:454
value_type Value(int64_t i) const
Definition: array.h:392
NumericArray(typename std::enable_if< TypeTraits< T1 >::is_parameter_free, int64_t >::type length, const std::shared_ptr< Buffer > &data, const std::shared_ptr< Buffer > &null_bitmap=NULLPTR, int64_t null_count=0, int64_t offset=0)
Definition: array.h:380
int64_t length() const
Size in the number of elements this array contains.
Definition: array.h:218
std::shared_ptr< Buffer > value_data() const
Note that this buffer does not account for any slice offset.
Definition: array.h:517
std::shared_ptr< ArrayData > data_
Definition: array.h:285
Concrete Array class for variable-size binary data.
Definition: array.h:480
const uint8_t * raw_values() const
Definition: array.h:588
Concrete Array class for union data.
Definition: array.h:654
const int32_t * raw_value_offsets() const
Definition: array.h:706
std::vector< std::shared_ptr< Array > > boxed_fields_
Definition: array.h:728
ArrayData(const ArrayData &other) noexcept
Definition: array.h:149
ArrayData(ArrayData &&other) noexcept
Definition: array.h:141
std::shared_ptr< ArrayData > Copy() const
Definition: array.h:168
UnionMode::type mode() const
Definition: array.h:708
const value_type * raw_values() const
Definition: array.h:388
Mutable container for generic Arrow array data.
Definition: array.h:88
int32_t value_length(int64_t i) const
Definition: array.h:523
Concrete Array class for 128-bit decimal data.
Definition: array.h:604
Concrete Array class for dictionary data.
Definition: array.h:751
int32_t byte_width_
Definition: array.h:597
ArrayData(const std::shared_ptr< DataType > &type, int64_t length, const std::vector< std::shared_ptr< Buffer >> &buffers, const std::vector< std::shared_ptr< ArrayData >> &child_data, int64_t null_count=kUnknownNullCount, int64_t offset=0)
Definition: array.h:102
Concrete type class for dictionary data.
Definition: type.h:741
Base class for memory allocation.
Definition: memory_pool.h:34
bool Value(int64_t i) const
Definition: array.h:409
uint8_t type_id_t
Definition: array.h:657
Concrete Array class for struct data.
Definition: array.h:623
int num_fields() const
Definition: array.h:277
const uint8_t * null_bitmap_data_
Definition: array.h:286
Concrete type class for union data.
Definition: type.h:552
NullArray(const std::shared_ptr< ArrayData > &data)
Definition: array.h:331
#define ARROW_EXTERN_TEMPLATE
Definition: visibility.h:52
std::shared_ptr< Buffer > values() const
Does not account for any slice offset.
Definition: array.h:351
std::vector< std::shared_ptr< ArrayData > > child_data
Definition: array.h:177
int32_t value_length(int64_t i) const
Definition: array.h:463
Concrete type class for fixed-size binary data.
Definition: type.h:461
Base class for arrays of fixed-size logical types.
Definition: array.h:343
Degenerate null type Array.
Definition: array.h:327
FixedSizeBinaryArray(const std::shared_ptr< ArrayData > &data)