Class: SPARQL::Algebra::Operator::Service

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

Overview

The SPARQL Service operator.

[59] ServiceGraphPattern ::= 'SERVICE' 'SILENT'? VarOrIri GroupGraphPattern

Examples:

SPARQL Grammar

PREFIX : <http://example.org/> 

SELECT ?s ?o1 ?o2  {
  ?s ?p1 ?o1 .
  SERVICE <http://example.org/sparql> {
    ?s ?p2 ?o2
  }
} 

SSE

(prefix ((: <http://example.org/>))
  (project (?s ?o1 ?o2)
    (join
      (bgp (triple ?s ?p1 ?o1))
      (service :sparql
        (bgp (triple ?s ?p2 ?o2))))))

See Also:

Constant Summary collapse

NAME =
[:service]

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 included from Query

#solutions

Attributes inherited from SPARQL::Algebra::Operator

#operands

Instance Method Summary collapse

Methods included from Query

#each_solution, #empty?, #failed?, #graph_name=, #matched?, #query_yields_boolean?, #query_yields_solutions?, #query_yields_statements?, #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!, #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!, 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) {|solution| ... } ⇒ RDF::Query::Solutions

Executes this query on the given queryable graph or repository. Really a pass-through, as this is a syntactic object used for providing graph_name for URIs.

Parameters:

Yields:

  • (solution)

    each matching solution, statement or boolean

Yield Parameters:

Yield Returns:

  • (void)

    ignored

Returns:

Raises:

  • (NotImplementedError)

See Also:



48
49
50
51
52
53
54
55
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sparql-796d3be4aa08/lib/sparql/algebra/operator/service.rb', line 48

def execute(queryable, **options, &block)
  debug(options) {"Service"}
  silent = operands.first == :silent
  location, query = operands
  query_sparql = query.to_sparql
  debug(options) {"query: #{query_sparql}"}
  raise NotImplementedError, "SERVICE operator not implemented"
end

#optimize(**options) ⇒ Prefix

Returns an optimized version of this query.

Replace with the query with URIs having their lexical shortcut removed

Returns:

See Also:



64
65
66
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sparql-796d3be4aa08/lib/sparql/algebra/operator/service.rb', line 64

def optimize(**options)
  operands.last.optimize(**options)
end

#to_sparql(**options) ⇒ String

Returns a partial SPARQL grammar for this term.

Returns:



73
74
75
76
77
78
79
80
81
82
83
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sparql-796d3be4aa08/lib/sparql/algebra/operator/service.rb', line 73

def to_sparql(**options)
  silent = operands.first == :silent
  ops = silent ? operands[1..-1] : operands
  location, query = ops

  
  str = "SERVICE "
  str << "SILENT " if silent
  str << location.to_sparql(**options) + " {" + query.to_sparql(**options) + "}"
  str
end