Sha256: 130cd23b3c2355a81a43e1b7c1baf11259508c961d88bee6c4df389f1d243c08
Contents?: true
Size: 1.7 KB
Versions: 1
Compression:
Stored size: 1.7 KB
Contents
module SPARQL; module Algebra class Operator ## # The SPARQL UPDATE `sequence` operator. # # Sequences through each operand # class Sequence < Operator include SPARQL::Algebra::Update NAME = :sequence ## # Basically a JOIN across multiple operands # # @param [RDF::Queryable] queryable # the graph or repository to write # @param [Hash{Symbol => Object}] options # any additional keyword options # @option options [Boolean] debug # Query execution debugging # @yield [solution] # each matching solution # @yieldparam [RDF::Query::Solution] solution # @yieldreturn [void] ignored # @see https://www.w3.org/TR/sparql11-query/#sparqlAlgebra def execute(queryable, **options) debug(options) {"Sequence #{operands.to_sse}"} last = queryable.query(operands.shift, depth: options[:depth].to_i + 1, **options) debug(options) {"(sequence)=>(last) #{last.map(&:to_h).to_sse}"} operands.each do |op| this = queryable.query(op, depth: options[:depth].to_i + 1, **options) debug(options) {"(sequence)=>(this) #{this.map(&:to_h).to_sse}"} last = last.map do |s1| this.map do |s2| s2.merge(s1) if s2.compatible?(s1) end end.flatten.compact debug(options) {"(sequence)=>(next) #{last.map(&:to_h).to_sse}"} end @solutions = RDF::Query::Solutions.new(last) debug(options) {"(sequence)=> #{@solutions.map(&:to_h).to_sse}"} @solutions.each(&block) if block_given? @solutions end end # Sequence 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/sequence.rb |