Class: SPARQL::Algebra::Operator::Ask

Inherits:
Unary show all
Includes:
Query
Defined in:
lib/sparql/algebra/operator/ask.rb

Overview

The SPARQL GraphPattern ask operator.

Examples:

(prefix ((: <http://example/>))
  (ask
    (bgp (triple :x :p ?x))))

See Also:

Constant Summary

NAME =
[:ask]

Constants inherited from Unary

Unary::ARITY

Constants inherited from SPARQL::Algebra::Operator

ARITY

Instance Attribute Summary

Attributes included from Query

#solutions

Attributes inherited from SPARQL::Algebra::Operator

#operands, #options

Instance Method Summary collapse

Methods included from Query

#context=, #each_solution, #failed?, #matched?, #unshift, #variables

Methods inherited from Unary

#initialize

Methods inherited from SPARQL::Algebra::Operator

arity, base_uri, #base_uri, base_uri=, #boolean, #constant?, #eql?, #evaluatable?, evaluate, #executable?, for, #initialize, #inspect, #operand, prefixes, #prefixes, prefixes=, #to_sse, #to_sxp, #variable?

Methods included from Evaluatable

#apply, #evaluate, #memoize

Methods included from Expression

cast, #constant?, #evaluate, for, new, open, parse, #to_sse, #variable?

Constructor Details

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

Instance Method Details

#execute(queryable, options = {}) ⇒ RDF::Literal::Boolean

Executes this query on the given queryable graph or repository. Returns true if any solutions are found, false otherwise.

Parameters:

  • queryable (RDF::Queryable)

    the graph or repository to query

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

    any additional keyword options

Returns:

  • (RDF::Literal::Boolean)

    the resulting solution sequence

See Also:



28
29
30
31
32
33
# File 'lib/sparql/algebra/operator/ask.rb', line 28

def execute(queryable, options = {})
  debug("Ask #{operands.first}", options)
  boolean(!operands.last.
    execute(queryable, options.merge(:depth => options[:depth].to_i + 1)).
    empty?)
end

#optimizeUnion, RDF::Query

Returns an optimized version of this query.

Return optimized query

Returns:



41
42
43
# File 'lib/sparql/algebra/operator/ask.rb', line 41

def optimize
  operands = operands.map(&:optimize)
end