Class: SPARQL::Algebra::Operator::Describe

Inherits:
Binary show all
Includes:
Query
Defined in:
vendor/bundler/ruby/2.4.0/bundler/gems/sparql-e0a915196943/lib/sparql/algebra/operator/describe.rb

Overview

The SPARQL GraphPattern describe operator.

Generages a graph across specified terms using RDF::Queryable#concise_bounded_description.

Examples:

(prefix ((exOrg: <http://org.example.com/employees#>))
  (describe (?x)
    (bgp (triple ?x exOrg:employeeId "1234"))))

See Also:

Constant Summary

NAME =
[:describe]

Constants inherited from Binary

Binary::ARITY

Constants inherited from SPARQL::Algebra::Operator

ARITY, IsURI, URI

Instance Attribute Summary

Attributes included from Query

#solutions

Attributes inherited from SPARQL::Algebra::Operator

#operands

Instance Method Summary collapse

Methods included from Query

#each_solution, #empty?, #failed?, #graph_name=, #matched?, #query_yields_boolean?, #query_yields_solutions?, #unshift, #variables

Methods inherited from Binary

#initialize

Methods inherited from SPARQL::Algebra::Operator

#aggregate?, arity, base_uri, #base_uri, base_uri=, #boolean, #constant?, #each_descendant, #eql?, #evaluatable?, evaluate, #executable?, #first_ancestor, for, #initialize, #inspect, #ndvars, #node?, #operand, #parent, #parent=, #prefixes, prefixes, prefixes=, #rewrite, #to_binary, #to_sxp, #to_sxp_bin, #validate!, #variable?, #vars

Methods included from Expression

cast, #constant?, #evaluate, extension, extensions, for, #invalid?, new, #node?, open, 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.

Examples:

(describe (<http://example/>))
(prefix ((foaf: <http://xmlns.com/foaf/0.1/>))
  (describe (?x)
    (bgp (triple ?x foaf:mbox <mailto:alice@org>))))

Parameters:

  • queryable (RDF::Queryable)

    the graph or repository to query

  • options (Hash{Symbol => Object}) (defaults to: {})

    any additional keyword options

Yields:

  • (statement)

    each matching statement

Yield Parameters:

Yield Returns:

  • (void)

    ignored

Returns:

  • (RDF::Graph)

    containing the constructed triples

See Also:



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'vendor/bundler/ruby/2.4.0/bundler/gems/sparql-e0a915196943/lib/sparql/algebra/operator/describe.rb', line 43

def execute(queryable, options = {}, &block)
  debug(options) {"Describe #{operands.first}, #{options.inspect}"}

  # Describe any constand URIs
  to_describe = operands.first.select {|t| t.uri?}
  
  to_describe.each {|t| debug(options) {"=> describe #{t}"}}

  queryable.query(operands.last) do |solution|
    solution.each_variable do |v|
      if operands.first.any? {|bound| v.eql?(bound)}
        debug(options) {"(describe)=> #{v}"}
        to_describe << v.value
      end
    end
  end

  # Return Concise Bounded Description
  queryable.concise_bounded_description(*to_describe.uniq, &block)
end

#optimizeUnion, RDF::Query

Returns an optimized version of this query.

Return optimized query

Returns:



70
71
72
# File 'vendor/bundler/ruby/2.4.0/bundler/gems/sparql-e0a915196943/lib/sparql/algebra/operator/describe.rb', line 70

def optimize
  operands = operands.map(&:optimize)
end

#query_yields_statements?Boolean

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

Returns:

  • (Boolean)


76
77
78
# File 'vendor/bundler/ruby/2.4.0/bundler/gems/sparql-e0a915196943/lib/sparql/algebra/operator/describe.rb', line 76

def query_yields_statements?
  true
end