Class: LD::Patch::Algebra::Cut
- Inherits:
-
SPARQL::Algebra::Operator::Unary
- Object
- SPARQL::Algebra::Operator
- SPARQL::Algebra::Operator::Unary
- LD::Patch::Algebra::Cut
- Defined in:
- vendor/bundler/ruby/3.3.0/bundler/gems/ld-patch-a8edc852261e/lib/ld/patch/algebra/cut.rb
Overview
The LD Patch cut
operator.
The Cut operation is recursively remove triples from some starting node.
Constant Summary collapse
- NAME =
:cut
Constants inherited from SPARQL::Algebra::Operator::Unary
SPARQL::Algebra::Operator::Unary::ARITY
Constants inherited from SPARQL::Algebra::Operator
SPARQL::Algebra::Operator::ARITY, SPARQL::Algebra::Operator::IsURI, SPARQL::Algebra::Operator::URI
Constants included from SPARQL::Algebra::Expression
SPARQL::Algebra::Expression::PATTERN_PARENTS
Constants included from RDF::Util::Logger
Instance Attribute Summary
Attributes inherited from SPARQL::Algebra::Operator
Instance Method Summary collapse
-
#execute(queryable, options = {}) ⇒ RDF::Query::Solutions
Executes this upate on the given
writable
graph or repository.
Methods included from SPARQL::Algebra::Evaluatable
#apply, #evaluate, #memoize, #replace_aggregate!, #replace_vars!
Methods included from SPARQL::Algebra::Update
#graph_name=, #unshift, #variables
Methods inherited from SPARQL::Algebra::Operator::Unary
Methods inherited from SPARQL::Algebra::Operator
#aggregate?, arity, base_uri, #base_uri, base_uri=, #bind, #boolean, #constant?, #deep_dup, #each_descendant, #eql?, #evaluatable?, evaluate, #executable?, #first_ancestor, for, #formulae, #initialize, #inspect, #mergable?, #ndvars, #node?, #operand, #optimize, #optimize!, #parent, #parent=, prefixes, #prefixes, prefixes=, #rewrite, #to_binary, #to_sparql, to_sparql, #to_sxp, #to_sxp_bin, #validate!, #variable?, #variables, #vars
Methods included from SPARQL::Algebra::Expression
cast, #constant?, #evaluate, extension, extension?, extensions, for, #invalid?, new, #node?, open, #optimize, #optimize!, parse, register_extension, #to_sxp_bin, #valid?, #validate!, #variable?
Methods included from RDF::Util::Logger
#log_debug, #log_depth, #log_error, #log_fatal, #log_info, #log_recover, #log_recovering?, #log_statistics, #log_warn, #logger
Constructor Details
This class inherits a constructor from SPARQL::Algebra::Operator::Unary
Instance Method Details
#execute(queryable, options = {}) ⇒ RDF::Query::Solutions
Executes this upate on the given writable
graph or repository.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/ld-patch-a8edc852261e/lib/ld/patch/algebra/cut.rb', line 28 def execute(queryable, = {}) debug() {"Cut"} bindings = .fetch(:bindings) solution = bindings.first var = operand(0) # Bind variable raise LD::Patch::Error.new("Operand uses unbound variable #{var.inspect}", code: 400) unless solution.bound?(var) var = solution[var] cut_count = 0 # Get triples to delete using consice bounded description queryable.concise_bounded_description(var) do |statement| queryable.delete(statement) cut_count += 1 end # Also delete triples having var in the object position queryable.query({object: var}).each do |statement| queryable.delete(statement) cut_count += 1 end raise LD::Patch::Error, "Cut removed no triples" unless cut_count > 0 bindings end |