class RDF::Query

Public Instance Methods

==(other) click to toggle source

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
bind(solution) click to toggle source

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
executable?() click to toggle source

Returns `true` as this is executable.

@return [Boolean] `true`

# File lib/sparql/algebra/extensions.rb, line 480
def executable?; true; end
ndvars() click to toggle source

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!(**options) click to toggle source

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
Also aliased as: optimize_without_expression!
optimize_without_expression!(**options)
Alias for: optimize!
query_yields_boolean?() click to toggle source

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_yields_solutions?() click to toggle source

Query results solutions (e.g., SELECT) @return [Boolean]

# File lib/sparql/algebra/extensions.rb, line 438
def query_yields_solutions?
  true
end
query_yields_statements?() click to toggle source

Query results statements (e.g., CONSTRUCT, DESCRIBE, CREATE) @return [Boolean]

# File lib/sparql/algebra/extensions.rb, line 432
def query_yields_statements?
  false
end
rewrite(&block) click to toggle source

Don't do any more rewriting @return [SPARQL::Algebra::Expression] `self`

# File lib/sparql/algebra/extensions.rb, line 394
def rewrite(&block)
  self
end
to_sxp_bin() click to toggle source

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
vars() click to toggle source

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