Module: SPARQL::Algebra::Evaluatable Abstract

Included in:
Operator, Operator::And, Operator::Asc, Operator::Bound, Operator::Compare, Operator::Datatype, Operator::Divide, Operator::Exprlist, Operator::IsBlank, Operator::IsIRI, Operator::IsLiteral, Operator::Lang, Operator::LangMatches, Operator::Minus, Operator::Multiply, Operator::Not, Operator::Or, Operator::Plus, Operator::Regex, Operator::SameTerm, Operator::Str, Operator::Subtract
Defined in:
lib/sparql/algebra/evaluatable.rb

Overview

This module is abstract.

Mixin for Algebra::Operator sub-classes that evaluate bindings to return a result

Instance Method Summary (collapse)

Instance Method Details

- (RDF::Term) apply(*operands)

This method is abstract.

Raises:

  • (NotImplementedError)


33
34
35
# File 'lib/sparql/algebra/evaluatable.rb', line 33

def apply(*operands)
  raise NotImplementedError, "#{self.class}#apply(#{operands.map(&:class).join(', ')})"
end

- (RDF::Term) evaluate(bindings = {})

This method is abstract.

Evaluates this operator using the given variable bindings.



14
15
16
17
# File 'lib/sparql/algebra/evaluatable.rb', line 14

def evaluate(bindings = {})
  args = operands.map { |operand| operand.evaluate(bindings) }
  options[:memoize] ? memoize(*args) : apply(*args)
end

- (RDF::Term) memoize(*operands)



23
24
25
26
# File 'lib/sparql/algebra/evaluatable.rb', line 23

def memoize(*operands)
  @cache ||= RDF::Util::Cache.new(options[:memoize].is_a?(Integer) ? options[:memoize] : -1)
  @cache[operands] ||= apply(*operands)
end