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 <cmath>
22 #include <cstdint>
23 #include <memory>
24 #include <string>
25 #include <utility>
26 #include <vector>
27 
28 #include "arrow/buffer.h"
29 #include "arrow/type.h"
30 #include "arrow/type_fwd.h"
31 #include "arrow/type_traits.h"
32 #include "arrow/util/bit-util.h"
34 #include "arrow/util/macros.h"
35 #include "arrow/util/visibility.h"
36 #include "arrow/visitor.h"
37 
38 namespace arrow {
39 
40 using BufferVector = std::vector<std::shared_ptr<Buffer>>;
41 
42 // When slicing, we do not know the null count of the sliced range without
43 // doing some computation. To avoid doing this eagerly, we set the null count
44 // to -1 (any negative number will do). When Array::null_count is called the
45 // first time, the null count will be computed. See ARROW-33
46 constexpr int64_t kUnknownNullCount = -1;
47 
48 class MemoryPool;
49 class Status;
50 
51 template <typename T>
52 struct Decimal;
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::BitNotSet(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 
320 class ARROW_EXPORT FlatArray : public Array {
321  protected:
322  using Array::Array;
323 };
324 
326 class ARROW_EXPORT NullArray : public FlatArray {
327  public:
329 
330  explicit NullArray(const std::shared_ptr<ArrayData>& data) { SetData(data); }
331  explicit NullArray(int64_t length);
332 
333  private:
334  inline void SetData(const std::shared_ptr<ArrayData>& data) {
335  null_bitmap_data_ = NULLPTR;
336  data->null_count = data->length;
337  data_ = data;
338  }
339 };
340 
342 class ARROW_EXPORT PrimitiveArray : public FlatArray {
343  public:
344  PrimitiveArray(const std::shared_ptr<DataType>& type, int64_t length,
345  const std::shared_ptr<Buffer>& data,
346  const std::shared_ptr<Buffer>& null_bitmap = NULLPTR,
347  int64_t null_count = 0, int64_t offset = 0);
348 
350  std::shared_ptr<Buffer> values() const { return data_->buffers[1]; }
351 
352  protected:
354 
355  inline void SetData(const std::shared_ptr<ArrayData>& data) {
356  auto values = data->buffers[1];
357  this->Array::SetData(data);
358  raw_values_ = values == NULLPTR ? NULLPTR : values->data();
359  }
360 
361  explicit inline PrimitiveArray(const std::shared_ptr<ArrayData>& data) {
362  SetData(data);
363  }
364 
365  const uint8_t* raw_values_;
366 };
367 
368 template <typename TYPE>
369 class ARROW_EXPORT NumericArray : public PrimitiveArray {
370  public:
371  using TypeClass = TYPE;
372  using value_type = typename TypeClass::c_type;
373 
374  explicit NumericArray(const std::shared_ptr<ArrayData>& data);
375 
376  // Only enable this constructor without a type argument for types without additional
377  // metadata
378  template <typename T1 = TYPE>
380  typename std::enable_if<TypeTraits<T1>::is_parameter_free, int64_t>::type length,
381  const std::shared_ptr<Buffer>& data,
382  const std::shared_ptr<Buffer>& null_bitmap = NULLPTR, int64_t null_count = 0,
383  int64_t offset = 0)
384  : PrimitiveArray(TypeTraits<T1>::type_singleton(), length, data, null_bitmap,
385  null_count, offset) {}
386 
387  const value_type* raw_values() const {
388  return reinterpret_cast<const value_type*>(raw_values_) + data_->offset;
389  }
390 
391  value_type Value(int64_t i) const { return raw_values()[i]; }
392 
393  protected:
395 };
396 
397 class ARROW_EXPORT BooleanArray : public PrimitiveArray {
398  public:
400 
401  explicit BooleanArray(const std::shared_ptr<ArrayData>& data);
402 
403  BooleanArray(int64_t length, const std::shared_ptr<Buffer>& data,
404  const std::shared_ptr<Buffer>& null_bitmap = NULLPTR,
405  int64_t null_count = 0, int64_t offset = 0);
406 
407  bool Value(int64_t i) const {
408  return BitUtil::GetBit(reinterpret_cast<const uint8_t*>(raw_values_),
409  i + data_->offset);
410  }
411 
412  protected:
414 };
415 
416 // ----------------------------------------------------------------------
417 // ListArray
418 
419 class ARROW_EXPORT ListArray : public Array {
420  public:
422 
423  explicit ListArray(const std::shared_ptr<ArrayData>& data);
424 
425  ListArray(const std::shared_ptr<DataType>& type, int64_t length,
426  const std::shared_ptr<Buffer>& value_offsets,
427  const std::shared_ptr<Array>& values,
428  const std::shared_ptr<Buffer>& null_bitmap = NULLPTR, int64_t null_count = 0,
429  int64_t offset = 0);
430 
444  static Status FromArrays(const Array& offsets, const Array& values, MemoryPool* pool,
445  std::shared_ptr<Array>* out);
446 
448  std::shared_ptr<Array> values() const;
449 
451  std::shared_ptr<Buffer> value_offsets() const { return data_->buffers[1]; }
452 
453  std::shared_ptr<DataType> value_type() const;
454 
456  const int32_t* raw_value_offsets() const { return raw_value_offsets_ + data_->offset; }
457 
458  // Neither of these functions will perform boundschecking
459  int32_t value_offset(int64_t i) const { return raw_value_offsets_[i + data_->offset]; }
460  int32_t value_length(int64_t i) const {
461  i += data_->offset;
462  return raw_value_offsets_[i + 1] - raw_value_offsets_[i];
463  }
464 
465  protected:
466  void SetData(const std::shared_ptr<ArrayData>& data);
467  const int32_t* raw_value_offsets_;
468 
469  private:
470  std::shared_ptr<Array> values_;
471 };
472 
473 // ----------------------------------------------------------------------
474 // Binary and String
475 
476 class ARROW_EXPORT BinaryArray : public FlatArray {
477  public:
479 
480  explicit BinaryArray(const std::shared_ptr<ArrayData>& data);
481 
482  BinaryArray(int64_t length, const std::shared_ptr<Buffer>& value_offsets,
483  const std::shared_ptr<Buffer>& data,
484  const std::shared_ptr<Buffer>& null_bitmap = NULLPTR,
485  int64_t null_count = 0, int64_t offset = 0);
486 
487  // Return the pointer to the given elements bytes
488  // TODO(emkornfield) introduce a StringPiece or something similar to capture zero-copy
489  // pointer + offset
490  const uint8_t* GetValue(int64_t i, int32_t* out_length) const {
491  // Account for base offset
492  i += data_->offset;
493 
494  const int32_t pos = raw_value_offsets_[i];
495  *out_length = raw_value_offsets_[i + 1] - pos;
496  return raw_data_ + pos;
497  }
498 
503  std::string GetString(int64_t i) const {
504  int32_t length = 0;
505  const uint8_t* bytes = GetValue(i, &length);
506  return std::string(reinterpret_cast<const char*>(bytes), static_cast<size_t>(length));
507  }
508 
510  std::shared_ptr<Buffer> value_offsets() const { return data_->buffers[1]; }
511 
513  std::shared_ptr<Buffer> value_data() const { return data_->buffers[2]; }
514 
515  const int32_t* raw_value_offsets() const { return raw_value_offsets_ + data_->offset; }
516 
517  // Neither of these functions will perform boundschecking
518  int32_t value_offset(int64_t i) const { return raw_value_offsets_[i + data_->offset]; }
519  int32_t value_length(int64_t i) const {
520  i += data_->offset;
521  return raw_value_offsets_[i + 1] - raw_value_offsets_[i];
522  }
523 
524  protected:
525  // For subclasses
527 
529  void SetData(const std::shared_ptr<ArrayData>& data);
530 
531  // Constructor that allows sub-classes/builders to propagate there logical type up the
532  // class hierarchy.
533  BinaryArray(const std::shared_ptr<DataType>& type, int64_t length,
534  const std::shared_ptr<Buffer>& value_offsets,
535  const std::shared_ptr<Buffer>& data,
536  const std::shared_ptr<Buffer>& null_bitmap = NULLPTR,
537  int64_t null_count = 0, int64_t offset = 0);
538 
539  const int32_t* raw_value_offsets_;
540  const uint8_t* raw_data_;
541 };
542 
543 class ARROW_EXPORT StringArray : public BinaryArray {
544  public:
546 
547  explicit StringArray(const std::shared_ptr<ArrayData>& data);
548 
549  StringArray(int64_t length, const std::shared_ptr<Buffer>& value_offsets,
550  const std::shared_ptr<Buffer>& data,
551  const std::shared_ptr<Buffer>& null_bitmap = NULLPTR,
552  int64_t null_count = 0, int64_t offset = 0);
553 
554  // Construct a std::string
555  // TODO: std::bad_alloc possibility
556  std::string GetString(int64_t i) const {
557  int32_t nchars;
558  const uint8_t* str = GetValue(i, &nchars);
559  return std::string(reinterpret_cast<const char*>(str), nchars);
560  }
561 };
562 
563 // ----------------------------------------------------------------------
564 // Fixed width binary
565 
566 class ARROW_EXPORT FixedSizeBinaryArray : public PrimitiveArray {
567  public:
569 
570  explicit FixedSizeBinaryArray(const std::shared_ptr<ArrayData>& data);
571 
572  FixedSizeBinaryArray(const std::shared_ptr<DataType>& type, int64_t length,
573  const std::shared_ptr<Buffer>& data,
574  const std::shared_ptr<Buffer>& null_bitmap = NULLPTR,
575  int64_t null_count = 0, int64_t offset = 0);
576 
577  const uint8_t* GetValue(int64_t i) const;
578  const uint8_t* Value(int64_t i) const { return GetValue(i); }
579 
580  int32_t byte_width() const { return byte_width_; }
581 
582  const uint8_t* raw_values() const { return raw_values_ + data_->offset * byte_width_; }
583 
584  protected:
585  inline void SetData(const std::shared_ptr<ArrayData>& data) {
586  this->PrimitiveArray::SetData(data);
587  byte_width_ = checked_cast<const FixedSizeBinaryType&>(*type()).byte_width();
588  }
589 
590  int32_t byte_width_;
591 };
592 
593 // ----------------------------------------------------------------------
594 // Decimal128Array
595 class ARROW_EXPORT Decimal128Array : public FixedSizeBinaryArray {
596  public:
598 
600 
602  explicit Decimal128Array(const std::shared_ptr<ArrayData>& data);
603 
604  std::string FormatValue(int64_t i) const;
605 };
606 
607 // Backward compatibility
609 
610 // ----------------------------------------------------------------------
611 // Struct
612 
613 class ARROW_EXPORT StructArray : public Array {
614  public:
616 
617  explicit StructArray(const std::shared_ptr<ArrayData>& data);
618 
619  StructArray(const std::shared_ptr<DataType>& type, int64_t length,
620  const std::vector<std::shared_ptr<Array>>& children,
621  std::shared_ptr<Buffer> null_bitmap = NULLPTR, int64_t null_count = 0,
622  int64_t offset = 0);
623 
624  // Return a shared pointer in case the requestor desires to share ownership
625  // with this array. The returned array has its offset, length and null
626  // count adjusted.
627  std::shared_ptr<Array> field(int pos) const;
628 
633  Status Flatten(MemoryPool* pool, ArrayVector* out) const;
634 
635  private:
636  // For caching boxed child data
637  mutable std::vector<std::shared_ptr<Array>> boxed_fields_;
638 };
639 
640 // ----------------------------------------------------------------------
641 // Union
642 
643 class ARROW_EXPORT UnionArray : public Array {
644  public:
646  using type_id_t = uint8_t;
647 
648  explicit UnionArray(const std::shared_ptr<ArrayData>& data);
649 
650  UnionArray(const std::shared_ptr<DataType>& type, int64_t length,
651  const std::vector<std::shared_ptr<Array>>& children,
652  const std::shared_ptr<Buffer>& type_ids,
653  const std::shared_ptr<Buffer>& value_offsets = NULLPTR,
654  const std::shared_ptr<Buffer>& null_bitmap = NULLPTR, int64_t null_count = 0,
655  int64_t offset = 0);
656 
669  static Status MakeDense(const Array& type_ids, const Array& value_offsets,
670  const std::vector<std::shared_ptr<Array>>& children,
671  std::shared_ptr<Array>* out);
672 
682  static Status MakeSparse(const Array& type_ids,
683  const std::vector<std::shared_ptr<Array>>& children,
684  std::shared_ptr<Array>* out);
685 
687  std::shared_ptr<Buffer> type_ids() const { return data_->buffers[1]; }
688 
690  std::shared_ptr<Buffer> value_offsets() const { return data_->buffers[2]; }
691 
692  int32_t value_offset(int64_t i) const { return raw_value_offsets_[i + data_->offset]; }
693 
694  const type_id_t* raw_type_ids() const { return raw_type_ids_ + data_->offset; }
695  const int32_t* raw_value_offsets() const { return raw_value_offsets_ + data_->offset; }
696 
697  UnionMode::type mode() const { return checked_cast<const UnionType&>(*type()).mode(); }
698 
699  // Return the given field as an individual array.
700  // For sparse unions, the returned array has its offset, length and null
701  // count adjusted.
702  // For dense unions, the returned array is unchanged.
703  std::shared_ptr<Array> child(int pos) const;
704 
706  const Array* UnsafeChild(int pos) const;
707 
708  protected:
709  void SetData(const std::shared_ptr<ArrayData>& data);
710 
712  const int32_t* raw_value_offsets_;
713 
714  // For caching boxed child data
715  mutable std::vector<std::shared_ptr<Array>> boxed_fields_;
716 };
717 
718 // ----------------------------------------------------------------------
719 // DictionaryArray (categorical and dictionary-encoded in memory)
720 
721 // A dictionary array contains an array of non-negative integers (the
722 // "dictionary indices") along with a data type containing a "dictionary"
723 // corresponding to the distinct values represented in the data.
724 //
725 // For example, the array
726 //
727 // ["foo", "bar", "foo", "bar", "foo", "bar"]
728 //
729 // with dictionary ["bar", "foo"], would have dictionary array representation
730 //
731 // indices: [1, 0, 1, 0, 1, 0]
732 // dictionary: ["bar", "foo"]
733 //
734 // The indices in principle may have any integer type (signed or unsigned),
735 // though presently data in IPC exchanges must be signed int32.
736 class ARROW_EXPORT DictionaryArray : public Array {
737  public:
739 
740  explicit DictionaryArray(const std::shared_ptr<ArrayData>& data);
741 
742  DictionaryArray(const std::shared_ptr<DataType>& type,
743  const std::shared_ptr<Array>& indices);
744 
754  static Status FromArrays(const std::shared_ptr<DataType>& type,
755  const std::shared_ptr<Array>& indices,
756  std::shared_ptr<Array>* out);
757 
758  std::shared_ptr<Array> indices() const;
759  std::shared_ptr<Array> dictionary() const;
760 
761  const DictionaryType* dict_type() const { return dict_type_; }
762 
763  private:
764  void SetData(const std::shared_ptr<ArrayData>& data);
765 
766  const DictionaryType* dict_type_;
767  std::shared_ptr<Array> indices_;
768 };
769 
770 // ----------------------------------------------------------------------
771 // extern templates and other details
772 
773 // Only instantiate these templates once
790 
798 ARROW_EXPORT
799 Status ValidateArray(const Array& array);
800 
801 } // namespace arrow
802 
803 #endif // ARROW_ARRAY_H
Definition: type.h:469
Definition: array.h:566
void SetData(const std::shared_ptr< ArrayData > &data)
Definition: array.h:585
Definition: array.h:369
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:456
BinaryArray()
Definition: array.h:526
const uint8_t * Value(int64_t i) const
Definition: array.h:578
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:490
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:687
type
Definition: type.h:46
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:361
int32_t byte_width() const
Definition: array.h:580
int64_t length
Definition: array.h:171
Definition: array.h:397
int32_t value_offset(int64_t i) const
Definition: array.h:459
std::shared_ptr< Buffer > null_bitmap() const
Buffer for the null bitmap.
Definition: array.h:237
Definition: array.h:320
const int32_t * raw_value_offsets_
Definition: array.h:467
std::shared_ptr< ArrayData > data() const
Definition: array.h:275
#define NULLPTR
Definition: macros.h:69
const type_id_t * raw_type_ids_
Definition: array.h:711
std::vector< std::shared_ptr< Buffer > > BufferVector
Definition: array.h:40
std::vector< std::shared_ptr< Array > > ArrayVector
Definition: array.h:302
int32_t value_offset(int64_t i) const
Definition: array.h:518
Definition: status.h:93
std::string GetString(int64_t i) const
Definition: array.h:556
PrimitiveArray()
Definition: array.h:353
Definition: type_traits.h:30
std::shared_ptr< DataType > dictionary(const std::shared_ptr< DataType > &index_type, const std::shared_ptr< Array > &values, bool ordered=false)
Create an instance of Dictionary type.
const int32_t * raw_value_offsets_
Definition: array.h:712
const type_id_t * raw_type_ids() const
Definition: array.h:694
Array()
Definition: array.h:283
type
Definition: type.h:521
const DictionaryType * dict_type() const
Definition: array.h:761
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
Definition: type.h:291
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:365
Definition: type.h:421
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.
Definition: type.h:303
Definition: type.h:385
int32_t value_offset(int64_t i) const
Definition: array.h:692
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:371
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:540
Definition: type.h:458
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:539
const int32_t * raw_value_offsets() const
Definition: array.h:515
typename TypeClass::c_type value_type
Definition: array.h:372
Definition: visitor.h:27
ArrayData & operator=(ArrayData &&other)
Definition: array.h:158
Definition: array.h:543
std::shared_ptr< Buffer > value_offsets() const
Note that this buffer does not account for any slice offset.
Definition: array.h:510
std::string GetString(int64_t i) const
Get binary value as a std::string.
Definition: array.h:503
constexpr int64_t kUnknownNullCount
Definition: array.h:46
void SetData(const std::shared_ptr< ArrayData > &data)
Definition: array.h:355
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:690
Array base type Immutable data array with some logical type and some length.
Definition: array.h:200
Definition: array.h:419
std::shared_ptr< DataType > type() const
Definition: array.h:230
Definition: type.h:508
std::shared_ptr< Buffer > value_offsets() const
Note that this buffer does not account for any slice offset.
Definition: array.h:451
value_type Value(int64_t i) const
Definition: array.h:391
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:379
int64_t length() const
Size in the number of elements this array contains.
Definition: array.h:218
#define ARROW_EXTERN_TEMPLATE
Definition: visibility.h:52
std::shared_ptr< Buffer > value_data() const
Note that this buffer does not account for any slice offset.
Definition: array.h:513
std::shared_ptr< ArrayData > data_
Definition: array.h:285
Definition: array.h:476
const uint8_t * raw_values() const
Definition: array.h:582
Definition: array.h:643
const int32_t * raw_value_offsets() const
Definition: array.h:695
std::vector< std::shared_ptr< Array > > boxed_fields_
Definition: array.h:715
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:697
const value_type * raw_values() const
Definition: array.h:387
Mutable container for generic Arrow array data.
Definition: array.h:88
int32_t value_length(int64_t i) const
Definition: array.h:519
OutputType checked_cast(InputType &&value)
Definition: checked_cast.h:26
Definition: array.h:595
Definition: array.h:736
int32_t byte_width_
Definition: array.h:590
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
Definition: type.h:710
Base class for memory allocation.
Definition: memory_pool.h:34
Definition: array.h:52
bool Value(int64_t i) const
Definition: array.h:407
uint8_t type_id_t
Definition: array.h:646
Definition: array.h:613
int num_fields() const
Definition: array.h:277
const uint8_t * null_bitmap_data_
Definition: array.h:286
Definition: type.h:524
#define ARROW_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition: macros.h:23
NullArray(const std::shared_ptr< ArrayData > &data)
Definition: array.h:330
std::shared_ptr< Buffer > values() const
Does not account for any slice offset.
Definition: array.h:350
std::vector< std::shared_ptr< ArrayData > > child_data
Definition: array.h:177
int32_t value_length(int64_t i) const
Definition: array.h:460
Definition: type.h:437
Base class for fixed-size logical types.
Definition: array.h:342
Degenerate null type Array.
Definition: array.h:326
FixedSizeBinaryArray(const std::shared_ptr< ArrayData > &data)