Sha256: 5fb960747b9ab5b369bef2bfbb89fa42b3f10396d417b0c65377f83108ff44e0

Contents?: true

Size: 1.95 KB

Versions: 7

Compression:

Stored size: 1.95 KB

Contents

module SPARQL; module Algebra
  class Operator
    ##
    # The SPARQL GraphPattern `base` operator.
    #
    # @example
    #   (base <http://example.org/>
    #     (bgp (triple <a> <b> 123.0)))
    #
    # @see https://www.w3.org/TR/sparql11-query/#QSynIRI
    class Base < Binary
      include Query
      
      NAME = [:base]

      ##
      # Executes this query on the given `queryable` graph or repository.
      # Really a pass-through, as this is a syntactic object used for providing
      # context for relative URIs.
      #
      # @param  [RDF::Queryable] queryable
      #   the graph or repository to query
      # @param  [Hash{Symbol => Object}] options
      #   any additional keyword options
      # @yield  [solution]
      #   each matching solution, statement or boolean
      # @yieldparam  [RDF::Statement, RDF::Query::Solution, Boolean] solution
      # @yieldreturn [void] ignored
      # @return [RDF::Queryable, RDF::Query::Solutions]
      #   the resulting solution sequence
      # @see    https://www.w3.org/TR/sparql11-query/#sparqlAlgebra
      def execute(queryable, **options, &block)
        debug(options) {"Base #{operands.first}"}
        Operator.base_uri = operands.first
        queryable.query(operands.last, depth: options[:depth].to_i + 1, **options, &block)
      end

      ##
      # Return optimized query
      #
      # @return [Base] a copy of `self`
      # @see SPARQL::Algebra::Expression#optimize
      def optimize(**options)
        Operator.base_uri = operands.first
        operands.last.optimize(**options)
      end

      # Query results in a boolean result (e.g., ASK)
      # @return [Boolean]
      def query_yields_boolean?
        operands.last.query_yields_boolean?
      end

      # Query results statements (e.g., CONSTRUCT, DESCRIBE, CREATE)
      # @return [Boolean]
      def query_yields_statements?
        operands.last.query_yields_statements?
      end
    end # Base
  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/base.rb
sparql-3.1.7 lib/sparql/algebra/operator/base.rb
sparql-3.1.6 lib/sparql/algebra/operator/base.rb
sparql-3.1.5 lib/sparql/algebra/operator/base.rb
sparql-3.1.4 lib/sparql/algebra/operator/base.rb
sparql-3.1.3 lib/sparql/algebra/operator/base.rb
sparql-3.1.2 lib/sparql/algebra/operator/base.rb