Class: SPARQL::Algebra::Operator::Distinct

Inherits:
Unary show all
Includes:
Query
Defined in:
lib/sparql/algebra/operator/distinct.rb

Overview

The SPARQL GraphPattern distinct operator.

Examples:

(prefix ((xsd: <http://www.w3.org/2001/XMLSchema#>)
         (: <http://example/>))
  (distinct
    (project (?v)
      (bgp (triple ?x ?p ?v)))))

See Also:

Constant Summary

NAME =
[:distinct]

Constants inherited from Unary

Unary::ARITY

Constants inherited from SPARQL::Algebra::Operator

ARITY

Instance Attribute Summary

Attributes included from Query

#solutions

Attributes inherited from SPARQL::Algebra::Operator

#operands, #options

Instance Method Summary (collapse)

Methods included from Query

#context=, #each_solution, #failed?, #matched?, #unshift, #variables

Methods inherited from Unary

#initialize

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 Evaluatable

#apply, #evaluate, #memoize

Methods included from Expression

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

Constructor Details

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

Instance Method Details

- (RDF::Query::Solutions) execute(queryable, options = {})

Executes this query on the given queryable graph or repository. Removes duplicate solutions from the solution set.



30
31
32
33
34
35
36
37
# File 'lib/sparql/algebra/operator/distinct.rb', line 30

def execute(queryable, options = {})
  debug("Distinct", options)
  @solutions = operands.last.execute(queryable, options.merge(:depth => options[:depth].to_i + 1))
  debug("=>(before) #{@solutions.inspect}", options)
  @solutions = @solutions.distinct
  debug("=>(after) #{@solutions.inspect}", options)
  @solutions
end

- (Union, RDF::Query) optimize

Returns an optimized version of this query.

Return optimized query



45
46
47
# File 'lib/sparql/algebra/operator/distinct.rb', line 45

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