Class: SPARQL::Algebra::Operator::Prefix

Inherits:
Binary show all
Includes:
Query
Defined in:
vendor/bundler/ruby/2.5.0/bundler/gems/sparql-bb59900f675b/lib/sparql/algebra/operator/prefix.rb

Overview

The SPARQL GraphPattern prefix operator.

Examples:

(prefix ((: <http://example/>))
  (graph ?g
    (bgp (triple ?s ?p ?o))))

See Also:

Constant Summary

NAME =
[:prefix]

Constants inherited from Binary

Binary::ARITY

Constants inherited from SPARQL::Algebra::Operator

ARITY, IsURI, URI

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_solutions?, #unshift, #variables

Methods inherited from Binary

#initialize

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, #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, parse, register_extension, #to_sxp_bin, #valid?, #validate!, #variable?

Constructor Details

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

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:

  • queryable (RDF::Queryable)

    the graph or repository to query

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

    any additional keyword options

Yields:

  • (solution)

    each matching solution, statement or boolean

Yield Parameters:

Yield Returns:

  • (void)

    ignored

Returns:

See Also:



33
34
35
36
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/sparql-bb59900f675b/lib/sparql/algebra/operator/prefix.rb', line 33

def execute(queryable, options = {}, &block)
  debug(options) {"Prefix"}
  @solutions = queryable.query(operands.last, options.merge(depth: options[:depth].to_i + 1), &block)
end

#merge!(other) ⇒ Prefix

Combine two prefix definitions, merging their definitions

Parameters:

Returns:



52
53
54
55
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/sparql-bb59900f675b/lib/sparql/algebra/operator/prefix.rb', line 52

def merge!(other)
  operands[0] += other.operands[0]
  self
end

#optimizeUnion, RDF::Query

Returns an optimized version of this query.

If optimize operands, and if the first two operands are both Queries, replace with the unique sum of the query elements

Returns:



45
46
47
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/sparql-bb59900f675b/lib/sparql/algebra/operator/prefix.rb', line 45

def optimize
  operands.last.optimize
end

#query_yields_boolean?Boolean

Query results in a boolean result (e.g., ASK)

Returns:

  • (Boolean)


59
60
61
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/sparql-bb59900f675b/lib/sparql/algebra/operator/prefix.rb', line 59

def query_yields_boolean?
  operands.last.query_yields_boolean?
end

#query_yields_statements?Boolean

Query results statements (e.g., CONSTRUCT, DESCRIBE, CREATE)

Returns:

  • (Boolean)


65
66
67
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/sparql-bb59900f675b/lib/sparql/algebra/operator/prefix.rb', line 65

def query_yields_statements?
  operands.last.query_yields_statements?
end