Class: SPARQL::Algebra::Operator::Describe
- Inherits:
-
Binary
- Object
- SPARQL::Algebra::Operator
- Binary
- 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]
Constants inherited from Binary
Constants inherited from SPARQL::Algebra::Operator
Constants included from Expression
Instance Attribute Summary
Attributes included from Query
Attributes inherited from SPARQL::Algebra::Operator
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
Methods inherited from Binary
Methods inherited from SPARQL::Algebra::Operator
#aggregate?, arity, #base_uri, base_uri, base_uri=, #bind, #boolean, #constant?, #deep_dup, #each_descendant, #eql?, #evaluatable?, evaluate, #executable?, #first_ancestor, for, #initialize, #inspect, #ndvars, #node?, #operand, #optimize, #optimize!, #parent, #parent=, #prefixes, prefixes, prefixes=, #rewrite, #to_binary, to_sparql, #to_sxp, #to_sxp_bin, #validate!, #variable?, #variables, #vars
Methods included from Expression
cast, #constant?, #evaluate, extension, extension?, extensions, for, #invalid?, new, #node?, open, #optimize, #optimize!, parse, register_extension, #to_sxp_bin, #valid?, #validate!, #variable?
Constructor Details
This class inherits a constructor from SPARQL::Algebra::Operator::Binary
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 |