Sha256: 13629f0e9e231d02da78400525b25c39458fde53ceb19b5a4e6ecc4818cb1043
Contents?: true
Size: 1.33 KB
Versions: 1
Compression:
Stored size: 1.33 KB
Contents
module SPARQL; module Algebra class Operator ## # The SPARQL `count` set function. # # [127] Aggregate::= 'COUNT' '(' 'DISTINCT'? ( '*' | Expression ) ')' ... # # @example SPARQL Grammar # PREFIX : <http://www.example.org/> # SELECT (COUNT(?O) AS ?C) # WHERE { ?S ?P ?O } # # @example SSE # (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, **options) RDF::Literal(enum.length) end ## # # Returns a partial SPARQL grammar for this operator. # # @return [String] def to_sparql(**options) "COUNT(#{operands.to_sparql(**options)})" end end # Count end # Operator end; end # SPARQL::Algebra
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sparql-3.2.0 | lib/sparql/algebra/operator/count.rb |