Class: SPARQL::Algebra::Operator::Describe
- Includes:
- Query
- Defined in:
- lib/sparql/algebra/operator/describe.rb
Overview
The SPARQL GraphPattern describe operator.
Generages a graph across specified terms using RDF::Queryable#concise_bounded_description.
[11] DescribeQuery ::= 'DESCRIBE' ( VarOrIri+ | '' ) DatasetClause WhereClause? SolutionModifier ValuesClause
Constant Summary collapse
- NAME =
[:describe]
Instance Attribute Summary
Attributes included from Query
Instance Method Summary collapse
-
#execute(queryable, **options) {|statement| ... } ⇒ RDF::Graph
Executes this query on the given RDF::Queryable object.
-
#query_yields_statements? ⇒ Boolean
Query results statements (e.g., CONSTRUCT, DESCRIBE, CREATE).
-
#to_sparql(**options) ⇒ String
Returns a partial SPARQL grammar for this term.
Methods included from Query
#each_solution, #empty?, #failed?, #graph_name=, #matched?, #query_yields_boolean?, #query_yields_solutions?, #unshift, #variables
Instance Method Details
#execute(queryable, **options) {|statement| ... } ⇒ RDF::Graph
Executes this query on the given RDF::Queryable object. Generates a graph containing the Concise Bounded Description variables and URIs listed in the first operand.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/sparql/algebra/operator/describe.rb', line 49 def execute(queryable, **, &block) debug() {"Describe #{operands.first}, #{.inspect}"} # Describe any constand URIs to_describe = operands.first.select {|t| t.uri?} to_describe.each {|t| debug() {"=> describe #{t}"}} queryable.query(operands.last) do |solution| solution.each_variable do |v| if operands.first.any? {|bound| v.eql?(bound)} debug() {"(describe)=> #{v}"} to_describe << v.value end end end # Return Concise Bounded Description queryable.concise_bounded_description(*to_describe.uniq, &block) end |
#query_yields_statements? ⇒ Boolean
Query results statements (e.g., CONSTRUCT, DESCRIBE, CREATE)
72 73 74 |
# File 'lib/sparql/algebra/operator/describe.rb', line 72 def query_yields_statements? true end |
#to_sparql(**options) ⇒ String
Returns a partial SPARQL grammar for this term.
81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/sparql/algebra/operator/describe.rb', line 81 def to_sparql(**) str = "DESCRIBE " str << if operands[0].empty? "*" else operands[0].map { |e| e.to_sparql(**) }.join(" ") end str << "\n" str << operands[1].to_sparql(top_level: true, project: nil, **) end |