pub trait TermEncoding:
Debug
+ Send
+ Sync {
type Array: EncodingArray<Encoding = Self>;
type Scalar: EncodingScalar<Encoding = Self>;
// Required methods
fn name(&self) -> EncodingName;
fn data_type(&self) -> DataType;
fn try_new_array(&self, array: ArrayRef) -> DFResult<Self::Array>;
fn try_new_scalar(&self, scalar: ScalarValue) -> DFResult<Self::Scalar>;
// Provided method
fn try_new_datum(
&self,
value: ColumnarValue,
number_rows: usize,
) -> DFResult<EncodingDatum<Self>> { ... }
}
Expand description
A term encoding defines how RDF terms are represented in Arrow arrays.
Each encoding defines a DataType that is uses for encoding RDF terms, while also having a wrapper Self::Array and Self::Scalar for Arrow arrays and scalars.
Different term encodings usually have different purposes and may only be valid for certain operations. For example, the TypedValueEncoding cannot be used to perform arbitrary join operations as it does not retain the lexical value of the RDF literals. On the other hand, the TypedValueEncoding will outperform the PlainTermEncoding for nested numerical operations as the parsing and validation of numeric literals is only done once. It is up to the user to ensure the correct use.
Required Associated Types§
Sourcetype Array: EncodingArray<Encoding = Self>
type Array: EncodingArray<Encoding = Self>
Represents a wrapper for Arrow arrays of this encoding. This can be used in conjunction with TermDecoder to obtain the values from an Arrow array.
Sourcetype Scalar: EncodingScalar<Encoding = Self>
type Scalar: EncodingScalar<Encoding = Self>
Represents a wrapper for Arrow scalars of this encoding. This can be used in conjunction with TermDecoder to obtain the values from an Arrow scalar.
Required Methods§
Sourcefn name(&self) -> EncodingName
fn name(&self) -> EncodingName
Returns the name of the encoding.
Sourcefn data_type(&self) -> DataType
fn data_type(&self) -> DataType
Returns the DataType that is used for this encoding.
This function depends on the instance of an encoding, as some encodings can be configured such that the data type changes (at least in the future). Some encodings also expose a statically known data type (e.g., PlainTermEncoding::data_type).
Sourcefn try_new_array(&self, array: ArrayRef) -> DFResult<Self::Array>
fn try_new_array(&self, array: ArrayRef) -> DFResult<Self::Array>
Checks whether array
contains a value with the correct encoding (i.e., type and possibly
metadata checks). If yes, returns an instance of Self::Array. Otherwise, an error is
returned.
Sourcefn try_new_scalar(&self, scalar: ScalarValue) -> DFResult<Self::Scalar>
fn try_new_scalar(&self, scalar: ScalarValue) -> DFResult<Self::Scalar>
Checks whether scalar
contains a value with the correct encoding (i.e., type and possibly
metadata checks). If yes, returns an instance of Self::Scalar. Otherwise, an error is
returned.
Provided Methods§
Sourcefn try_new_datum(
&self,
value: ColumnarValue,
number_rows: usize,
) -> DFResult<EncodingDatum<Self>>
fn try_new_datum( &self, value: ColumnarValue, number_rows: usize, ) -> DFResult<EncodingDatum<Self>>
Checks whether value
contains a value with the correct encoding (i.e., type and possibly
metadata checks). If yes, returns a datum that either wraps an array or a scalar. Otherwise,
an error is returned.
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.