Sha256: c6c0db0ab8fbba91f33a2fd397a8974773bcff97cb5d1fca81aa7aefd0e6fa55

Contents?: true

Size: 1.36 KB

Versions: 7

Compression:

Stored size: 1.36 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 https://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    https://www.w3.org/TR/sparql11-query/#sparqlAlgebra
      def execute(queryable, **options, &block)
        @solutions = operands.last.
          execute(queryable, depth: options[:depth].to_i + 1, **options).reduced
        @solutions.each(&block) if block_given?
        @solutions
      end
    end # Reduced
  end # Operator
end; end # SPARQL::Algebra

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sparql-3.1.8 lib/sparql/algebra/operator/reduced.rb
sparql-3.1.7 lib/sparql/algebra/operator/reduced.rb
sparql-3.1.6 lib/sparql/algebra/operator/reduced.rb
sparql-3.1.5 lib/sparql/algebra/operator/reduced.rb
sparql-3.1.4 lib/sparql/algebra/operator/reduced.rb
sparql-3.1.3 lib/sparql/algebra/operator/reduced.rb
sparql-3.1.2 lib/sparql/algebra/operator/reduced.rb