Class: SPARQL::Algebra::Operator::Exprlist

Inherits:
SPARQL::Algebra::Operator show all
Includes:
Evaluatable
Defined in:
lib/sparql/algebra/operator/exprlist.rb

Overview

The SPARQL GraphPattern exprlist operator.

Used for filters with more than one expression.

Examples:

(prefix ((: <http://example/>))
  (project (?v ?w)
    (filter (exprlist (= ?v 2) (= ?w 3))
      (bgp
        (triple ?s :p ?v)
        (triple ?s :q ?w)
      ))))

See Also:

Constant Summary collapse

NAME =
[:exprlist]

Constants inherited from SPARQL::Algebra::Operator

ARITY

Instance Attribute Summary

Attributes inherited from SPARQL::Algebra::Operator

#operands, #options

Instance Method Summary collapse

Methods included from Evaluatable

#apply, #memoize

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 Expression

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

Constructor Details

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

Instance Method Details

#evaluate(bindings = {}) ⇒ RDF::Literal::Boolean

Returns true if all operands evaluate to true.

Note that this operator operates on the effective boolean value (EBV) of its operands.

Examples:


(exprlist (= 1 1) (!= 1 0))

Parameters:

  • bindings (RDF::Query::Solution, #[]) (defaults to: {})

Returns:

  • (RDF::Literal::Boolean)

    true or false

Raises:

  • (TypeError)

    if the operands could not be coerced to a boolean literal



36
37
38
39
# File 'lib/sparql/algebra/operator/exprlist.rb', line 36

def evaluate(bindings = {})
  res = operands.all? {|op| boolean(op.evaluate(bindings)).true? }
  RDF::Literal(res) # FIXME: error handling
end

#optimizeUnion, RDF::Query

Returns an optimized version of this query.

Return optimized query

Returns:



47
48
49
# File 'lib/sparql/algebra/operator/exprlist.rb', line 47

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