pub trait ArrayRefExt {
// Required method
fn to_column<'a, S: Scalar>(
&'a self,
alloc: &'a Bump,
range: &Range<usize>,
scals: Option<&'a [S]>,
) -> Result<Column<'a, S>, ArrowArrayToColumnConversionError>;
}
Expand description
This trait is used to provide utility functions to convert ArrayRef
s into proof types (Column, Scalars, etc.)
Required Methods§
Sourcefn to_column<'a, S: Scalar>(
&'a self,
alloc: &'a Bump,
range: &Range<usize>,
scals: Option<&'a [S]>,
) -> Result<Column<'a, S>, ArrowArrayToColumnConversionError>
fn to_column<'a, S: Scalar>( &'a self, alloc: &'a Bump, range: &Range<usize>, scals: Option<&'a [S]>, ) -> Result<Column<'a, S>, ArrowArrayToColumnConversionError>
Convert an ArrayRef
into a Proof of SQL Column type
Parameters:
-
alloc
: used to allocate a slice of data when necessary (videStringArray
intoColumn::HashedBytes((_,_))
. -
range
: used to get a subslice out ofArrayRef
. -
scals
: scalar representation of each element in theArrayRef
. Some types don’t require this slice (seeColumn::BigInt
). But for types requiring it,scals
must be provided and have a length equal torange.len()
.
Note: this function must not be called from unsupported or nullable arrays as it will panic.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl ArrayRefExt for ArrayRef
impl ArrayRefExt for ArrayRef
Source§fn to_column<'a, S: Scalar>(
&'a self,
alloc: &'a Bump,
range: &Range<usize>,
precomputed_scals: Option<&'a [S]>,
) -> Result<Column<'a, S>, ArrowArrayToColumnConversionError>
fn to_column<'a, S: Scalar>( &'a self, alloc: &'a Bump, range: &Range<usize>, precomputed_scals: Option<&'a [S]>, ) -> Result<Column<'a, S>, ArrowArrayToColumnConversionError>
Converts the given ArrowArray
into a Column
data type based on its DataType
. Returns an
empty Column
for any empty range if it is in-bounds.
§Parameters
alloc
: Reference to aBump
allocator used for memory allocation during the conversion.range
: Reference to aRange<usize>
specifying the slice of the array to convert.precomputed_scals
: Optional reference to a slice ofTestScalars
values.VarChar
columns store hashes to their values as scalars, which can be provided here.
§Supported types
- For
DataType::Int64
andDataType::Decimal128(38, 0)
, it slices the array based on the provided range and returns the correspondingBigInt
orInt128
column. - Decimal256, converts arrow i256 columns into Decimal75(precision, scale) columns.
- For
DataType::Utf8
, it extracts string values and scalar values (ifprecomputed_scals
is provided) for the specified range and returns aVarChar
column.
§Panics
- When any range is OOB, i.e. indexing 3..6 or 5..5 on array of size 2.