Skip to main content

Module encoding

Module encoding 

Source
Expand description

Term encoding: every RDF term maps to a tagged 64-bit integer id.

Layout (the sign bit is always 0, so ids are positive SQLite INTEGERs):

 63 | 62..59 | 58..0
  0 |  tag   | payload (hash, or inline value)

Hashed kinds store a 59-bit xxh3 hash of a canonical key and need a row in terms. Inline kinds (canonical xsd:integer in ±2^58 and canonical xsd:boolean) carry their value in the payload, need no terms row, and — because the integer payload is offset — sort by value, so range filters on inline integers are id range scans.

Modules§

numeric_type
Numeric type ranks used for SPARQL type promotion.

Structs§

EncodedRows
Everything that must be written so that an encoded term can be decoded later.
TermRow
The row stored in terms for a hashed term.
TripleRow
The row stored in triple_terms for an RDF 1.2 triple term.

Enums§

Tag
Term kinds, stored in the 4 tag bits.

Constants§

DEFAULT_GRAPH_ID
The id of the default graph.
INT_MAX
Largest inline integer.
INT_MIN
Smallest inline integer.
INT_OFFSET
Offset applied to inline integers so that ids sort by value.
PAYLOAD_BITS
Number of bits used by the payload.
PAYLOAD_MASK
Mask selecting the payload.

Functions§

blank_node_id
Encodes a blank node.
boolean_id
Builds the id of a boolean.
decode_inline
Decodes an inline id (integer, boolean) without any lookup.
decode_row
Decodes a hashed id from its terms row.
encode_literal
Encodes a literal, returning its id and (for hashed literals) the row to store.
graph_id
integer_id
Builds the id of an inline integer, if it fits.
make_quad
Builds a quad from decoded parts.
make_triple
Rebuilds a triple from its decoded components.
named_node_id
Encodes a named node.
numeric_rank
Returns the numeric type rank of a datatype, if numeric.
rdf_type_id
Well-known ids used by the planner and reasoner.
sort_key
A string whose byte order is the ORDER BY order of terms (blank nodes, IRIs, numbers by value, other literals by lexical form, triple terms by components).
subject_id
tag_of
Extracts the tag of an id.
term_id
Encodes a term without collecting rows (only the id).
timestamp
Seconds since the epoch of an xsd:dateTime or xsd:date lexical form (no timezone = UTC).
timezone_flag
For xsd:dateTime / xsd:date values: 1 if the lexical form has a timezone, else 0.
to_graph_name
Converts a decoded term into a graph name.
to_subject
Converts a decoded term into a subject.
triple_id
Id of a triple term (hash of its component ids).
value_key
A string that is equal for value-equal terms (numbers by value, dates by instant): used to compare triple terms with SPARQL = in one SQL comparison.