Sha256: be585203b239a2f4d0d703b0df15f58289087a5bbf484527cf61912687f128e8
Contents?: true
Size: 1.37 KB
Versions: 7
Compression:
Stored size: 1.37 KB
Contents
module SPARQL; module Algebra class Operator ## # The SPARQL GraphPattern `project` operator. # # @example # (select (?v) # (project (?v) # (filter (= ?v 2) # (bgp (triple ?s <http://example/p> ?v))))) # # @see https://www.w3.org/TR/sparql11-query/#modProjection class Project < Operator::Binary include Query NAME = [:project] ## # Executes this query on the given `queryable` graph or repository. # Reduces the result set to the variables listed in the first operand # # @param [RDF::Queryable] queryable # the graph or repository to query # @param [Hash{Symbol => Object}] options # any additional keyword options # @yield [solution] # each matching solution # @yieldparam [RDF::Query::Solution] solution # @yieldreturn [void] ignored # @return [RDF::Query::Solutions] # the resulting solution sequence # @see https://www.w3.org/TR/sparql11-query/#sparqlAlgebra def execute(queryable, **options, &block) @solutions = queryable.query(operands.last, depth: options[:depth].to_i + 1, **options) @solutions = @solutions.project(*(operands.first)) @solutions.each(&block) if block_given? @solutions end end # Project end # Operator end; end # SPARQL::Algebra
Version data entries
7 entries across 7 versions & 1 rubygems