ObjectIdEncoding

Struct ObjectIdEncoding 

Source
pub struct ObjectIdEncoding { /* private fields */ }
Expand description

The ObjectIdEncoding represents each distinct term in the database with a single unique id. We call such an id object id. Here is an example of the encoding:

?variable

 ┌─────┐
 │   1 │ ────►  <#MyEntity>
 ├─────┤
 │   2 │ ────►  120^^xsd:integer
 ├─────┤
 │ ... │
 └─────┘

§Object ID Mapping

The mapping implementation depends on the storage layer that is being used. For example, an in-memory RDF store will use a different implementation as an on-disk RDF store. The ObjectIdMapping trait defines the contract.

§Strengths and Weaknesses

The object id encoding is very well suited for evaluating joins, as instead of joining variable-length RDF terms, we can directly join the object ids. While we do not have recent numbers for the performance gains, the original pull request quadrupled the performance of some queries (with relatively small datasets!).

However, this also introduces the necessity of decoding the object ids back to RDF terms. For example, by converting it to the PlainTermEncoding. For queries that spend little time on join operations, the cost of decoding the object ids can outweigh the benefits of using the object id encoding.

Furthermore, the encoding introduces the necessity of maintaining the ObjectIdMapping, which can be non-trivial.

§Current Limitation

Currently, this id is fixed to being a 32-bit integer. However, we have an issue that tracks the progress on limiting this limitation.

Implementations§

Source§

impl ObjectIdEncoding

Source

pub fn new(object_id_size: u8) -> Self

Creates a new ObjectIdEncoding.

Source

pub fn object_id_size(&self) -> u8

Returns the size of the object id.

Trait Implementations§

Source§

impl Clone for ObjectIdEncoding

Source§

fn clone(&self) -> ObjectIdEncoding

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ObjectIdEncoding

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for ObjectIdEncoding

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for ObjectIdEncoding

Source§

fn eq(&self, other: &ObjectIdEncoding) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TermDecoder<ObjectIdEncoding> for DefaultObjectIdDecoder

Source§

type Term<'data> = ObjectId

The resulting value type of decoding an RDF term.
Source§

fn decode_terms( array: &<ObjectIdEncoding as TermEncoding>::Array, ) -> impl Iterator<Item = ThinResult<Self::Term<'_>>>

Allows extracting an iterator over all RDF terms in array that are compatible with this decoder (see TermDecoder for more information). Read more
Source§

fn decode_term( scalar: &<ObjectIdEncoding as TermEncoding>::Scalar, ) -> ThinResult<Self::Term<'_>>

Allows extracting an iterator over all RDF terms in array that are compatible with this decoder (see TermDecoder for more information). Read more
Source§

impl TermEncoding for ObjectIdEncoding

Source§

type Array = ObjectIdArray

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.
Source§

type Scalar = ObjectIdScalar

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.
Source§

fn name(&self) -> EncodingName

Returns the name of the encoding.
Source§

fn data_type(&self) -> DataType

Returns the DataType that is used for this encoding. Read more
Source§

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.
Source§

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.
Source§

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.
Source§

impl Eq for ObjectIdEncoding

Source§

impl StructuralPartialEq for ObjectIdEncoding

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynEq for T
where T: Eq + Any,

Source§

fn dyn_eq(&self, other: &(dyn Any + 'static)) -> bool

Source§

impl<T> DynHash for T
where T: Hash + Any,

Source§

fn dyn_hash(&self, state: &mut dyn Hasher)

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

impl<T> ErasedDestructor for T
where T: 'static,