Class: RDF::Query

Inherits:
Object show all
Defined in:
vendor/bundler/ruby/2.5.0/bundler/gems/rdf-spec-ab2aa521dd46/lib/rdf/spec/inspects.rb,
vendor/bundler/ruby/2.5.0/bundler/gems/sparql-7b34b4cf091a/lib/sparql/algebra/extensions.rb

Direct Known Subclasses

SPARQL::Client::Query

Defined Under Namespace

Classes: Pattern, Solutions, Variable

Instance Method Summary collapse

Instance Method Details

#==(other) ⇒ Boolean

Equivalence for Queries: Same Patterns Same Context

Returns:

  • (Boolean)


281
282
283
284
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/sparql-7b34b4cf091a/lib/sparql/algebra/extensions.rb', line 281

def ==(other)
  # FIXME: this should be graph_name == other.graph_name
  other.is_a?(RDF::Query) && patterns == other.patterns && graph_name == graph_name
end

#executable?Boolean

Returns true if this is executable (i.e., contains a graph patterns), false otherwise.

Returns:

  • (Boolean)

    true or false



346
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/sparql-7b34b4cf091a/lib/sparql/algebra/extensions.rb', line 346

def executable?; true; end

#inspectObject



29
30
31
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/rdf-spec-ab2aa521dd46/lib/rdf/spec/inspects.rb', line 29

def inspect
  "RDF::Query(#{graph_name ? graph_name.to_sxp : 'nil'})#{patterns.inspect}"
end

#ndvarsArray<RDF::Query::Variable>

Return the non-destinguished variables contained within patterns and graph name



330
331
332
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/sparql-7b34b4cf091a/lib/sparql/algebra/extensions.rb', line 330

def ndvars
  vars.reject(&:distinguished?)
end

#query_yields_boolean?Boolean

Query results in a boolean result (e.g., ASK)

Returns:

  • (Boolean)


311
312
313
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/sparql-7b34b4cf091a/lib/sparql/algebra/extensions.rb', line 311

def query_yields_boolean?
  false
end

#query_yields_solutions?Boolean

Query results solutions (e.g., SELECT)

Returns:

  • (Boolean)


323
324
325
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/sparql-7b34b4cf091a/lib/sparql/algebra/extensions.rb', line 323

def query_yields_solutions?
  true
end

#query_yields_statements?Boolean

Query results statements (e.g., CONSTRUCT, DESCRIBE, CREATE)

Returns:

  • (Boolean)


317
318
319
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/sparql-7b34b4cf091a/lib/sparql/algebra/extensions.rb', line 317

def query_yields_statements?
  false
end

#rewrite(&block) ⇒ SPARQL::Algebra::Expression

Don't do any more rewriting

Returns:



289
290
291
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/sparql-7b34b4cf091a/lib/sparql/algebra/extensions.rb', line 289

def rewrite(&block)
  self
end

#to_sxp_binArray

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

Returns:



300
301
302
303
304
305
306
307
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/sparql-7b34b4cf091a/lib/sparql/algebra/extensions.rb', line 300

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

#varsArray<RDF::Query::Variable>

Return the variables contained within patterns and graph name



337
338
339
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/sparql-7b34b4cf091a/lib/sparql/algebra/extensions.rb', line 337

def vars
  variables.values
end