Package rdflib :: Package sparql :: Module graphPattern :: Class GraphPattern
[show private | hide private]
[frames | no frames]

Class GraphPattern


Storage of one Graph Pattern, ie, the pattern tuples and the possible (functional) constraints (filters)
Method Summary
  __init__(self, patterns)
  __add__(self, other)
Adding means concatenating all the patterns and filters arrays
  __iadd__(self, other)
Adding means concatenating all the patterns and filters arrays
  __repr__(self)
  __str__(self)
  addConstraint(self, func)
Add a global filter constraint to the graph pattern.
  addConstraints(self, lst)
Add a list of global filter constraints to the graph pattern.
  addPattern(self, tupl)
Append a tuple to the local patterns.
  addPatterns(self, lst)
Append a list of tuples to the local patterns.
  construct(self, tripleStore, bindings)
Add triples to a tripleStore based on a variable bindings of the patterns stored locally.
  insertPattern(self, tupl)
Insert a tuple to to the start of local patterns.
  insertPatterns(self, lst)
Insert a list of tuples to the start of the local patterns.
Boolean isEmpty(self)
Is the pattern empty?
  _generatePattern(self, tupl)
Append a tuple to the local patterns.

Method Details

__init__(self, patterns=[])
(Constructor)

Parameters:
patterns - an initial list of graph pattern tuples

__add__(self, other)
(Addition operator)

Adding means concatenating all the patterns and filters arrays

__iadd__(self, other)

Adding means concatenating all the patterns and filters arrays

addConstraint(self, func)

Add a global filter constraint to the graph pattern. 'func' must be a method with a single input parameter (a dictionary) returning a boolean. This method is added to previously added methods, ie, all methods must return True to accept a binding.
Parameters:
func - filter function

addConstraints(self, lst)

Add a list of global filter constraints to the graph pattern. Each function in the list must be a method with a single input parameter (a dictionary) returning a boolean. These methods are added to previously added methods, ie, all methods must return True to accept a binding.
Parameters:
lst - list of functions

addPattern(self, tupl)

Append a tuple to the local patterns. Possible type literals are converted to real literals on the fly. Each tuple should be contain either 3 elements (for an RDF Triplet pattern) or four, where the fourth element is a per-pattern constraint (filter). (The general constraint of SPARQL can be optimized by assigning a constraint to a specific pattern; because it stops the graph expansion, its usage might be much more optimal than the the 'global' constraint).
Parameters:
tupl - either a three or four element tuple

addPatterns(self, lst)

Append a list of tuples to the local patterns. Possible type literals are converted to real literals on the fly. Each tuple should be contain either three elements (for an RDF Triplet pattern) or four, where the fourth element is a per-pattern constraint. (The general constraint of SPARQL can be optimized by assigning a constraint to a specific pattern; because it stops the graph expansion, its usage might be much more optimal than the the 'global' constraint).
Parameters:
lst - list consisting of either a three or four element tuples

construct(self, tripleStore, bindings)

Add triples to a tripleStore based on a variable bindings of the patterns stored locally. The triples are patterned by the current Graph Pattern. The method is used to construct a graph after a successful querying.
Parameters:
tripleStore - an (rdflib) Triple Store
bindings - dictionary

insertPattern(self, tupl)

Insert a tuple to to the start of local patterns. Possible type literals are converted to real literals on the fly. Each tuple should be contain either 3 elements (for an RDF Triplet pattern) or four, where the fourth element is a per-pattern constraint (filter). (The general constraint of SPARQL can be optimized by assigning a constraint to a specific pattern; because it stops the graph expansion, its usage might be much more optimal than the the 'global' constraint).

Semantically, the behaviour induced by a graphPattern does not depend on the order of the patterns. However, due to the behaviour of the expansion algorithm, users may control the speed somewhat by adding patterns that would 'cut' the expansion tree soon (ie, patterns that reduce the available triplets significantly). API users may be able to do that, hence this additional method.
Parameters:
tupl - either a three or four element tuple

insertPatterns(self, lst)

Insert a list of tuples to the start of the local patterns. Possible type literals are converted to real literals on the fly. Each tuple should be contain either three elements (for an RDF Triplet pattern) or four, where the fourth element is a per-pattern constraint. (The general constraint of SPARQL can be optimized by assigning a constraint to a specific pattern; because it stops the graph expansion, its usage might be much more optimal than the the 'global' constraint).

Semantically, the behaviour induced by a graphPattern does not depend on the order of the patterns. However, due to the behaviour of the expansion algorithm, users may control the speed somewhat by adding patterns that would 'cut' the expansion tree soon (ie, patterns that reduce the available triplets significantly). API users may be able to do that, hence this additional method.
Parameters:
lst - list consisting of either a three or four element tuples

isEmpty(self)

Is the pattern empty?
Returns:
Boolean

_generatePattern(self, tupl)

Append a tuple to the local patterns. Possible type literals are converted to real literals on the fly. Each tuple should be contain either 3 elements (for an RDF Triplet pattern) or four, where the fourth element is a per-pattern constraint (filter). (The general constraint of SPARQL can be optimized by assigning a constraint to a specific pattern; because it stops the graph expansion, its usage might be much more optimal than the the 'global' constraint).
Parameters:
tupl - either a three or four element tuple

Generated by Epydoc 2.1 on Wed Jun 29 09:50:16 2005 http://epydoc.sf.net