Class: SPARQL::Algebra::Operator::Create

Inherits:
SPARQL::Algebra::Operator show all
Includes:
Update
Defined in:
vendor/bundler/ruby/3.3.0/bundler/gems/sparql-796d3be4aa08/lib/sparql/algebra/operator/create.rb

Overview

The SPARQL UPDATE create operator.

This operation creates a graph in the Graph Store

This is a no-op for RDF.rb implementations, unless the graph exists

[34] Create ::= 'CREATE' 'SILENT'? GraphRef

Examples:

SPARQL Grammar

CREATE SILENT GRAPH <http://example.org/g1>

SSE

(update (create silent <http://example.org/g1>))

See Also:

Constant Summary collapse

NAME =
[:create]

Constants inherited from SPARQL::Algebra::Operator

ARITY, IsURI, URI

Constants included from Expression

Expression::PATTERN_PARENTS

Constants included from RDF::Util::Logger

RDF::Util::Logger::IOWrapper

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=, #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.

Parameters:

Options Hash (**options):

  • debug (Boolean)

    Query execution debugging

Returns:

Raises:

  • (IOError)

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

See Also:



39
40
41
42
43
44
45
46
47
48
49
50
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sparql-796d3be4aa08/lib/sparql/algebra/operator/create.rb', line 39

def execute(queryable, **options)
  debug(options) {"Create"}
  silent = operands.first == :silent
  operands.shift if silent

  iri = operands.first
  raise ArgumentError, "clear expected a single IRI" if operands.length != 1 || !iri.is_a?(RDF::URI)
  if queryable.has_graph?(iri)
    raise IOError, "create operation graph #{iri.to_ntriples} exists" unless silent
  end
  queryable
end

#to_sparql(**options) ⇒ String

Returns a partial SPARQL grammar for this operator.

Returns:



57
58
59
60
61
62
63
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sparql-796d3be4aa08/lib/sparql/algebra/operator/create.rb', line 57

def to_sparql(**options)
  silent = operands.first == :silent
  str = "CREATE "
  str << "SILENT " if operands.first == :silent
  str << "GRAPH " if operands.last.is_a?(RDF::URI)
  str << operands.last.to_sparql(**options)
end