com.hp.hpl.mesa.rdf.jena.rdb
Interface IRDBDriver

All Known Implementing Classes:
DriverGenericGeneric, DriverGenericGenericProc, DriverGenericMMGeneric, DriverGenericMMGenericProc, DriverGenericMMHash, DriverGenericProc, DriverInterbaseHash, DriverInterbaseMMHash, DriverOracleMMGeneric

public interface IRDBDriver

Generic database interface used for implementing RDF Stores. Different database table layouts and different SQL dialects should all be supportable via this generic interface. Each driver instance can support multiple stores so long as "supportsMultipleModels" is true.

Version:
$Revision: 1.9 $ on $Date: 2002/09/04 08:47:38 $
Author:
Dave Reynolds

Method Summary
 void addStatement(Statement s, ModelRDB m)
          Register a statement in the database.
 IDBID allocateModelID(java.lang.String modelName)
          Allocate a new databaseID for a new model in the same database.
 void attachStore(StoreRDB store)
          Register a store as a user of this driver.
 void cleanDB()
          Remove all RDF information from a database.
 void clear(ModelRDB model)
          Remove all the statements from the given model.
 void close()
          Close the databse connection
 IConstraints createConstraints(ModelRDB model)
          Create a constraint object appropriate for this type of database layout
 void deleteModel(java.lang.String modelName)
          Delete the named from from within the database.
 boolean deleteStatement(IDBID statementID, ModelRDB m)
          Delete the statement in the model corresponding to the given statement ID
 boolean deleteStatement(Resource subject, Property predicate, RDFNode object, ModelRDB m)
          Delete the statements in the model which match the given subject, predicate object.
 void detachStore(StoreRDB store)
          Notify that a store is no longer using this driver.
 void formatDB()
          Initialise a database ready to store RDF tables.
 StatementImplRDB getBareStatementResource(IDBID id, ModelRDB m)
          Fetch a reiefied statement resource just knowing its resource rdb-id.
 java.sql.Connection getConnection()
          Return the jdbc connection to the database, opening it if necessary
 Literal getLiteral(IDBID id)
          Fetch a literal just knowing its literal rdb-id
 Literal getLiteralFromCache(IDBID id)
          Fetch a literal from the cache just knowing its literal rdb-id.
 IDBID getLiteralID(Literal l)
          Return the database ID for the literal
 IDBID getModelID(java.lang.String modelName)
          Return the databaseID for an existing named model within the database.
 java.lang.String getNamespace(IDBID nsid)
          Return the namespace string corresponding to a given namespace id
 Property getProperty(IDBID id, ModelRDB m)
          Fetch a property just knowing its resource rdb-id.
 Property getProperty(java.lang.String uri, ModelRDB m)
          Fetch a property, knowing its uri.
 Property getPropertyFromCache(IDBID id, ModelRDB m)
          Fetch a property from the cache just knowing its resource rdb-id.
 Resource getResource(IDBID id, ModelRDB m)
          Fetch a resource just knowing its resource rdb-id.
 Resource getResource(java.lang.String uri, ModelRDB m)
          Fetch a resource, knowing its uri.
 Resource getResourceFromCache(IDBID id, ModelRDB m)
          Fetch a resource from the cache just knowing its resource rdb-id.
 IDBID getResourceID(Resource resource)
          Lookup the unique ID for a resource.
 SQLCache getSQLCache()
          Return the SQLCache used for low level database commands.
 void hintPropertyTable(Property p)
          Hint to the store that the given property could be stored as an attribute table.
 boolean isDBFormatOK()
          Check that the database has a legal set of RDF tables.
 boolean isStatementPresent(Resource subject, Property predicate, RDFNode object, ModelRDB m)
          Check if a statement is in the database.
 java.util.Iterator listModels()
          List the names of all models in this database
 ResultSetIterator listNamespaces(ModelRDB m)
          List all namespaces referenced in the model
 ResultSetIterator listReifiedStatements(ModelRDB m)
          Return an iterator over all statements which are have been added as reified statements.
 ResultSetIterator listStatements(IConstraints constraints, ModelRDB m)
          List all the statements in the given moddel which make the given set of constraints (a constraint set can be obtained using createConstraints(com.hp.hpl.mesa.rdf.jena.rdb.ModelRDB)).
 ResultSetIterator listStatements(Resource subject, Property predicate, RDFNode object, ModelRDB m)
          List all the statements in the model which match the given subject, predicate object - each of which can be null (meaning wildcard).
 ResultSetIterator listSubjects(ModelRDB m)
          List all the subject resources in the model
 void loadProperties(java.util.Properties props)
          Load a set of configuration parameters into the driver.
 Property makeProperty(IDBID id, java.lang.String localname, IDBID nsid, ModelRDB m)
          Re-create a property from its local name and namespace identifier
 Resource makeResource(IDBID id, java.lang.String localname, IDBID nsidw, ModelRDB m)
          Re-create a resource from its local name and namespace identifier
 Resource makeResource(IDBID id, java.lang.String localname, IDBID nsid, ModelRDB m, IDBID stmtID)
          Re-create a resource from its local name and namespace identifier.
 void preloadCaches(ModelRDB m)
          Preload the resource and literal caches with all data in the DB.
 void setCacheLimits(int literalLimit, int resourceLimit)
          Set cache limits for caching resources and literals.
 void setConnection(IDBConnection dbcon)
          Link an existing instance of the driver to a specific jdbc connection
 boolean supportsJenaReification()
          Returns true if the database layout supports implicit reification of statements (i.e.
 boolean supportsMultipleModels()
          Returns true if the database layout supports multiple RDF models in the same database.
 IDBID wrapDBID(java.lang.Object id)
          Convert the raw SQL object used to store a database identifier into a java object which meets the IDBID interface
 

Method Detail

setConnection

public void setConnection(IDBConnection dbcon)
                   throws RDFRDBException
Link an existing instance of the driver to a specific jdbc connection

RDFRDBException

getConnection

public java.sql.Connection getConnection()
                                  throws RDFRDBException
Return the jdbc connection to the database, opening it if necessary

RDFRDBException

close

public void close()
           throws RDFRDBException
Close the databse connection

Throws:
RDFRDBException - if there is an access problem

isDBFormatOK

public boolean isDBFormatOK()
                     throws RDFRDBException
Check that the database has a legal set of RDF tables.

Returns:
true if the database seems to be legally formated.
Throws:
RDFRDBException - if the is a problem opening the connection or an internal SQL error.

formatDB

public void formatDB()
              throws RDFRDBException
Initialise a database ready to store RDF tables. Currently the table format depends on the RDBSpec type. In future it may become an explicit part of operations like this.

Throws:
RDFRDBException - if the is a problem opening the connection or an internal SQL error.

cleanDB

public void cleanDB()
Remove all RDF information from a database.


allocateModelID

public IDBID allocateModelID(java.lang.String modelName)
                      throws RDFRDBException
Allocate a new databaseID for a new model in the same database. Throws RDFRDBException if the driver does not support multiple models per db.

RDFRDBException

getModelID

public IDBID getModelID(java.lang.String modelName)
                 throws RDFRDBException
Return the databaseID for an existing named model within the database. Throws RDFRDBException if the driver does not support multiple models per db.

RDFRDBException

deleteModel

public void deleteModel(java.lang.String modelName)
                 throws RDFRDBException
Delete the named from from within the database. This will remove any statements associated with the model and remove the model from the table of known models. Throws RDFRDBException if the driver does not support multiple models per db.

RDFRDBException

listModels

public java.util.Iterator listModels()
                              throws RDFRDBException
List the names of all models in this database

RDFRDBException

loadProperties

public void loadProperties(java.util.Properties props)
Load a set of configuration parameters into the driver.


setCacheLimits

public void setCacheLimits(int literalLimit,
                           int resourceLimit)
Set cache limits for caching resources and literals. In each case a limit of 0 indicates no caching and a limit of -1 indicates unlimited caching.

Parameters:
literalLimit - limit on number of literals to cache

preloadCaches

public void preloadCaches(ModelRDB m)
                   throws RDFException
Preload the resource and literal caches with all data in the DB. Used for higher performance bulk loading in situations where the DB is just used for persistance, not for volume scaling.

RDFException

getResourceFromCache

public Resource getResourceFromCache(IDBID id,
                                     ModelRDB m)
                              throws RDFException
Fetch a resource from the cache just knowing its resource rdb-id. If the resource is not cached, does not attempt to load it from the database.

RDFException

getPropertyFromCache

public Property getPropertyFromCache(IDBID id,
                                     ModelRDB m)
                              throws RDFException
Fetch a property from the cache just knowing its resource rdb-id. If the resource is not cached, does not attempt to load it from the database.

RDFException

getLiteralFromCache

public Literal getLiteralFromCache(IDBID id)
Fetch a literal from the cache just knowing its literal rdb-id. If it is not in the cache, do not attempt to retrieve it from the database.


makeProperty

public Property makeProperty(IDBID id,
                             java.lang.String localname,
                             IDBID nsid,
                             ModelRDB m)
                      throws RDFException
Re-create a property from its local name and namespace identifier

RDFException

attachStore

public void attachStore(StoreRDB store)
Register a store as a user of this driver. One driver can support multiple store instances.


detachStore

public void detachStore(StoreRDB store)
Notify that a store is no longer using this driver.


addStatement

public void addStatement(Statement s,
                         ModelRDB m)
                  throws RDFException
Register a statement in the database.

RDFException

deleteStatement

public boolean deleteStatement(Resource subject,
                               Property predicate,
                               RDFNode object,
                               ModelRDB m)
                        throws RDFException
Delete the statements in the model which match the given subject, predicate object.

Returns:
true if the statement was successfully deleted
RDFException

deleteStatement

public boolean deleteStatement(IDBID statementID,
                               ModelRDB m)
                        throws RDFException
Delete the statement in the model corresponding to the given statement ID

Returns:
true if the statement was successfully deleted
RDFException

listSubjects

public ResultSetIterator listSubjects(ModelRDB m)
                               throws RDFRDBException
List all the subject resources in the model

Returns:
iterator over Resource objects
RDFRDBException

listNamespaces

public ResultSetIterator listNamespaces(ModelRDB m)
                                 throws RDFRDBException
List all namespaces referenced in the model

Returns:
iterator over Strings
RDFRDBException

listStatements

public ResultSetIterator listStatements(Resource subject,
                                        Property predicate,
                                        RDFNode object,
                                        ModelRDB m)
                                 throws RDFException
List all the statements in the model which match the given subject, predicate object - each of which can be null (meaning wildcard).

RDFException

isStatementPresent

public boolean isStatementPresent(Resource subject,
                                  Property predicate,
                                  RDFNode object,
                                  ModelRDB m)
                           throws RDFException
Check if a statement is in the database.

RDFException

listStatements

public ResultSetIterator listStatements(IConstraints constraints,
                                        ModelRDB m)
                                 throws RDFException
List all the statements in the given moddel which make the given set of constraints (a constraint set can be obtained using createConstraints(com.hp.hpl.mesa.rdf.jena.rdb.ModelRDB)).

RDFException

createConstraints

public IConstraints createConstraints(ModelRDB model)
Create a constraint object appropriate for this type of database layout


clear

public void clear(ModelRDB model)
           throws RDFRDBException
Remove all the statements from the given model. N.B. The implementation is not guaranteed to garbage collect resources and literal tables but this fact is not detectable from the API.

RDFRDBException

supportsMultipleModels

public boolean supportsMultipleModels()
Returns true if the database layout supports multiple RDF models in the same database.


supportsJenaReification

public boolean supportsJenaReification()
Returns true if the database layout supports implicit reification of statements (i.e. statements can be treated as resources).


listReifiedStatements

public ResultSetIterator listReifiedStatements(ModelRDB m)
                                        throws RDFException
Return an iterator over all statements which are have been added as reified statements.

RDFException

makeResource

public Resource makeResource(IDBID id,
                             java.lang.String localname,
                             IDBID nsidw,
                             ModelRDB m)
                      throws RDFException
Re-create a resource from its local name and namespace identifier

RDFException

makeResource

public Resource makeResource(IDBID id,
                             java.lang.String localname,
                             IDBID nsid,
                             ModelRDB m,
                             IDBID stmtID)
                      throws RDFException
Re-create a resource from its local name and namespace identifier. If stmtID is not null then the resource is actually a reified statement and with that as its id.

RDFException

wrapDBID

public IDBID wrapDBID(java.lang.Object id)
               throws RDFException
Convert the raw SQL object used to store a database identifier into a java object which meets the IDBID interface

RDFException

getResource

public Resource getResource(IDBID id,
                            ModelRDB m)
                     throws RDFException
Fetch a resource just knowing its resource rdb-id.

RDFException

getBareStatementResource

public StatementImplRDB getBareStatementResource(IDBID id,
                                                 ModelRDB m)
                                          throws RDFException
Fetch a reiefied statement resource just knowing its resource rdb-id. Can be null if the ID can from a hash function and resource isn't registered yet. This variant will never attempt to instantiate the contents of the Statement (as does getResource) - if the statement is not cached then an empty StatementImplRDB will be returned.

RDFException

getProperty

public Property getProperty(IDBID id,
                            ModelRDB m)
                     throws RDFException
Fetch a property just knowing its resource rdb-id.

RDFException

getLiteral

public Literal getLiteral(IDBID id)
                   throws RDFException
Fetch a literal just knowing its literal rdb-id

RDFException

getLiteralID

public IDBID getLiteralID(Literal l)
                   throws RDFRDBException
Return the database ID for the literal

RDFRDBException

getResourceID

public IDBID getResourceID(Resource resource)
                    throws RDFException
Lookup the unique ID for a resource.

RDFException

getNamespace

public java.lang.String getNamespace(IDBID nsid)
                              throws RDFRDBException
Return the namespace string corresponding to a given namespace id

RDFRDBException

getSQLCache

public SQLCache getSQLCache()
Return the SQLCache used for low level database commands.


getResource

public Resource getResource(java.lang.String uri,
                            ModelRDB m)
                     throws RDFException
Fetch a resource, knowing its uri. If the resource does not yet exist in the database it is added

RDFException

getProperty

public Property getProperty(java.lang.String uri,
                            ModelRDB m)
                     throws RDFException
Fetch a property, knowing its uri. If the property does not yet exist in the database it is added

RDFException

hintPropertyTable

public void hintPropertyTable(Property p)
                       throws RDFException
Hint to the store that the given property could be stored as an attribute table.

RDFException


Copyright © 2001 Hewlett-Packard. All Rights Reserved.