Sha256: 8d022ce703715d9eac87018be20707f414982122532360ac0ddafc73d926e4bb

Contents?: true

Size: 1.59 KB

Versions: 10

Compression:

Stored size: 1.59 KB

Contents

module SPARQL; module Algebra
  class Operator
    ##
    # The SPARQL GraphPattern `reduced` operator.
    #
    # @example
    #   (prefix ((xsd: <http://www.w3.org/2001/XMLSchema#>)
    #            (: <http://example/>))
    #     (reduced
    #       (project (?v)
    #         (bgp (triple ?x ?p ?v)))))
    #
    # @see http://www.w3.org/TR/sparql11-query/#sparqlAlgebra
    class Reduced < Operator::Unary
      include Query
      
      NAME = [:reduced]

      ##
      # Executes this query on the given `queryable` graph or repository.
      # Removes duplicate solutions from the solution set.
      #
      # @param  [RDF::Queryable] queryable
      #   the graph or repository to query
      # @param  [Hash{Symbol => Object}] options
      #   any additional keyword options
      # @yield  [solution]
      #   each matching solution
      # @yieldparam  [RDF::Query::Solution] solution
      # @yieldreturn [void] ignored
      # @return [RDF::Query::Solutions]
      #   the resulting solution sequence
      # @see    http://www.w3.org/TR/sparql11-query/#sparqlAlgebra
      def execute(queryable, options = {}, &block)
        @solutions = operands.last.
          execute(queryable, options.merge(depth: options[:depth].to_i + 1)).reduced
        @solutions.each(&block) if block_given?
        @solutions
      end
      
      ##
      # Returns an optimized version of this query.
      #
      # Return optimized query
      #
      # @return [Union, RDF::Query] `self`
      def optimize
        operands = operands.map(&:optimize)
      end
    end # Reduced
  end # Operator
end; end # SPARQL::Algebra

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
sparql-3.0.2 lib/sparql/algebra/operator/reduced.rb
sparql-3.0.1 lib/sparql/algebra/operator/reduced.rb
sparql-3.0.0 lib/sparql/algebra/operator/reduced.rb
sparql-2.2.2 lib/sparql/algebra/operator/reduced.rb
sparql-2.2.1 lib/sparql/algebra/operator/reduced.rb
sparql-2.2.0 lib/sparql/algebra/operator/reduced.rb
sparql-2.1.0 lib/sparql/algebra/operator/reduced.rb
sparql-2.0.0 lib/sparql/algebra/operator/reduced.rb
sparql-2.0.0.beta2 lib/sparql/algebra/operator/reduced.rb
sparql-2.0.0.beta1 lib/sparql/algebra/operator/reduced.rb