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

Inherits:
SPARQL::Algebra::Operator show all
Includes:
Evaluatable
Defined in:
vendor/bundler/ruby/2.5.0/bundler/gems/sparql-b66c70fb77a0/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, IsURI, URI

Instance Attribute Summary

Attributes inherited from SPARQL::Algebra::Operator

#operands

Instance Method Summary collapse

Methods included from Evaluatable

#apply, #memoize, #replace_aggregate!, #replace_vars!

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?, 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

Instance Method Details

#evaluate(bindings, options = {}) ⇒ 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)

    a query solution containing zero or more variable bindings

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

    ({}) options passed from query

Returns:

Raises:

  • (TypeError)

    if the operands could not be coerced to a boolean literal



39
40
41
42
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/sparql-b66c70fb77a0/lib/sparql/algebra/operator/exprlist.rb', line 39

def evaluate(bindings, options = {})
  res = operands.all? {|op| boolean(op.evaluate(bindings, options.merge(depth: options[:depth].to_i + 1))).true? }
  RDF::Literal(res) # FIXME: error handling
end

#optimizeUnion, RDF::Query

Returns an optimized version of this query.

Return optimized query

Returns:



50
51
52
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/sparql-b66c70fb77a0/lib/sparql/algebra/operator/exprlist.rb', line 50

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