Sha256: dbe6289bf96d8be0fad9f95499201c0777639f4d298799f035380b70c746fde0

Contents?: true

Size: 921 Bytes

Versions: 5

Compression:

Stored size: 921 Bytes

Contents

module SPARQL; module Algebra
  class Operator
    ##
    # The SPARQL `count` set function.
    #
    # @example
    #    (prefix ((: <http://www.example.org>))
    #      (project (?C)
    #        (extend ((?C ??.0))
    #          (group () ((??.0 (count ?O)))
    #            (bgp (triple ?S ?P ?O))))))
    #
    # @see https://www.w3.org/TR/sparql11-query/#defn_aggCount
    class Count < Operator
      include Aggregate

      NAME = :count

      ##
      # Count is a SPARQL set function which counts the number of times a given expression has a bound, and non-error value within the aggregate group.
      #
      # @param  [Enumerable<Array<RDF::Term>>] enum
      #   enum of evaluated operand
      # @return [RDF::Literal::Integer] The number of non-error terms in the multiset
      def apply(enum)
        RDF::Literal(enum.length)
      end
    end # Count
  end # Operator
end; end # SPARQL::Algebra

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sparql-3.1.6 lib/sparql/algebra/operator/count.rb
sparql-3.1.5 lib/sparql/algebra/operator/count.rb
sparql-3.1.4 lib/sparql/algebra/operator/count.rb
sparql-3.1.3 lib/sparql/algebra/operator/count.rb
sparql-3.1.2 lib/sparql/algebra/operator/count.rb