class RDF::Query
Public Instance Methods
Equivalence for Queries:
Same Patterns Same Context
@return [Boolean]
# File lib/sparql/algebra/extensions.rb, line 386 def ==(other) # FIXME: this should be graph_name == other.graph_name other.is_a?(RDF::Query) && patterns == other.patterns && graph_name == graph_name end
Binds the pattern to a solution, making it no longer variable if all variables are resolved to bound variables
@param [RDF::Query::Solution] solution @return [self]
# File lib/sparql/algebra/extensions.rb, line 419 def bind(solution) patterns.each {|p| p.bind(solution)} self end
Returns `true` as this is executable.
@return [Boolean] `true`
# File lib/sparql/algebra/extensions.rb, line 480 def executable?; true; end
Return the non-destinguished variables contained within patterns and graph name @return [Array<RDF::Query::Variable>]
# File lib/sparql/algebra/extensions.rb, line 445 def ndvars vars.reject(&:distinguished?) end
Optimize the query, removing lexical shortcuts in URIs
@return [self] @see SPARQL::Algebra::Expression#optimize!
# File lib/sparql/algebra/extensions.rb, line 462 def optimize!(**options) @patterns = @patterns.map do |pattern| components = pattern.to_quad.map do |term| if term.respond_to?(:lexical=) term.dup.instance_eval {@lexical = nil; self} else term end end RDF::Query::Pattern.from(components, **pattern.options) end self.optimize_without_expression!(**options) end
Query
results in a boolean result (e.g., ASK) @return [Boolean]
# File lib/sparql/algebra/extensions.rb, line 426 def query_yields_boolean? false end
Query
results solutions (e.g., SELECT) @return [Boolean]
# File lib/sparql/algebra/extensions.rb, line 438 def query_yields_solutions? true end
Query
results statements (e.g., CONSTRUCT, DESCRIBE, CREATE) @return [Boolean]
# File lib/sparql/algebra/extensions.rb, line 432 def query_yields_statements? false end
Don't do any more rewriting @return [SPARQL::Algebra::Expression] `self`
# File lib/sparql/algebra/extensions.rb, line 394 def rewrite(&block) self end
Transform Query
into an Array
form of an SSE
If Query
has the `as_container` option set, serialize as Quads Otherwise, If Query
is named, serialize as a GroupGraphPattern. Otherise, serialize as a BGP
@return [Array]
# File lib/sparql/algebra/extensions.rb, line 405 def to_sxp_bin if options[:as_container] [:graph, graph_name] + [patterns.map(&:to_sxp_bin)] else res = [:bgp] + patterns.map(&:to_sxp_bin) (graph_name ? [:graph, graph_name, res] : res) end end
Return the variables contained within patterns and graph name @return [Array<RDF::Query::Variable>]
# File lib/sparql/algebra/extensions.rb, line 452 def vars variables.values end