proof_of_sql::base::database

Trait ArrayRefExt

source
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§

source

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 to range.len().

Note: this function must not be called from unsupported or nullable arrays as it will panic.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

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>

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 a Bump allocator used for memory allocation during the conversion.
  • range: Reference to a Range<usize> specifying the slice of the array to convert.
  • precomputed_scals: Optional reference to a slice of Curve25519Scalar values. VarChar columns store hashes to their values as scalars, which can be provided here.
§Supported types
  • For DataType::Int64 and DataType::Decimal128(38, 0), it slices the array based on the provided range and returns the corresponding BigInt or Int128 column.
  • Decimal256, converts arrow i256 columns into Decimal75(precision, scale) columns.
  • For DataType::Utf8, it extracts string values and scalar values (if precomputed_scals is provided) for the specified range and returns a VarChar column.
§Panics
  • When any range is OOB, i.e. indexing 3..6 or 5..5 on array of size 2.

Implementors§