Module: SPARQL::Algebra::Query Abstract
- Included in:
- Operator::Ask, Operator::Base, Operator::Construct, Operator::Dataset, Operator::Describe, Operator::Distinct, Operator::Filter, Operator::Join, Operator::LeftJoin, Operator::Order, Operator::Prefix, Operator::Project, Operator::Reduced, Operator::Slice, Operator::Union
- Defined in:
- lib/sparql/algebra/query.rb
Overview
A SPARQL algebra query, may be duck-typed as RDF::Query.
Mixin with SPARQL::Algebra::Operator to provide query-like operations on graphs and filters
Instance Attribute Summary (collapse)
-
- (RDF::Query::Solutions) solutions
readonly
The solution sequence for this query.
Instance Method Summary (collapse)
-
- (RDF::URI, RDF::Query::Variable) context=(value)
Add context to sub-items, unless they already have a context.
-
- (Enumerator) each_solution {|solution| ... }
(also: #each)
Enumerates over each matching query solution.
-
- (RDF::Query::Solutions) execute(queryable, options = {})
Executes this query on the given
queryablegraph or repository. -
- (Boolean) failed?
Returns
trueif this query did not match when last executed. -
- (Boolean) matched?
Returns
trueif this query matched when last executed. -
- unshift(query)
Prepends an operator.
-
- (Hash{Symbol => RDF::Query::Variable}) variables
The variables used in this query.
Instance Attribute Details
- (RDF::Query::Solutions) solutions (readonly)
The solution sequence for this query.
32 33 34 |
# File 'lib/sparql/algebra/query.rb', line 32 def solutions @solutions end |
Instance Method Details
- (RDF::URI, RDF::Query::Variable) context=(value)
Add context to sub-items, unless they already have a context
57 58 59 60 61 62 |
# File 'lib/sparql/algebra/query.rb', line 57 def context=(value) operands.each do |operand| operand.context = value if operand.respond_to?(:context) && operand.context != false end value end |
- (Enumerator) each_solution {|solution| ... } Also known as: each
Enumerates over each matching query solution.
94 95 96 |
# File 'lib/sparql/algebra/query.rb', line 94 def each_solution(&block) solutions.each(&block) end |
- (RDF::Query::Solutions) execute(queryable, options = {})
Executes this query on the given queryable graph or repository.
50 51 52 |
# File 'lib/sparql/algebra/query.rb', line 50 def execute(queryable, = {}) raise NotImplementedError, "#{self.class}#execute(#{queryable})" end |
- (Boolean) failed?
Returns true if this query did not match when last executed.
When the solution sequence is empty, this method can be used to determine whether the query failed to match or not.
72 73 74 |
# File 'lib/sparql/algebra/query.rb', line 72 def failed? solutions.empty? end |
- (Boolean) matched?
Returns true if this query matched when last executed.
When the solution sequence is empty, this method can be used to determine whether the query matched successfully or not.
84 85 86 |
# File 'lib/sparql/algebra/query.rb', line 84 def matched? !failed? end |
- unshift(query)
This method returns an undefined value.
Prepends an operator.
15 16 17 18 |
# File 'lib/sparql/algebra/query.rb', line 15 def unshift(query) @operands.unshift(query) self end |
- (Hash{Symbol => RDF::Query::Variable}) variables
The variables used in this query.
24 25 26 |
# File 'lib/sparql/algebra/query.rb', line 24 def variables operands.inject({}) {|hash, o| o.executable? ? hash.merge!(o.variables) : hash} end |