pub trait ObjectIdMapping:
Debug
+ Send
+ Sync {
// Required methods
fn encoding(&self) -> ObjectIdEncoding;
fn try_get_object_id(
&self,
scalar: &PlainTermScalar,
) -> Result<Option<ObjectIdScalar>, ObjectIdMappingError>;
fn encode_array(
&self,
array: &PlainTermArray,
) -> Result<ObjectIdArray, ObjectIdMappingError>;
fn decode_array(
&self,
array: &ObjectIdArray,
) -> Result<PlainTermArray, ObjectIdMappingError>;
fn decode_array_to_typed_value(
&self,
array: &ObjectIdArray,
) -> Result<TypedValueArray, ObjectIdMappingError>;
// Provided methods
fn encode_scalar(
&self,
scalar: &PlainTermScalar,
) -> Result<ObjectIdScalar, ObjectIdMappingError> { ... }
fn decode_scalar(
&self,
scalar: &ObjectIdScalar,
) -> Result<PlainTermScalar, ObjectIdMappingError> { ... }
fn decode_scalar_to_typed_value(
&self,
scalar: &ObjectIdScalar,
) -> Result<TypedValueScalar, ObjectIdMappingError> { ... }
}
Expand description
The object id mapping is responsible for mapping between object ids and RDF terms in the ObjectIdEncoding.
The mapping between the object id and the RDF term is bijective. In other words, each distinct
RDF term maps to exactly one object id, while each object id maps to exactly one RDF term. As
a result, operations that rely on the equality of RDF terms (SAME_TERM
) can directly work
with the object ids. Joining solution sets is the most important example.
§Typed Values
To speed up decoding object ids directly into the TypedValueEncoding, the trait also contains methods for directly mapping object ids to their typed values. This can be implemented in two ways:
- Decode the object id to a plain term and then translate the term to a typed value
- Maintain a second mapping from the object ids to the typed value of their associated RDF term
Contrary to the mapping between RDF terms and object ids, the mapping between typed values and
object ids is not bijective. A single typed value can map to multiple object ids. For example,
this is the case for the two RDF terms "01"^^xsd:integer
and "1"^^xsd:integer
.
Required Methods§
Sourcefn encoding(&self) -> ObjectIdEncoding
fn encoding(&self) -> ObjectIdEncoding
Returns the encoding.
Sourcefn try_get_object_id(
&self,
scalar: &PlainTermScalar,
) -> Result<Option<ObjectIdScalar>, ObjectIdMappingError>
fn try_get_object_id( &self, scalar: &PlainTermScalar, ) -> Result<Option<ObjectIdScalar>, ObjectIdMappingError>
Try to retrieve the object id of the given scalar
.
This method does not automatically create a mapping. See Self::encode_scalar for this functionality.
Sourcefn encode_array(
&self,
array: &PlainTermArray,
) -> Result<ObjectIdArray, ObjectIdMappingError>
fn encode_array( &self, array: &PlainTermArray, ) -> Result<ObjectIdArray, ObjectIdMappingError>
Encodings the entire array
as an ObjectIdArray. Automatically creates a mapping for a
fresh object id if a term is not yet mapped.
Sourcefn decode_array(
&self,
array: &ObjectIdArray,
) -> Result<PlainTermArray, ObjectIdMappingError>
fn decode_array( &self, array: &ObjectIdArray, ) -> Result<PlainTermArray, ObjectIdMappingError>
Decodes the entire array
as a PlainTermArray.
Sourcefn decode_array_to_typed_value(
&self,
array: &ObjectIdArray,
) -> Result<TypedValueArray, ObjectIdMappingError>
fn decode_array_to_typed_value( &self, array: &ObjectIdArray, ) -> Result<TypedValueArray, ObjectIdMappingError>
Decodes the entire array
as a TypedValueArray.
Provided Methods§
Sourcefn encode_scalar(
&self,
scalar: &PlainTermScalar,
) -> Result<ObjectIdScalar, ObjectIdMappingError>
fn encode_scalar( &self, scalar: &PlainTermScalar, ) -> Result<ObjectIdScalar, ObjectIdMappingError>
Encodes a single scalar
as an ObjectIdScalar. Automatically creates a mapping for a
fresh object id if the term is not yet mapped.
Sourcefn decode_scalar(
&self,
scalar: &ObjectIdScalar,
) -> Result<PlainTermScalar, ObjectIdMappingError>
fn decode_scalar( &self, scalar: &ObjectIdScalar, ) -> Result<PlainTermScalar, ObjectIdMappingError>
Decodes a single scalar
as a PlainTermScalar.
Sourcefn decode_scalar_to_typed_value(
&self,
scalar: &ObjectIdScalar,
) -> Result<TypedValueScalar, ObjectIdMappingError>
fn decode_scalar_to_typed_value( &self, scalar: &ObjectIdScalar, ) -> Result<TypedValueScalar, ObjectIdMappingError>
Decodes a single scalar
as a TypedValueScalar.