sage.query_engine.update package

Submodules

sage.query_engine.update.delete module

class sage.query_engine.update.delete.DeleteOperator(quads: List[Tuple[str, str, str, str]], dataset: sage.database.core.dataset.Dataset)

Bases: sage.query_engine.iterators.preemptable_iterator.PreemptableIterator

A DeleteOperator deletes RDF triples from a RDF dataset.

Args:
  • quads: List of RDF quads to delete from the RDF dataset.

  • dataset: RDF dataset.

has_next() → bool

Return True if the iterator has more quads to delete

async next() → Optional[Dict[str, str]]

Delete the next quad from the RDF dataset.

This function works in an iterator fashion, so it can be used in a pipeline of iterators. It may also contains non interruptible clauses which must be atomically evaluated before preemption occurs.

Returns: The quad if it was successfully deleted, otwherise it returns None.

next_stage(mappings: Dict[str, str]) → None

Propagate mappings to the bottom of the pipeline in order to compute nested loop joins

save() → iterators_pb2.SavedDeleteData

Save and serialize the iterator as a Protobuf message

serialized_name() → str

Get the name of the iterator, as used in the plan serialization protocol

sage.query_engine.update.if_exists module

class sage.query_engine.update.if_exists.IfExistsOperator(quads: List[Dict[str, str]], dataset: sage.database.core.dataset.Dataset, start_time: datetime.datetime)

Bases: sage.query_engine.iterators.preemptable_iterator.PreemptableIterator

An IfExistsOperator checks if all N-Quads in a set exist in the database.

It is used to provide the “serializability per solution group” consistency level.

Args:
  • quads: RDF quads to validate.

  • dataset: RDF dataset.

  • start_time: A timestamp used to perform all reads against a consistent version of the dataset.

has_next() → bool

Return True if the iterator has more quads to validate

property missing_nquads

Returns True if, at the time of invocation, at least one n-quad was not found in the RDF dataset.

async next() → Optional[Dict[str, str]]

Validate the next quad using the RDF dataset.

This function works in an iterator fashion, so it can be used in a pipeline of iterators. It may also contains non interruptible clauses which must be atomically evaluated before preemption occurs.

Returns: always None

Throws: StopAsyncIteration if the iterator has no more quads to validate.

save() → str

Useless for this operator, as it MUST run completely inside a quantum

serialized_name() → str

Get the name of the iterator, as used in the plan serialization protocol

sage.query_engine.update.insert module

class sage.query_engine.update.insert.InsertOperator(quads: List[Tuple[str, str, str, str]], dataset: sage.database.core.dataset.Dataset)

Bases: sage.query_engine.iterators.preemptable_iterator.PreemptableIterator

A DeleteOperator inserts RDF triples into a RDF dataset.

Args:
  • quads: List of RDF quads to insert into the RDF dataset.

  • dataset: RDF dataset

has_next() → bool

Return True if the iterator has more quads to insert

async next() → Optional[Dict[str, str]]

Insert the next quad into the RDF dataset.

This function works in an iterator fashion, so it can be used in a pipeline of iterators. It may also contains non interruptible clauses which must be atomically evaluated before preemption occurs.

Returns: The quad if it was successfully inserted, otwherise it returns None.

next_stage(mappings: Dict[str, str]) → None

Propagate mappings to the bottom of the pipeline in order to compute nested loop joins

save() → iterators_pb2.SavedInsertData

Save and serialize the iterator as a Protobuf message

serialized_name() → str

Get the name of the iterator, as used in the plan serialization protocol

sage.query_engine.update.serializable module

class sage.query_engine.update.serializable.SerializableUpdate(dataset: sage.database.core.dataset.Dataset, read_input: sage.query_engine.iterators.preemptable_iterator.PreemptableIterator, delete_templates: List[Tuple[str, str, str, str]], insert_templates: List[Tuple[str, str, str, str]])

Bases: sage.query_engine.iterators.preemptable_iterator.PreemptableIterator

A SerializableUpdate iterator evaluates a SPARQL INSERT/DELETE query as a serializable transaction.

Args:
  • dataset: RDF dataset to update.

  • read_input: Iterator that evaluates a WHERE clause.

  • delete_templates: List of delete templates from the DELETE clause (nquads to delete).

  • insert_templates: List of insert templates from the INSERT clause (nquads to insert).

has_next() → bool

Return True if the iterator has more quads to process.

This iterator has not finished to process quads iff:
  • the read set is not entierly built, or

  • all deletes have not been performed, or

  • all insert have not been performed.

async next() → None

Execute the SPARQL INSERT/DELETE query.

This function blocks until the whole query has been processed. hence, it breaks the iterator model as all the work is done in a single call to next() It may also contains non interruptible clauses which must be atomically evaluated before preemption occurs.

Returns: Always None

Throws:
  • StopAsyncIteration if the iterator has fnished query processing.

  • SerializationFailure if the SPARQL UPDATE query cannot be serialized as a transaction.

save() → str

Useless for this operator, as it MUST run completely inside a quantum

serialized_name() → str

Get the name of the iterator, as used in the plan serialization protocol

sage.query_engine.update.serializable.apply_templates(mappings: List[Dict[str, str]], templates: List[Tuple[str, str, str, str]]) → Iterable[Tuple[str, str, str, str]]

Returns an iterator that applies each mapping in a set to a set of quads templates and returns the distinct quads produced.

sage.query_engine.update.update_sequence module

class sage.query_engine.update.update_sequence.UpdateSequenceOperator(if_exists_op: sage.query_engine.iterators.preemptable_iterator.PreemptableIterator, delete_op: sage.query_engine.iterators.preemptable_iterator.PreemptableIterator, insert_op: sage.query_engine.iterators.preemptable_iterator.PreemptableIterator)

Bases: sage.query_engine.iterators.preemptable_iterator.PreemptableIterator

An UpdateSequenceOperator evaluates a “IF_EXISTS DELETE INSERT” query.

It is used to provide serializability per solution group. To do so, it sequentually evaluates a IfExistsOperator, then a DeleteOperator and finally an InsertOperator.

Args:
  • if_exists_op: Operator used to evaluated the IF_EXISTS clause.

  • delete_op: Operator used to evaluated the DELETE clause.

  • insert_op: Operator used to evaluated the INSERT clause.

has_next() → bool

Return True if the iterator has more quads to process.

async next() → Optional[Dict[str, str]]

Advance in the sequence of operations.

This function works in an iterator fashion, so it can be used in a pipeline of iterators. It may also contains non interruptible clauses which must be atomically evaluated before preemption occurs.

Returns: Always None

Throws:
  • StopAsyncIteration if the iterator has fnished query processing.

  • DeleteInsertConflict if a read-write conflict is detected.

save() → str

Useless for this operator, as it MUST run completely inside a quantum

serialized_name() → str

Get the name of the iterator, as used in the plan serialization protocol

Module contents