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 ArrayRefs 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 (vide StringArray into Column::HashedBytes((,)). -
range
: used to get a subslice out of ArrayRef. -
scals
: scalar representation of each element in the ArrayRef. Some types don’t require this slice (see Column::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.
Object Safety§
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 tange 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 ofCurve25519Scalar
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.