Class: SPARQL::Algebra::Operator::Modify

Inherits:
SPARQL::Algebra::Operator show all
Includes:
Update
Defined in:
vendor/bundler/ruby/2.5.0/bundler/gems/sparql-7b34b4cf091a/lib/sparql/algebra/operator/modify.rb

Overview

The SPARQL UPDATE modify operator.

Wraps delete/insert

Examples:

(modify
  (bgp (triple ?a foaf:knows ?b))
  (delete ((triple ?a foaf:knows ?b)))
  (insert ((triple ?b foaf:knows ?a)))

See Also:

  • XXX

Constant Summary collapse

NAME =
[:modify]

Constants inherited from SPARQL::Algebra::Operator

ARITY, IsURI, URI

Instance Attribute Summary

Attributes inherited from SPARQL::Algebra::Operator

#operands

Instance Method Summary collapse

Methods included from Update

#graph_name=, #unshift, #variables

Methods inherited from SPARQL::Algebra::Operator

#aggregate?, arity, #base_uri, base_uri, base_uri=, #boolean, #constant?, #each_descendant, #eql?, #evaluatable?, evaluate, #executable?, #first_ancestor, for, #initialize, #inspect, #ndvars, #node?, #operand, #optimize, #parent, #parent=, prefixes, #prefixes, prefixes=, #rewrite, #to_binary, #to_sxp, #to_sxp_bin, #validate!, #variable?, #vars

Methods included from Expression

cast, #constant?, #evaluate, extension, extensions, for, #invalid?, new, #node?, open, #optimize, parse, register_extension, #to_sxp_bin, #valid?, #validate!, #variable?

Constructor Details

This class inherits a constructor from SPARQL::Algebra::Operator

Instance Method Details

#execute(queryable, options = {}) ⇒ RDF::Queryable

Executes this upate on the given writable graph or repository.

Execute the first operand to get solutions, and apply those solutions to the subsequent operators.

Parameters:

  • queryable (RDF::Queryable)

    the graph or repository to write

  • options (Hash{Symbol => Object}) (defaults to: {})

    any additional keyword options

Options Hash (options):

  • debug (Boolean)

    Query execution debugging

Returns:

Raises:

  • (IOError)

    If from does not exist, unless the silent operator is present

See Also:



37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/sparql-7b34b4cf091a/lib/sparql/algebra/operator/modify.rb', line 37

def execute(queryable, options = {})
  debug(options) {"Modify"}
  query = operands.shift

  queryable.query(query, options.merge(depth: options[:depth].to_i + 1)) do |solution|
    debug(options) {"(solution)=>#{solution.inspect}"}

    # Execute each operand with queryable and solution
    operands.each do |op|
      op.execute(queryable, solution, options.merge(depth: options[:depth].to_i + 1))
    end
  end
  queryable
end