Class: SPARQL::Algebra::Operator::Describe
- Inherits:
-
Binary
- Object
- SPARQL::Algebra::Operator
- Binary
- SPARQL::Algebra::Operator::Describe
- Includes:
- Query
- Defined in:
- vendor/bundler/ruby/3.3.0/bundler/gems/sparql-796d3be4aa08/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
Constants included from RDF::Util::Logger
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, #formulae, #initialize, #inspect, #mergable?, #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?
Methods included from RDF::Util::Logger
#log_debug, #log_depth, #log_error, #log_fatal, #log_info, #log_recover, #log_recovering?, #log_statistics, #log_warn, #logger
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 'vendor/bundler/ruby/3.3.0/bundler/gems/sparql-796d3be4aa08/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 'vendor/bundler/ruby/3.3.0/bundler/gems/sparql-796d3be4aa08/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 'vendor/bundler/ruby/3.3.0/bundler/gems/sparql-796d3be4aa08/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 |