Class: SPARQL::Algebra::Operator::Dataset
- Inherits:
-
Binary
- Object
- SPARQL::Algebra::Operator
- Binary
- SPARQL::Algebra::Operator::Dataset
- Includes:
- Query
- Defined in:
- lib/sparql/algebra/operator/dataset.rb
Overview
The SPARQL GraphPattern dataset
operator.
Instintiated with two operands, the first being an array of data source URIs,
either bare, indicating a default dataset, or expressed as an array [:named,
Constant Summary collapse
- NAME =
[:dataset]
Constants inherited from Binary
Constants inherited from SPARQL::Algebra::Operator
Instance Attribute Summary
Attributes included from Query
Attributes inherited from SPARQL::Algebra::Operator
Instance Method Summary collapse
-
#execute(queryable, options = {}) ⇒ RDF::Query::Solutions
Executes this query on the given
queryable
graph or repository. -
#optimize ⇒ Union, RDF::Query
Returns an optimized version of this query.
Methods included from Query
#context=, #each_solution, #failed?, #matched?, #unshift, #variables
Methods inherited from Binary
Methods inherited from SPARQL::Algebra::Operator
arity, base_uri, #base_uri, base_uri=, #boolean, #constant?, #eql?, #evaluatable?, evaluate, #executable?, for, #initialize, #inspect, #operand, prefixes, #prefixes, prefixes=, #to_sse, #to_sxp, #variable?
Methods included from Evaluatable
Methods included from Expression
cast, #constant?, #evaluate, for, new, open, parse, #to_sse, #variable?
Constructor Details
This class inherits a constructor from SPARQL::Algebra::Operator::Binary
Instance Method Details
#execute(queryable, options = {}) ⇒ RDF::Query::Solutions
Executes this query on the given queryable
graph or repository.
Reads specified data sources into queryable. Named data sources
are added using a context of the data source URI.
Datasets are specified in operand(1), which is an array of default or named graph URIs.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/sparql/algebra/operator/dataset.rb', line 35 def execute(queryable, = {}) debug("Dataset", ) operand(0).each do |ds| load_opts = {} case ds when Array uri = if self.base_uri u = self.base_uri.join(ds.last) u.lexical = "<#{ds.last}>" unless u.to_s == ds.last.to_s u else ds.last end uri = self.base_uri ? self.base_uri.join(ds.last) : ds.last uri.lexical = ds.last load_opts[:context] = uri debug("=> read named data source #{uri}", ) else uri = self.base_uri ? self.base_uri.join(ds) : ds debug("=> read default data source #{uri}", ) end queryable.load(uri.to_s, load_opts) end @solutions = operands.last.execute(queryable, .merge(:depth => [:depth].to_i + 1)) end |
#optimize ⇒ Union, RDF::Query
Returns an optimized version of this query.
If optimize operands, and if the first two operands are both Queries, replace with the unique sum of the query elements
69 70 71 |
# File 'lib/sparql/algebra/operator/dataset.rb', line 69 def optimize operands.last.optimize end |