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

Inherits:
SPARQL::Algebra::Operator show all
Includes:
Evaluatable
Defined in:
vendor/bundler/ruby/3.3.0/bundler/gems/sparql-36baa432eb7f/lib/sparql/algebra/operator/exprlist.rb

Overview

The SPARQL GraphPattern exprlist operator.

Used for filters with more than one expression.

[72] ExpressionList ::= NIL | '(' Expression ( ',' Expression )* ')'

Examples:

SPARQL Grammar

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

SELECT ?v ?w
{ 
  FILTER (?v = 2)
  FILTER (?w = 3)
  ?s :p ?v . 
  ?s :q ?w .
}

SSE

(prefix ((: <http://example.org/>))
  (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

Constants included from Expression

Expression::PATTERN_PARENTS

Constants included from RDF::Util::Logger

RDF::Util::Logger::IOWrapper

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=, #bind, #boolean, #constant?, #deep_dup, #each_descendant, #eql?, #evaluatable?, evaluate, #executable?, #first_ancestor, for, #formulae, #initialize, #inspect, #ndvars, #node?, #operand, #optimize, #optimize!, #parent, #parent=, prefixes, #prefixes, prefixes=, #rewrite, #to_binary, #to_sparql, to_sparql, #to_sxp, #to_sxp_bin, #validate!, #variable?, #variables, #vars

Methods included from Expression

cast, #constant?, extension, extension?, extensions, for, #invalid?, new, #node?, open, #optimize, #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

#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:

Returns:

Raises:

  • (TypeError)

    if the operands could not be coerced to a boolean literal



52
53
54
55
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sparql-36baa432eb7f/lib/sparql/algebra/operator/exprlist.rb', line 52

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