Class: SPARQL::Algebra::Operator::Clear
- Inherits:
-
SPARQL::Algebra::Operator
- Object
- SPARQL::Algebra::Operator
- SPARQL::Algebra::Operator::Clear
- Includes:
- Update
- Defined in:
- vendor/bundler/ruby/3.3.0/bundler/gems/sparql-796d3be4aa08/lib/sparql/algebra/operator/clear.rb
Overview
The SPARQL UPDATE clear
operator.
The CLEAR operation removes all the triples in the specified graph(s) in the Graph Store.
[32] Clear ::= 'CLEAR' 'SILENT'? GraphRefAll
Constant Summary collapse
- NAME =
[:clear]
Constants inherited from SPARQL::Algebra::Operator
Constants included from Expression
Constants included from RDF::Util::Logger
Instance Attribute Summary
Attributes inherited from SPARQL::Algebra::Operator
Instance Method Summary collapse
-
#execute(queryable, **options) ⇒ RDF::Queryable
Executes this upate on the given
writable
graph or repository. -
#to_sparql(**options) ⇒ String
Returns a partial SPARQL grammar for this operator.
Methods included from Update
#graph_name=, #unshift, #variables
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_sxp, #to_sxp_bin, #validate!, #variable?, #variables, #vars
Methods included from 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
Instance Method Details
#execute(queryable, **options) ⇒ RDF::Queryable
Executes this upate on the given writable
graph or repository.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sparql-796d3be4aa08/lib/sparql/algebra/operator/clear.rb', line 43 def execute(queryable, **) debug() {"Clear"} silent = operands.first == :silent operands.shift if silent raise ArgumentError, "clear expected operand to be 'default', 'named', 'all', or an IRI" unless operands.length == 1 case operands.last when :default queryable.each_graph do |g| g.clear! unless g.graph_name end when :named queryable.each_graph do |g| g.clear! if g.graph_name end when :all queryable.clear! when RDF::URI if g = queryable.each_graph.detect {|c| c.graph_name == operands.last} g.clear! else raise IOError, "clear operation graph does not exist" unless silent end else raise ArgumentError, "clear expected operand to be 'default', 'named', 'all', or an IRI" end queryable end |
#to_sparql(**options) ⇒ String
Returns a partial SPARQL grammar for this operator.
78 79 80 81 82 83 84 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sparql-796d3be4aa08/lib/sparql/algebra/operator/clear.rb', line 78 def to_sparql(**) silent = operands.first == :silent str = "CLEAR " str << "SILENT " if operands.first == :silent str << "GRAPH " if operands.last.is_a?(RDF::URI) str << operands.last.to_sparql(**) end |