Class: SPARQL::Algebra::Operator::Min
- Inherits:
-
SPARQL::Algebra::Operator
- Object
- SPARQL::Algebra::Operator
- SPARQL::Algebra::Operator::Min
- Includes:
- Aggregate
- Defined in:
- vendor/bundler/ruby/2.7.0/bundler/gems/sparql-881ac01048a7/lib/sparql/algebra/operator/min.rb
Overview
The SPARQL min
set function.
Constant Summary collapse
- NAME =
:min
Constants inherited from SPARQL::Algebra::Operator
Instance Attribute Summary
Attributes inherited from SPARQL::Algebra::Operator
Instance Method Summary collapse
-
#apply(enum) ⇒ RDF::Literal
Min is a SPARQL set function that return the minimum value from a group respectively.
Methods included from Aggregate
#aggregate, #replace_aggregate!, #replace_vars!
Methods inherited from SPARQL::Algebra::Operator
#aggregate?, arity, base_uri, #base_uri, base_uri=, #bind, #boolean, #constant?, #deep_dup, #each_descendant, #eql?, #evaluatable?, evaluate, #executable?, #first_ancestor, for, #formulae, #initialize, #inspect, #ndvars, #node?, #operand, #optimize, #optimize!, #parent, #parent=, #prefixes, prefixes, prefixes=, #rewrite, #to_binary, #to_sxp, #to_sxp_bin, #validate!, #variable?, #vars
Methods included from Expression
cast, #constant?, #evaluate, extension, extensions, for, #invalid?, new, #node?, open, #optimize, #optimize!, parse, register_extension, #to_sxp_bin, #valid?, #validate!, #variable?
Constructor Details
This class inherits a constructor from SPARQL::Algebra::Operator
Instance Method Details
#apply(enum) ⇒ RDF::Literal
Min is a SPARQL set function that return the minimum value from a group respectively.
It makes use of the SPARQL ORDER BY ordering definition, to allow ordering over arbitrarily typed expressions.
27 28 29 30 31 32 33 34 35 36 37 |
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/sparql-881ac01048a7/lib/sparql/algebra/operator/min.rb', line 27 def apply(enum) # FIXME: we don't actually do anything with distinct operands.shift if distinct = (operands.first == :distinct) if enum.empty? raise TypeError, "Minumuim of an empty multiset" elsif enum.flatten.all? {|n| n.literal?} RDF::Literal(enum.flatten.min) else raise TypeError, "Minumuim of non-literals: #{enum.flatten}" end end |