Class: SPARQL::Algebra::Operator::Slice
- Includes:
- Query
- Defined in:
- lib/sparql/algebra/operator/slice.rb
Overview
The SPARQL GraphPattern slice operator.
[25] LimitOffsetClauses ::= LimitClause OffsetClause? | OffsetClause LimitClause?
Constant Summary collapse
- NAME =
[:slice]
Instance Attribute Summary
Attributes included from Query
Instance Method Summary collapse
-
#execute(queryable, **options) {|solution| ... } ⇒ RDF::Query::Solutions
Executes this query on the given
queryablegraph or repository. -
#to_sparql(**options) ⇒ String
Extracts OFFSET and LIMIT.
Methods included from Query
#each_solution, #empty?, #failed?, #graph_name=, #matched?, #query_yields_boolean?, #query_yields_solutions?, #query_yields_statements?, #unshift, #variables
Instance Method Details
#execute(queryable, **options) {|solution| ... } ⇒ RDF::Query::Solutions
Executes this query on the given queryable graph or repository.
Returns a subset of the solutions resulting from executing
the third operand, an RDF::Queryable object by indexing in to the
result set by the amount specified in the first operand and limiting
the total number of solutions returned by the amount specified in the
second operand.
If either the first or second operands are :_, they are not considered.
57 58 59 60 61 62 63 64 65 |
# File 'lib/sparql/algebra/operator/slice.rb', line 57 def execute(queryable, **, &block) offset = operands[0] == :_ ? 0 : operands[0].to_i limit = operands[1] == :_ ? -1 : operands[1].to_i @solutions = operands.last. execute(queryable, **.merge(depth: [:depth].to_i + 1)) @solutions.offset(operands[0]) unless operands[0] == :_ @solutions.limit(operands[1]) unless operands[1] == :_ @solutions.each(&block) if block_given? @solutions end |
#to_sparql(**options) ⇒ String
Extracts OFFSET and LIMIT.
72 73 74 75 76 |
# File 'lib/sparql/algebra/operator/slice.rb', line 72 def to_sparql(**) offset = operands[0].to_i unless operands[0] == :_ limit = operands[1].to_i unless operands[1] == :_ operands.last.to_sparql(offset: offset, limit: limit, **) end |