Sha256: eae7db8bc278a4cde5c58a4f6acc87818cb0561fecf1066771cf6700ac70bf86

Contents?: true

Size: 1.72 KB

Versions: 10

Compression:

Stored size: 1.72 KB

Contents

module SPARQL; module Algebra
  class Operator
    ##
    # The SPARQL logical `exists` operator.
    #
    # There is a filter operator EXISTS that takes a graph pattern. EXISTS returns `true`/`false` depending on whether the pattern matches the dataset given the bindings in the current group graph pattern, the dataset and the active graph at this point in the query evaluation. No additional binding of variables occurs. The `NOT EXISTS` form translates into `fn:not(EXISTS{...})`.
    #
    # @example
    #    (prefix ((ex: <http://www.example.org/>))
    #      (filter (exists
    #                 (filter (notexists (bgp (triple ?s ?p ex:o2)))
    #                   (bgp (triple ?s ?p ex:o1))))
    #        (bgp (triple ?s ?p ex:o))))
    #
    # @see http://www.w3.org/TR/sparql11-query/#func-abs
    # @see http://www.w3.org/TR/xpath-functions/#func-abs
    class NotExists < Operator::Unary
      include Evaluatable

      NAME = [:notexists]

      ##
      # Exvaluating this operator executes the query in the first operator passing in each existing bindings.
      #
      # @param  [RDF::Query::Solution] bindings
      #   a query solution containing zero or more variable bindings
      # @param [Hash{Symbol => Object}] options ({})
      #   options passed from query
      # @option options[RDF::Queryable] queryable
      #   queryable to execute, using bindings as an initial solution.
      # @return [RDF::Literal::Boolean] `true` or `false`
      def evaluate(bindings, options = {})
        solutions = RDF::Query::Solutions(bindings)
        queryable = options[:queryable]
        operand(0).execute(queryable, options.merge(solutions: solutions)).empty?
      end
    end # NotExists
  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/notexists.rb
sparql-3.0.1 lib/sparql/algebra/operator/notexists.rb
sparql-3.0.0 lib/sparql/algebra/operator/notexists.rb
sparql-2.2.2 lib/sparql/algebra/operator/notexists.rb
sparql-2.2.1 lib/sparql/algebra/operator/notexists.rb
sparql-2.2.0 lib/sparql/algebra/operator/notexists.rb
sparql-2.1.0 lib/sparql/algebra/operator/notexists.rb
sparql-2.0.0 lib/sparql/algebra/operator/notexists.rb
sparql-2.0.0.beta2 lib/sparql/algebra/operator/notexists.rb
sparql-2.0.0.beta1 lib/sparql/algebra/operator/notexists.rb