Class: SPARQL::Algebra::Operator::FunctionCall

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

Overview

The SPARQL function_call operator.

[70] FunctionCall ::= iri ArgList

Examples:

SPARQL Grammar

PREFIX xsd:   <http://www.w3.org/2001/XMLSchema#>
SELECT *
WHERE { ?s ?p ?o . FILTER xsd:integer(?o) }

SSE

(prefix
 ((xsd: <http://www.w3.org/2001/XMLSchema#>))
 (filter (xsd:integer ?o)
  (bgp (triple ?s ?p ?o))))

See Also:

Constant Summary collapse

NAME =
:function_call

Constants inherited from SPARQL::Algebra::Operator

ARITY, IsURI, URI

Constants included from Expression

Expression::PATTERN_PARENTS

Instance Attribute Summary

Attributes inherited from SPARQL::Algebra::Operator

#operands

Instance Method Summary collapse

Methods included from Evaluatable

#evaluate, #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, #initialize, #inspect, #ndvars, #node?, #operand, #optimize, #optimize!, #parent, #parent=, #prefixes, prefixes, prefixes=, #rewrite, #to_binary, to_sparql, #to_sxp, #validate!, #variable?, #variables, #vars

Methods included from Expression

cast, #constant?, #evaluate, extension, extension?, extensions, for, #invalid?, new, #node?, open, #optimize, #optimize!, parse, register_extension, #valid?, #validate!, #variable?

Constructor Details

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

Instance Method Details

#apply(iri, *args, **options) ⇒ RDF::Term

Invokes the function with the passed arguments.

Parameters:

Returns:



34
35
36
37
# File 'lib/sparql/algebra/operator/function_call.rb', line 34

def apply(iri, *args, **options)
  args = RDF.nil == args.last ? args[0..-2] : args
  SPARQL::Algebra::Expression.extension(iri, *args, **options)
end

#to_sparql(**options) ⇒ String

Returns a partial SPARQL grammar for this operator.

Returns:

  • (String)


55
56
57
58
59
60
61
# File 'lib/sparql/algebra/operator/function_call.rb', line 55

def to_sparql(**options)
  iri, args = operands
  iri.to_sparql(**options) +
    '(' +
    args.to_sparql(delimiter: ', ', **options) +
    ')'
end

#to_sxp_binArray

Returns the SPARQL S-Expression (SSE) representation of this expression.

Remove the optional argument.

Returns:

See Also:



46
47
48
# File 'lib/sparql/algebra/operator/function_call.rb', line 46

def to_sxp_bin
  @operands.map(&:to_sxp_bin)
end