Package rdflib :: Package store :: Package FOPLRelationalModel :: Module BinaryRelationPartition
[show private | hide private]
[frames | no frames]

Module rdflib.store.FOPLRelationalModel.BinaryRelationPartition

The set of classes used to model the 3 'partitions' for N3 assertions. There is a top level class which implements operations common to all partitions as well as a class for each partition. These classes are meant to allow the underlying SQL schema to be completely configurable as well as to automate the generation of SQL queries for adding,updating,removing,resolving triples from the partitions. These classes work in tandem with the RelationHashes to automate all (or most) of the SQL processing associated with this FOPL Relational Model

NOTE: The use of foreign keys (which - unfortunately - bumps the minimum MySQL version to 5.0) allows for the efficient removal of all statements about a particular resource using cascade on delete (currently not used)

see: http://dev.mysql.com/doc/refman/5.0/en/ansi-diff-foreign-keys.html
Classes
AssociativeBox The partition associated with assertions of class membership (formally known - in Description Logics - as an Associative Box) This partition is for all assertions where the property is rdf:type see: http://en.wikipedia.org/wiki/Description_Logic#Modelling_in_Description_Logics
BinaryRelationPartition The common ancestor of the three partitions for assertions.
NamedBinaryRelations Partition associated with assertions where the predicate isn't rdf:type and the object isn't a literal
NamedLiteralProperties The partition associated with assertions where the object is a Literal.

Function Summary
  BinaryRelationPartitionCoverage((subject, predicate, object_, context), BRPs)
This function takes a quad pattern (where any term is one of: URIRef,BNode,Literal,None,or REGEXTerm) ,a list of 3 live partitions and returns a list of only those partitions that need to be searched in order to resolve the pattern.
  PatternResolution(quad, cursor, BRPs, orderByTriple, fetchall, fetchContexts)
This function implements query pattern resolution against a list of partition objects and 3 parameters specifying whether to sort the result set (in order to group identical triples by the contexts in which they appear), whether to fetch the entire result set or one at a time, and whether to fetch the matching contexts only or the assertions.

Variable Summary
NoneType Any = None                                                                  
list ANY_TERM = ['U', 'B', 'F', 'V', 'L']
list ASSOCIATIVE_BOX_CLASSES = ['U']
dict BRPQueryDecisionMap = {'U_RNTR': (<class 'rdflib.store.F...
list CLASS_TERMS = ['U', 'B', 'V']
str CONTEXT_COLUMN = 'context'
list CONTEXT_TERMS = ['U', 'B', 'F']
str CREATE_BRP_TABLE = '\nCREATE TABLE %s (\n    %s\n) ENGIN...
str CREATE_RESULT_TABLE = "\nCREATE TEMPORARY TABLE result (...
str CROSS_BRP_QUERY_SQL = 'SELECT DISTINCT %s FROM %s %s WHE...
str CROSS_BRP_RESULT_QUERY_SQL = 'SELECT * FROM result ORDER...
str DROP_RESULT_TABLE_SQL = 'DROP result'
list GROUND_IDENTIFIERS = ['U']
list IDENTIFIER_TERMS = ['U', 'B']
str LOOKUP_INTERSECTION_SQL = 'INNER JOIN %s %s ON (%s)'
str LOOKUP_UNION_SQL = 'LEFT JOIN %s %s ON (%s)'
list NAMED_BINARY_RELATION_OBJECTS = ['U', 'B', 'L']
list NAMED_BINARY_RELATION_PREDICATES = ['U']
list NAMED_LITERAL_OBJECTS = ['L']
list NAMED_LITERAL_PREDICATES = ['U']
list NON_LITERALS = ['U', 'B', 'F', 'V']
list PREDICATE_NAMES = ['U', 'V']

Function Details

BinaryRelationPartitionCoverage((subject, predicate, object_, context), BRPs)

This function takes a quad pattern (where any term is one of: URIRef,BNode,Literal,None,or REGEXTerm) ,a list of 3 live partitions and returns a list of only those partitions that need to be searched in order to resolve the pattern. This function relies on the BRPQueryDecisionMap dictionary to determine which partitions to use. Note that the dictionary as it is currently constituted requres that REGEXTerms in the object slot require that *both* the binary relation partition and the literal properties partitions are searched when this search could be limited to the literal properties only (for more efficient REGEX evaluation of literal values). Given the nature of the REGEX function in SPARQL and the way Versa matches by REGEX, this seperation couldn't be done

PatternResolution(quad, cursor, BRPs, orderByTriple=True, fetchall=True, fetchContexts=False)

This function implements query pattern resolution against a list of partition objects and 3 parameters specifying whether to sort the result set (in order to group identical triples by the contexts in which they appear), whether to fetch the entire result set or one at a time, and whether to fetch the matching contexts only or the assertions. This function uses BinaryRelationPartitionCoverage to whittle out the partitions that don't need to be searched, generateHashIntersections / generateWhereClause to generate the SQL query and the parameter fill-ins and creates a single UNION query against the relevant partitions.

Note the use of UNION syntax requires that the literal properties partition is first (since it uses the first select to determine the column types for the resulting rows from the subsequent SELECT queries)

see: http://dev.mysql.com/doc/refman/5.0/en/union.html

Variable Details

Any

Type:
NoneType
Value:
None                                                                  

ANY_TERM

Type:
list
Value:
['U', 'B', 'F', 'V', 'L']                                              

ASSOCIATIVE_BOX_CLASSES

Type:
list
Value:
['U']                                                                  

BRPQueryDecisionMap

Type:
dict
Value:
{'RTL': <class 'rdflib.store.FOPLRelationalModel.BinaryRelationPartiti\
on.NamedLiteralProperties'>,
 'RTR': (<class 'rdflib.store.FOPLRelationalModel.BinaryRelationPartit\
ion.NamedLiteralProperties'>,
         <class 'rdflib.store.FOPLRelationalModel.BinaryRelationPartit\
ion.AssociativeBox'>,
         <class 'rdflib.store.FOPLRelationalModel.BinaryRelationPartit\
ion.NamedBinaryRelations'>),
...                                                                    

CLASS_TERMS

Type:
list
Value:
['U', 'B', 'V']                                                        

CONTEXT_COLUMN

Type:
str
Value:
'context'                                                              

CONTEXT_TERMS

Type:
list
Value:
['U', 'B', 'F']                                                        

CREATE_BRP_TABLE

Type:
str
Value:
'''
CREATE TABLE %s (
    %s
) ENGINE=InnoDB'''                                                     

CREATE_RESULT_TABLE

Type:
str
Value:
"""
CREATE TEMPORARY TABLE result (
    subject text NOT NULL,
    subjectTerm enum('F','V','U','B','L') NOT NULL,
    predicate text NOT NULL,
    predicateTerm enum('F','V','U','B','L') NOT NULL,
    object text NOT NULL,
    objectTerm enum('F','V','U','B','L') NOT NULL,
...                                                                    

CROSS_BRP_QUERY_SQL

Type:
str
Value:
'SELECT DISTINCT %s FROM %s %s WHERE '                                 

CROSS_BRP_RESULT_QUERY_SQL

Type:
str
Value:
'SELECT * FROM result ORDER BY context'                                

DROP_RESULT_TABLE_SQL

Type:
str
Value:
'DROP result'                                                          

GROUND_IDENTIFIERS

Type:
list
Value:
['U']                                                                  

IDENTIFIER_TERMS

Type:
list
Value:
['U', 'B']                                                             

LOOKUP_INTERSECTION_SQL

Type:
str
Value:
'INNER JOIN %s %s ON (%s)'                                             

LOOKUP_UNION_SQL

Type:
str
Value:
'LEFT JOIN %s %s ON (%s)'                                              

NAMED_BINARY_RELATION_OBJECTS

Type:
list
Value:
['U', 'B', 'L']                                                        

NAMED_BINARY_RELATION_PREDICATES

Type:
list
Value:
['U']                                                                  

NAMED_LITERAL_OBJECTS

Type:
list
Value:
['L']                                                                  

NAMED_LITERAL_PREDICATES

Type:
list
Value:
['U']                                                                  

NON_LITERALS

Type:
list
Value:
['U', 'B', 'F', 'V']                                                   

PREDICATE_NAMES

Type:
list
Value:
['U', 'V']                                                             

Generated by Epydoc 2.1 on Wed Apr 4 16:05:47 2007 http://epydoc.sf.net