Trait google_cloud_bigquery::storage::array::Array
pub trait Array: Debug + Send + Sync {
Show 14 methods
// Required methods
fn as_any(&self) -> &(dyn Any + 'static);
fn to_data(&self) -> ArrayData;
fn into_data(self) -> ArrayData;
fn data_type(&self) -> &DataType;
fn slice(&self, offset: usize, length: usize) -> Arc<dyn Array, Global>;
fn len(&self) -> usize;
fn is_empty(&self) -> bool;
fn offset(&self) -> usize;
fn nulls(&self) -> Option<&NullBuffer>;
fn get_buffer_memory_size(&self) -> usize;
fn get_array_memory_size(&self) -> usize;
// Provided methods
fn is_null(&self, index: usize) -> bool { ... }
fn is_valid(&self, index: usize) -> bool { ... }
fn null_count(&self) -> usize { ... }
}Expand description
An array in the arrow columnar format
Required Methods§
fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Returns the array as Any so that it can be
downcasted to a specific implementation.
Example:
let id = Int32Array::from(vec![1, 2, 3, 4, 5]);
let batch = RecordBatch::try_new(
Arc::new(Schema::new(vec![Field::new("id", DataType::Int32, false)])),
vec![Arc::new(id)]
).unwrap();
let int32array = batch
.column(0)
.as_any()
.downcast_ref::<Int32Array>()
.expect("Failed to downcast");fn into_data(self) -> ArrayData
fn into_data(self) -> ArrayData
Returns the underlying data of this array
Unlike Array::to_data this consumes self, allowing it avoid unnecessary clones
fn slice(&self, offset: usize, length: usize) -> Arc<dyn Array, Global>
fn slice(&self, offset: usize, length: usize) -> Arc<dyn Array, Global>
Returns a zero-copy slice of this array with the indicated offset and length.
Example:
use arrow_array::{Array, Int32Array};
let array = Int32Array::from(vec![1, 2, 3, 4, 5]);
// Make slice over the values [2, 3, 4]
let array_slice = array.slice(1, 3);
assert_eq!(&array_slice, &Int32Array::from(vec![2, 3, 4]));fn len(&self) -> usize
fn len(&self) -> usize
Returns the length (i.e., number of elements) of this array.
Example:
use arrow_array::{Array, Int32Array};
let array = Int32Array::from(vec![1, 2, 3, 4, 5]);
assert_eq!(array.len(), 5);fn is_empty(&self) -> bool
fn is_empty(&self) -> bool
Returns whether this array is empty.
Example:
use arrow_array::{Array, Int32Array};
let array = Int32Array::from(vec![1, 2, 3, 4, 5]);
assert_eq!(array.is_empty(), false);fn offset(&self) -> usize
fn offset(&self) -> usize
Returns the offset into the underlying data used by this array(-slice).
Note that the underlying data can be shared by many arrays.
This defaults to 0.
Example:
use arrow_array::{Array, BooleanArray};
let array = BooleanArray::from(vec![false, false, true, true]);
let array_slice = array.slice(1, 3);
assert_eq!(array.offset(), 0);
assert_eq!(array_slice.offset(), 1);fn nulls(&self) -> Option<&NullBuffer>
fn nulls(&self) -> Option<&NullBuffer>
Returns the null buffers of this array if any
fn get_buffer_memory_size(&self) -> usize
fn get_buffer_memory_size(&self) -> usize
Returns the total number of bytes of memory pointed to by this array. The buffers store bytes in the Arrow memory format, and include the data as well as the validity map.
fn get_array_memory_size(&self) -> usize
fn get_array_memory_size(&self) -> usize
Returns the total number of bytes of memory occupied physically by this array.
This value will always be greater than returned by get_buffer_memory_size() and
includes the overhead of the data structures that contain the pointers to the various buffers.
Provided Methods§
fn is_null(&self, index: usize) -> bool
fn is_null(&self, index: usize) -> bool
Returns whether the element at index is null.
When using this function on a slice, the index is relative to the slice.
Example:
use arrow_array::{Array, Int32Array};
let array = Int32Array::from(vec![Some(1), None]);
assert_eq!(array.is_null(0), false);
assert_eq!(array.is_null(1), true);fn is_valid(&self, index: usize) -> bool
fn is_valid(&self, index: usize) -> bool
Returns whether the element at index is not null.
When using this function on a slice, the index is relative to the slice.
Example:
use arrow_array::{Array, Int32Array};
let array = Int32Array::from(vec![Some(1), None]);
assert_eq!(array.is_valid(0), true);
assert_eq!(array.is_valid(1), false);fn null_count(&self) -> usize
fn null_count(&self) -> usize
Returns the total number of null values in this array.
Example:
use arrow_array::{Array, Int32Array};
// Construct an array with values [1, NULL, NULL]
let array = Int32Array::from(vec![Some(1), None, None]);
assert_eq!(array.null_count(), 2);Trait Implementations§
§impl AsArray for dyn Array + '_
impl AsArray for dyn Array + '_
§fn as_boolean_opt(&self) -> Option<&BooleanArray>
fn as_boolean_opt(&self) -> Option<&BooleanArray>
BooleanArray returning None if not possible§fn as_primitive_opt<T>(&self) -> Option<&PrimitiveArray<T>>where
T: ArrowPrimitiveType,
fn as_primitive_opt<T>(&self) -> Option<&PrimitiveArray<T>>where T: ArrowPrimitiveType,
PrimitiveArray returning None if not possible§fn as_bytes_opt<T>(&self) -> Option<&GenericByteArray<T>>where
T: ByteArrayType,
fn as_bytes_opt<T>(&self) -> Option<&GenericByteArray<T>>where T: ByteArrayType,
GenericByteArray returning None if not possible§fn as_struct_opt(&self) -> Option<&StructArray>
fn as_struct_opt(&self) -> Option<&StructArray>
StructArray returning None if not possible§fn as_list_opt<O>(&self) -> Option<&GenericListArray<O>>where
O: OffsetSizeTrait,
fn as_list_opt<O>(&self) -> Option<&GenericListArray<O>>where O: OffsetSizeTrait,
GenericListArray returning None if not possible§fn as_fixed_size_list_opt(&self) -> Option<&FixedSizeListArray>
fn as_fixed_size_list_opt(&self) -> Option<&FixedSizeListArray>
FixedSizeListArray returning None if not possible§fn as_map_opt(&self) -> Option<&MapArray>
fn as_map_opt(&self) -> Option<&MapArray>
MapArray returning None if not possible§fn as_dictionary_opt<K>(&self) -> Option<&DictionaryArray<K>>where
K: ArrowDictionaryKeyType,
fn as_dictionary_opt<K>(&self) -> Option<&DictionaryArray<K>>where K: ArrowDictionaryKeyType,
DictionaryArray returning None if not possible§fn as_boolean(&self) -> &BooleanArray
fn as_boolean(&self) -> &BooleanArray
BooleanArray panicking if not possible§fn as_primitive<T>(&self) -> &PrimitiveArray<T>where
T: ArrowPrimitiveType,
fn as_primitive<T>(&self) -> &PrimitiveArray<T>where T: ArrowPrimitiveType,
PrimitiveArray panicking if not possible§fn as_bytes<T>(&self) -> &GenericByteArray<T>where
T: ByteArrayType,
fn as_bytes<T>(&self) -> &GenericByteArray<T>where T: ByteArrayType,
GenericByteArray panicking if not possible§fn as_string_opt<O>(&self) -> Option<&GenericByteArray<GenericStringType<O>>>where
O: OffsetSizeTrait,
fn as_string_opt<O>(&self) -> Option<&GenericByteArray<GenericStringType<O>>>where O: OffsetSizeTrait,
GenericStringArray returning None if not possible§fn as_string<O>(&self) -> &GenericByteArray<GenericStringType<O>>where
O: OffsetSizeTrait,
fn as_string<O>(&self) -> &GenericByteArray<GenericStringType<O>>where O: OffsetSizeTrait,
GenericStringArray panicking if not possible§fn as_binary_opt<O>(&self) -> Option<&GenericByteArray<GenericBinaryType<O>>>where
O: OffsetSizeTrait,
fn as_binary_opt<O>(&self) -> Option<&GenericByteArray<GenericBinaryType<O>>>where O: OffsetSizeTrait,
GenericBinaryArray returning None if not possible§fn as_binary<O>(&self) -> &GenericByteArray<GenericBinaryType<O>>where
O: OffsetSizeTrait,
fn as_binary<O>(&self) -> &GenericByteArray<GenericBinaryType<O>>where O: OffsetSizeTrait,
GenericBinaryArray panicking if not possible§fn as_struct(&self) -> &StructArray
fn as_struct(&self) -> &StructArray
StructArray panicking if not possible§fn as_list<O>(&self) -> &GenericListArray<O>where
O: OffsetSizeTrait,
fn as_list<O>(&self) -> &GenericListArray<O>where O: OffsetSizeTrait,
GenericListArray panicking if not possible§fn as_fixed_size_list(&self) -> &FixedSizeListArray
fn as_fixed_size_list(&self) -> &FixedSizeListArray
FixedSizeListArray panicking if not possible§fn as_dictionary<K>(&self) -> &DictionaryArray<K>where
K: ArrowDictionaryKeyType,
fn as_dictionary<K>(&self) -> &DictionaryArray<K>where K: ArrowDictionaryKeyType,
DictionaryArray panicking if not possibleImplementations on Foreign Types§
§impl<'a, T> Array for &'a Twhere
T: Array,
impl<'a, T> Array for &'a Twhere T: Array,
fn as_any(&self) -> &(dyn Any + 'static)
fn to_data(&self) -> ArrayData
fn into_data(self) -> ArrayData
fn data_type(&self) -> &DataType
fn slice(&self, offset: usize, length: usize) -> Arc<dyn Array, Global>
fn len(&self) -> usize
fn is_empty(&self) -> bool
fn offset(&self) -> usize
fn nulls(&self) -> Option<&NullBuffer>
fn is_null(&self, index: usize) -> bool
fn is_valid(&self, index: usize) -> bool
fn null_count(&self) -> usize
fn get_buffer_memory_size(&self) -> usize
fn get_array_memory_size(&self) -> usize
§impl Array for Arc<dyn Array, Global>
impl Array for Arc<dyn Array, Global>
Ergonomics: Allow use of an ArrayRef as an &dyn Array