com.hp.hpl.jena.db.impl
Class DriverRDB

java.lang.Object
  extended bycom.hp.hpl.jena.db.impl.DriverRDB
All Implemented Interfaces:
IRDBDriver
Direct Known Subclasses:
Driver_HSQL

public abstract class DriverRDB
extends Object
implements IRDBDriver

Base database driver for implementing SpecializedGraphs. Different drivers are needed for different databases and different layout schemes.

This driver is a base implemention from which database-specific drivers can inherit. It is not generic in the sense that it will work on any minimal SQL store and so should be treated as if it were an abstract class.

The SQL statements which implement each of the functions are loaded in a separate file etc/[layout]_[database].sql from the classpath.

Version:
$Revision: 1.1 $ on $Date: 2003/10/16 11:36:33 $
Author:
hkuno modification of Jena1 code by Dave Reynolds (der)

Nested Class Summary
 
Nested classes inherited from class com.hp.hpl.jena.db.impl.IRDBDriver
IRDBDriver.GenSQLAnd
 
Field Summary
protected  boolean BATCH_ENABLED
          Set to true if batching prepared statements is enabled
protected  boolean CACHE_PREPARED_STATEMENTS
          Set to true to enable cache of pre-prepared statements
protected  String DATABASE_TYPE
          The name of the database type this driver supports
protected  boolean DB_NAMES_TO_UPPER
          Indicates whether search pattern used to select system objects by name should be upper-case.
protected  int DEFAULT_ID
          Unique numeric identifier of the graph holding default properties
protected  String DEFAULT_PROPS
          Name of the graph holding default properties (the one's that a newly-created graph will have by default
protected  String DEFAULT_SQL_FILE
          The name of the sql definition file for this database/layout combo
protected  String DRIVER_NAME
          The class name of the database driver (e.g. jdbc.sql.class)
protected  String EOS
          true if the database engine will trim trailing spaces in strings. to prevent this, append EOS to strings that should not be trimmed.
protected  char EOS_CHAR
           
protected  int EOS_LEN
           
protected  String GRAPH_TABLE
          Name of the graph table
protected  String ID_SQL_TYPE
          The SQL type to use for storing ids (compatible with wrapDBID)
protected  int INDEX_KEY_LENGTH
          The maximum size of index key (or a component of a key)
protected  int INDEX_KEY_LENGTH_MAX
          The maximum possible value for INDEX_KEY_LENGTH (db-dependent)
protected  boolean inTransaction
          flag to indicate that there is a transaction active on the associated connection
protected  boolean IS_XACT_DB
          true if graphs using this database instance supports transactions.
protected  int JENA_LONGEST_TABLE_NAME_LENGTH
          Holds the length of the longest jena table or index name.
protected  String LAYOUT_TYPE
          The name of the layout type this driver supports
protected  String LAYOUT_VERSION
          Database layout version
protected static org.apache.log4j.Logger logger
           
protected  String LONG_LIT_TABLE
          Name of the long literal table
protected  int LONG_OBJECT_LENGTH
          if URI_COMPRESS is true, compress prefixes that are longer than this. /** The maximum size of an object that can be stored in a Statement table
protected  int LONG_OBJECT_LENGTH_MAX
          The maximum possible value for LONG_OBJECT_LENGTH (db-dependent)
protected  String LONG_URI_TABLE
          Name of the long URI table
protected  IDBConnection m_dbcon
           
protected  DBPropDatabase m_dbProps
          This Graph's db properties
protected  String m_lsetClassName
          Cached name of this class's SpecializedGraph_XXX class
protected  String m_lsetReifierClassName
          Cached name of this class's SpecializedGraphReifer_XXX class
protected  String m_psetClassName
          Name of this class's PSet_TripleStore_XXX class
protected  String m_psetReifierClassName
          Name of this class's PSet_TripleStore_XXX class
protected  SQLCache m_sql
          Instance of SQLCache used by Driver for hard-coded db commands
protected  SpecializedGraph m_sysProperties
          Cache a reference to the system property graph (java)
protected  boolean PRE_ALLOCATE_ID
          Set to true if IDs are allocated prior to insert
static int PREFIX_CACHE_SIZE
           
protected  String PREFIX_TABLE
          Name of the prefix table
protected  LRUCache prefixCache
           
protected  char QUOTE_CHAR
          EOS is appended to most RDB strings to deal with string trimming. if STRINGS_TRIMMED is false, EOS is null. otherwise, EOS is EOS_CHAR.
protected static String RDBCodeANY
           
protected static String RDBCodeBlank
           
protected static String RDBCodeDelim
           
protected static char RDBCodeDelimChar
           
protected static String RDBCodeInvalid
           
protected static String RDBCodeLiteral
           
protected static String RDBCodePrefix
           
protected static String RDBCodeRef
           
protected static String RDBCodeURI
           
protected static String RDBCodeValue
           
protected static String RDBCodeVariable
           
protected  boolean SKIP_DUPLICATE_CHECK
          Set to true if the insert operations already check for duplications
protected  String SQL_FILE
          The name of the sql definition file for this database/layout combo
protected  String STORE_WITH_MODEL
          If not null, newly-created graphs share tables with the identified graph
protected  boolean STRINGS_TRIMMED
           
protected  String SYSTEM_STMT_TABLE
          Default name of the table that holds system property graph asserted statements
protected  int TABLE_NAME_LENGTH_MAX
          Holds maximum length of table and index names in database.
protected  String TABLE_NAME_PREFIX
          Holds prefix for names of Jena database tables.
protected  boolean URI_COMPRESS
          true if URI's are to be compressed by storing prefixes (an approximation of a namespace) in the JENA_PREFIX table. note that "short" prefixes are not stored, i.e., the prefix length not more than URI_COMPRESS_LENGTH.
protected  int URI_COMPRESS_LENGTH
           
protected  String VERSION
          Driver version number
 
Constructor Summary
DriverRDB()
          Create a bare instance of the driver.
 
Method Summary
 void abort()
          If underlying database connection supports transactions, call abort() on the connection, then turn autocommit on.
 DBIDInt addRDBLongObject(DriverRDB.RDBLongObject lobj, String table)
          Insert a long object into the database.
protected  String aliasToString(int alias)
           
 void begin()
          If the underlying database connection supports transactions, turn autocommit off, then begin a new transaction.
protected  void checkDbIsOpen()
           
protected  void checkDbUninitialized()
           
 void cleanDB()
          Remove all RDF information from a database.
 void clearSequences()
          Drop all Jena-related sequences from database, if necessary.
 void close()
          Deprecated. Since Jena 2.0 this call is no longer required - just close the DBConnection - there should be no need for an application to interact directly with the driver.
protected  String colAliasToString(int alias, char colid)
           
protected  String colidToColname(char colid)
           
 void commit()
          If the underlying database connection supports transactions, call commit(), then turn autocommit on.
 List createSpecializedGraphs(DBPropGraph graphProperties)
          Construct and return a new specialized graph.
 String createTable(int graphId, boolean isReif)
          Create a table for storing asserted or reified statements.
protected  boolean dbIsOpen()
           
static int dbSplitNamespace(String uri)
          This is cuurently a copy of Util.splitNamespace.
 void deleteTable(String tableName)
          Delete a table.
protected  SpecializedGraph formatAndConstructSystemSpecializedGraph()
          Format the database and construct a brand new system specialized graph.
 void formatDB()
          Deprecated. Since Jena 2.0 this call is no longer needed - formatting happens automatically as a side effect of creating Models - there should be no need for an application to interact directly with the driver.
 String genSQLFromKW()
           
 String genSQLFromList(int aliasCnt, String table)
          Generate an SQL string for a from list of a select stmt.
 String genSQLJoin(int lhsAlias, char lhsCol, int rhsAlias, char rhsCol)
          Generate an SQL string to joing two table columns.
 String genSQLQualConst(int alias, char pred, Node lit)
          Generate an SQL string to match a table column value to a constant.
 String genSQLQualGraphId(int alias, int graphId)
          Generate an SQL string to match a graph id.
 String genSQLQualParam(int alias, char pred)
          Generate an SQL string to match a table column value to a parameter.
 String genSQLReifQualAnyObj(boolean objIsStmt)
          Generate an SQL string for a reified statement to match on any subject, predicate or object column.
 String genSQLReifQualObj(char reifProp, boolean hasObj)
          Generate an SQL string for a reified statement to match on a property column.
 String genSQLReifQualStmt()
          Generate an SQL string for a reified statement to match on the stmt URI.
 String genSQLResList(int[] resIndex, VarIndex[] binding)
          Generate an SQL string for a result list of a select stmt.
 String genSQLSelectKW()
           
 String genSQLSelectStmt(String res, String from, String qual)
          Generate an SQL Select statement given the result list, the from list and the where clause;
 String genSQLWhereKW()
           
 boolean getBatchEnabled()
          Get the value of BatchEnabled
 DBIDInt getBlankID(String bstr, boolean add)
          Return the database ID for the URI, if it exists
 int getCompressCacheSize()
          Get the value of CompressCacheSize
 int getCompressURILength()
          Get the value of CompressURILength
 IDBConnection getConnection()
          Return the connection
protected abstract  String[] getCreateTableParams(int graphId, boolean isReif)
           
 String getDatabaseType()
          Return a string identifying underlying database type.
protected abstract  String[] getDbInitTablesParams()
           
 DBPropGraph getDefaultModelProperties()
          Method getDefaultModelProperties Return the default properties for a new model stored in this database.
 boolean getDoCompressURI()
          Get the value of DoCompressURI
 boolean getDoDuplicateCheck()
          Get the value of DoDuplicateCheck
 int getIndexKeyLength()
          Get the value of IndexKeyLength
 boolean getIsTransactionDb()
          Get the value of IsTransactionDb
 DBIDInt getLiteralID(Node_Literal lnode, boolean add)
          Return the database ID for the literal, if it exists
 DBIDInt getLongObjectID(DriverRDB.RDBLongObject lobj, String table, boolean add)
           
 int getLongObjectLength()
          Get the value of LongObjectLength
 List getSequences()
          Check database and see if named sequence exists.
 String getStoreWithModel()
          Get the value of StoreWithModel
 SpecializedGraph getSystemSpecializedGraph()
          Return the specialized graph used to store system properties.
protected  int getTableCount(int graphId)
           
 String getTableNamePrefix()
          Get the value of TableNamePrefix
 DBIDInt getURIID(String qname, boolean add)
          Return the database ID for the URI, if it exists
abstract  int graphIdAlloc(String graphName)
          Allocate an identifier for a new graph.
protected  String IDtoBlank(String bnID)
          Return the Blank node string that has the given database id.
protected  String IDtoLiteral(int litID)
          Return the long literal string that has the given database id.
protected  DriverRDB.RDBLongObject IDtoLongObject(int dbid, String table)
           
protected  DriverRDB.RDBLongObject IDtoLongObject(String idAsString, String table)
           
protected  String IDtoPrefix(int prefixID)
          Return the prefix string that has the given prefix id.
protected  String IDtoString(int dbID, String table, String RDBcode)
           
protected  String IDtoString(String dbidAsString, String table, String RDBcode)
           
protected  String IDtoURI(String uriID)
          Return the URI string that has the given database id.
 boolean isDBFormatOK()
          Test if the database has previously been formatted.
protected  DriverRDB.RDBLongObject literalToLongObject(Node_Literal node)
           
 String litLangTypeToRDBString(String lang, String dtype)
          Encode a literal node's lang and datatype as a string of the form ":[langLen]:[datatypeLen]:[langString][dataTypeString]"
 String nodeToRDBString(Node node, boolean addIfLong)
          Convert a node to a string to be stored in a statement table.
protected  boolean objectIsLong(int encodingLen, String objAsString)
          Check if an object is long, i.e., it exceeds the length limit for storing in a statement table.
protected  DriverRDB.RDBLongObject PrefixToLongObject(String prefix, int split)
           
protected  void RDBStringParseInt(String RDBString, DriverRDB.ParseInt pi, boolean toEnd)
           
 Node RDBStringToNode(String RDBString)
          Convert an RDB string to the node that it encodes.
 List recreateSpecializedGraphs(DBPropGraph graphProperties)
          Construct and return a list of specialized graphs to match those in the store.
 void removeSequence(String seqName)
          Removes named sequence from the database, if it exists.
 void removeSpecializedGraphs(DBPropGraph graphProperties, List specializedGraphs)
          Remove the specialized graph, erasing all trace of a Graph.
 boolean sequenceExists(String seqName)
          Check database and see if named sequence exists.
 void setBatchEnabled(boolean bool)
          Set the value of BatchEnabled
 void setCompressCacheSize(int count)
          Set the value of CompressCacheSize.
 void setCompressURILength(int len)
          Set the value of CompressURILength.
 void setDatabaseProperties(Graph databaseProperties)
          Method setDatabaseProperties.
 void setDoCompressURI(boolean bool)
          Set the value of DoCompressURI.
 void setDoDuplicateCheck(boolean bool)
          Set the value of DoDuplicateCheck.
 void setIndexKeyLength(int len)
          Set the value of IndexKeyLength.
 void setIsTransactionDb(boolean bool)
          Set the value of IsTransactionDb.
 void setLongObjectLength(int len)
          Set the value of LongObjectLength.
 void setStoreWithModel(String modelName)
          Set the value of StoreWithModel.
 void setTableNamePrefix(String prefix)
          Set the value of TableNamePrefix.
 String stringToDBname(String aName)
          Converts string to form accepted by database.
protected  long stringToHash(String str)
           
 boolean supportsJenaReification()
          Deprecated. Since Jena 2.0 the reification API has changed. The new API is supported in all models, but the old Jena 1 API is no longer supported. This call will return false to indicate to old code that the old style of jena reification is not supported.
 boolean supportsMultipleModels()
          Deprecated. Since Jena 2.0 all databases support multiple models.
 boolean transactionsSupported()
          Returns true if the underlying database supports transactions.
protected  DriverRDB.RDBLongObject URIToLongObject(String qname, String code)
           
 DBIDInt wrapDBID(Object id)
          Convert the raw SQL object used to store a database identifier into a java object which meets the DBIDInt interface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.hp.hpl.jena.db.impl.IRDBDriver
getInsertID, graphIdDealloc, setConnection
 

Field Detail

m_dbProps

protected DBPropDatabase m_dbProps
This Graph's db properties


m_psetClassName

protected String m_psetClassName
Name of this class's PSet_TripleStore_XXX class


m_psetReifierClassName

protected String m_psetReifierClassName
Name of this class's PSet_TripleStore_XXX class


m_lsetClassName

protected String m_lsetClassName
Cached name of this class's SpecializedGraph_XXX class


m_lsetReifierClassName

protected String m_lsetReifierClassName
Cached name of this class's SpecializedGraphReifer_XXX class


DRIVER_NAME

protected String DRIVER_NAME
The class name of the database driver (e.g. jdbc.sql.class)


DATABASE_TYPE

protected String DATABASE_TYPE
The name of the database type this driver supports


INDEX_KEY_LENGTH

protected int INDEX_KEY_LENGTH
The maximum size of index key (or a component of a key)


INDEX_KEY_LENGTH_MAX

protected int INDEX_KEY_LENGTH_MAX
The maximum possible value for INDEX_KEY_LENGTH (db-dependent)


IS_XACT_DB

protected boolean IS_XACT_DB
true if graphs using this database instance supports transactions. this is a user settable parameter. the underlying db engine may support transactions but an application may prefer to run without transactions for better performance. this can only be set before the db is formatted.


STRINGS_TRIMMED

protected boolean STRINGS_TRIMMED

EOS

protected String EOS
true if the database engine will trim trailing spaces in strings. to prevent this, append EOS to strings that should not be trimmed.


EOS_CHAR

protected char EOS_CHAR

EOS_LEN

protected int EOS_LEN

QUOTE_CHAR

protected char QUOTE_CHAR
EOS is appended to most RDB strings to deal with string trimming. if STRINGS_TRIMMED is false, EOS is null. otherwise, EOS is EOS_CHAR. EOS_LEN is the length of EOS (0 or 1).


DB_NAMES_TO_UPPER

protected boolean DB_NAMES_TO_UPPER
Indicates whether search pattern used to select system objects by name should be upper-case.


URI_COMPRESS

protected boolean URI_COMPRESS
true if URI's are to be compressed by storing prefixes (an approximation of a namespace) in the JENA_PREFIX table. note that "short" prefixes are not stored, i.e., the prefix length not more than URI_COMPRESS_LENGTH.


URI_COMPRESS_LENGTH

protected int URI_COMPRESS_LENGTH

LONG_OBJECT_LENGTH

protected int LONG_OBJECT_LENGTH
if URI_COMPRESS is true, compress prefixes that are longer than this. /** The maximum size of an object that can be stored in a Statement table


LONG_OBJECT_LENGTH_MAX

protected int LONG_OBJECT_LENGTH_MAX
The maximum possible value for LONG_OBJECT_LENGTH (db-dependent)


ID_SQL_TYPE

protected String ID_SQL_TYPE
The SQL type to use for storing ids (compatible with wrapDBID)


SKIP_DUPLICATE_CHECK

protected boolean SKIP_DUPLICATE_CHECK
Set to true if the insert operations already check for duplications


PRE_ALLOCATE_ID

protected boolean PRE_ALLOCATE_ID
Set to true if IDs are allocated prior to insert


SQL_FILE

protected String SQL_FILE
The name of the sql definition file for this database/layout combo


DEFAULT_SQL_FILE

protected String DEFAULT_SQL_FILE
The name of the sql definition file for this database/layout combo


BATCH_ENABLED

protected boolean BATCH_ENABLED
Set to true if batching prepared statements is enabled


TABLE_NAME_PREFIX

protected String TABLE_NAME_PREFIX
Holds prefix for names of Jena database tables.


TABLE_NAME_LENGTH_MAX

protected int TABLE_NAME_LENGTH_MAX
Holds maximum length of table and index names in database.


JENA_LONGEST_TABLE_NAME_LENGTH

protected int JENA_LONGEST_TABLE_NAME_LENGTH
Holds the length of the longest jena table or index name. This is really a hack and should be better architected. The currently known longest possible name is: GnTm_StmtXSP where prefix is the table name prefix (which isn't counted here), n is the graph identifier, m is the table number within that graph and XSP refers to the subject-predicate index. If we assume n and m might be two digits, we get 14.


CACHE_PREPARED_STATEMENTS

protected boolean CACHE_PREPARED_STATEMENTS
Set to true to enable cache of pre-prepared statements


LAYOUT_TYPE

protected String LAYOUT_TYPE
The name of the layout type this driver supports


SYSTEM_STMT_TABLE

protected String SYSTEM_STMT_TABLE
Default name of the table that holds system property graph asserted statements


LONG_LIT_TABLE

protected String LONG_LIT_TABLE
Name of the long literal table


LONG_URI_TABLE

protected String LONG_URI_TABLE
Name of the long URI table


PREFIX_TABLE

protected String PREFIX_TABLE
Name of the prefix table


GRAPH_TABLE

protected String GRAPH_TABLE
Name of the graph table


STORE_WITH_MODEL

protected String STORE_WITH_MODEL
If not null, newly-created graphs share tables with the identified graph


DEFAULT_PROPS

protected final String DEFAULT_PROPS
Name of the graph holding default properties (the one's that a newly-created graph will have by default

See Also:
Constant Field Values

DEFAULT_ID

protected final int DEFAULT_ID
Unique numeric identifier of the graph holding default properties

See Also:
Constant Field Values

VERSION

protected final String VERSION
Driver version number

See Also:
Constant Field Values

LAYOUT_VERSION

protected String LAYOUT_VERSION
Database layout version


logger

protected static org.apache.log4j.Logger logger

m_sql

protected SQLCache m_sql
Instance of SQLCache used by Driver for hard-coded db commands


m_sysProperties

protected SpecializedGraph m_sysProperties
Cache a reference to the system property graph (java)


m_dbcon

protected IDBConnection m_dbcon

prefixCache

protected LRUCache prefixCache

PREFIX_CACHE_SIZE

public static final int PREFIX_CACHE_SIZE
See Also:
Constant Field Values

inTransaction

protected boolean inTransaction
flag to indicate that there is a transaction active on the associated connection


RDBCodeURI

protected static String RDBCodeURI

RDBCodeBlank

protected static String RDBCodeBlank

RDBCodeLiteral

protected static String RDBCodeLiteral

RDBCodeVariable

protected static String RDBCodeVariable

RDBCodeANY

protected static String RDBCodeANY

RDBCodePrefix

protected static String RDBCodePrefix

RDBCodeValue

protected static String RDBCodeValue

RDBCodeRef

protected static String RDBCodeRef

RDBCodeDelim

protected static String RDBCodeDelim

RDBCodeDelimChar

protected static char RDBCodeDelimChar

RDBCodeInvalid

protected static String RDBCodeInvalid
Constructor Detail

DriverRDB

public DriverRDB()
Create a bare instance of the driver. It is not functional until a database connection has been supplied via setConnection.

Method Detail

getConnection

public IDBConnection getConnection()
Return the connection

Specified by:
getConnection in interface IRDBDriver

getSystemSpecializedGraph

public SpecializedGraph getSystemSpecializedGraph()
Return the specialized graph used to store system properties. (Constuct a new one if necessary).

Specified by:
getSystemSpecializedGraph in interface IRDBDriver
Returns:
SpecializedGraph holding properties of this database

formatAndConstructSystemSpecializedGraph

protected SpecializedGraph formatAndConstructSystemSpecializedGraph()
Format the database and construct a brand new system specialized graph.


getDbInitTablesParams

protected abstract String[] getDbInitTablesParams()

getCreateTableParams

protected abstract String[] getCreateTableParams(int graphId,
                                                 boolean isReif)

graphIdAlloc

public abstract int graphIdAlloc(String graphName)
Description copied from interface: IRDBDriver
Allocate an identifier for a new graph.

Specified by:
graphIdAlloc in interface IRDBDriver
Parameters:
graphName - The name of a new graph.
Returns:
the identifier of the new graph.

createSpecializedGraphs

public List createSpecializedGraphs(DBPropGraph graphProperties)
Construct and return a new specialized graph.

Specified by:
createSpecializedGraphs in interface IRDBDriver
Parameters:
graphProperties - A set of customization properties for the specialized graph.
Returns:
List of SpecializedGraphs to store a Graph

recreateSpecializedGraphs

public List recreateSpecializedGraphs(DBPropGraph graphProperties)
Construct and return a list of specialized graphs to match those in the store.

Specified by:
recreateSpecializedGraphs in interface IRDBDriver
Parameters:
graphProperties - A set of customization properties for the graph.
Returns:
List of SpecializedGraphs to store a Graph

removeSpecializedGraphs

public void removeSpecializedGraphs(DBPropGraph graphProperties,
                                    List specializedGraphs)
Remove the specialized graph, erasing all trace of a Graph.

Specified by:
removeSpecializedGraphs in interface IRDBDriver
Parameters:
graphProperties - The properties for the graph to be removed.

setDatabaseProperties

public void setDatabaseProperties(Graph databaseProperties)
Method setDatabaseProperties. Sets the current properties for the database.

Specified by:
setDatabaseProperties in interface IRDBDriver
Parameters:
databaseProperties - is a Graph containing a full set of database properties

getDefaultModelProperties

public DBPropGraph getDefaultModelProperties()
Method getDefaultModelProperties Return the default properties for a new model stored in this database. If none are stored, then load default properties into the database.

Specified by:
getDefaultModelProperties in interface IRDBDriver
Returns:
Graph containg the default properties for a new model

isDBFormatOK

public boolean isDBFormatOK()
Test if the database has previously been formatted.

Specified by:
isDBFormatOK in interface IRDBDriver
Returns:
boolean true if database is correctly formatted, false on any error.

stringToDBname

public String stringToDBname(String aName)
Converts string to form accepted by database.


cleanDB

public void cleanDB()
Description copied from interface: IRDBDriver
Remove all RDF information from a database. There should be no need for an application to call this function directly - instead use DBConnection.cleanDB().

Specified by:
cleanDB in interface IRDBDriver

clearSequences

public void clearSequences()
Drop all Jena-related sequences from database, if necessary. Override in subclass if sequences must be explicitly deleted.


removeSequence

public void removeSequence(String seqName)
Removes named sequence from the database, if it exists.

Parameters:
seqName -

sequenceExists

public boolean sequenceExists(String seqName)
Check database and see if named sequence exists.

Parameters:
seqName -

getSequences

public List getSequences()
Check database and see if named sequence exists.


formatDB

public void formatDB()
              throws RDFRDBException
Deprecated. Since Jena 2.0 this call is no longer needed - formatting happens automatically as a side effect of creating Models - there should be no need for an application to interact directly with the driver.

Initialise a database ready to store RDF tables.

Specified by:
formatDB in interface IRDBDriver
Throws:
RDFDBException - if the is a problem opening the connection or an internal SQL error.
RDFRDBException

createTable

public String createTable(int graphId,
                          boolean isReif)
Create a table for storing asserted or reified statements.

Specified by:
createTable in interface IRDBDriver
Parameters:
graphId - the graph which the table is created.
isReif - true if table stores reified statements.
Returns:
the name of the new table

deleteTable

public void deleteTable(String tableName)
Delete a table.

Parameters:
tableName - the name of the table to delete. *

abort

public void abort()
           throws RDFRDBException
If underlying database connection supports transactions, call abort() on the connection, then turn autocommit on.

Specified by:
abort in interface IRDBDriver
Throws:
RDFRDBException

begin

public void begin()
           throws RDFRDBException
If the underlying database connection supports transactions, turn autocommit off, then begin a new transaction. Note that transactions are associated with connections, not with Models. This

Specified by:
begin in interface IRDBDriver
Throws:
RDFRDBException

commit

public void commit()
            throws RDFRDBException
If the underlying database connection supports transactions, call commit(), then turn autocommit on.

Specified by:
commit in interface IRDBDriver
Throws:
RDFRDBException

getDatabaseType

public String getDatabaseType()
Return a string identifying underlying database type.

Specified by:
getDatabaseType in interface IRDBDriver

transactionsSupported

public boolean transactionsSupported()
Returns true if the underlying database supports transactions.

Specified by:
transactionsSupported in interface IRDBDriver

close

public void close()
           throws RDFRDBException
Deprecated. Since Jena 2.0 this call is no longer required - just close the DBConnection - there should be no need for an application to interact directly with the driver.

Close the driver Nothing to do for now.

Specified by:
close in interface IRDBDriver
Throws:
RDFDBException - if there is an access problem
RDFRDBException

supportsMultipleModels

public boolean supportsMultipleModels()
Deprecated. Since Jena 2.0 all databases support multiple models.

Returns true if the database layout supports multiple RDF models in the same database.

Specified by:
supportsMultipleModels in interface IRDBDriver
Returns:
boolean true if the database supports multiple models

supportsJenaReification

public boolean supportsJenaReification()
Deprecated. Since Jena 2.0 the reification API has changed. The new API is supported in all models, but the old Jena 1 API is no longer supported. This call will return false to indicate to old code that the old style of jena reification is not supported.

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

Specified by:
supportsJenaReification in interface IRDBDriver
Returns:
boolean true if the database supports jena 1.0 reification.

nodeToRDBString

public String nodeToRDBString(Node node,
                              boolean addIfLong)
                       throws RDFRDBException
Convert a node to a string to be stored in a statement table.

Specified by:
nodeToRDBString in interface IRDBDriver
Parameters:
addIfLong - If the node is a long object and is not in the database, add it.
Returns:
the string or null if failure.
Throws:
RDFRDBException

RDBStringToNode

public Node RDBStringToNode(String RDBString)
                     throws RDFRDBException
Convert an RDB string to the node that it encodes. Return null if failure.

Specified by:
RDBStringToNode in interface IRDBDriver
Returns:
The node or null if failure.
Throws:
RDFRDBException

dbSplitNamespace

public static int dbSplitNamespace(String uri)
This is cuurently a copy of Util.splitNamespace. It was copied rather than used directly for two reasons. 1) in the future it may be desirable to use a different split algorithm for persistence. 2) the util version could change at any time, which would render existing databases inaccessible. having a copy allows the db version to evolve in a controlled way. Given an absolute URI, determine the split point between the namespace part and the localname part. If there is no valid localname part then the length of the string is returned. The algorithm tries to find the longest NCName at the end of the uri, not immediately preceeded by the first colon in the string.

Parameters:
uri -
Returns:
the index of the first character of the localname

RDBStringParseInt

protected void RDBStringParseInt(String RDBString,
                                 DriverRDB.ParseInt pi,
                                 boolean toEnd)

PrefixToLongObject

protected DriverRDB.RDBLongObject PrefixToLongObject(String prefix,
                                                     int split)

litLangTypeToRDBString

public String litLangTypeToRDBString(String lang,
                                     String dtype)
                              throws RDFRDBException
Encode a literal node's lang and datatype as a string of the form ":[langLen]:[datatypeLen]:[langString][dataTypeString]"

Returns:
the string.
Throws:
RDFRDBException

objectIsLong

protected boolean objectIsLong(int encodingLen,
                               String objAsString)
Check if an object is long, i.e., it exceeds the length limit for storing in a statement table.

Returns:
true if literal is long, else false.

literalToLongObject

protected DriverRDB.RDBLongObject literalToLongObject(Node_Literal node)

stringToHash

protected long stringToHash(String str)

getBlankID

public DBIDInt getBlankID(String bstr,
                          boolean add)
                                           throws RDFRDBException
Return the database ID for the URI, if it exists

Throws:
RDFRDBException

getURIID

public DBIDInt getURIID(String qname,
                        boolean add)
                                         throws RDFRDBException
Return the database ID for the URI, if it exists

Throws:
RDFRDBException

URIToLongObject

protected DriverRDB.RDBLongObject URIToLongObject(String qname,
                                                  String code)

getLiteralID

public DBIDInt getLiteralID(Node_Literal lnode,
                            boolean add)
                                             throws RDFRDBException
Return the database ID for the literal, if it exists

Throws:
RDFRDBException

getLongObjectID

public DBIDInt getLongObjectID(DriverRDB.RDBLongObject lobj,
                               String table,
                               boolean add)
                                                throws RDFRDBException
Throws:
RDFRDBException

addRDBLongObject

public DBIDInt addRDBLongObject(DriverRDB.RDBLongObject lobj,
                                String table)
                                                 throws RDFRDBException
Insert a long object into the database. This assumes the object is not already in the database.

Returns:
the db index of the added literal
Throws:
RDFRDBException

IDtoPrefix

protected String IDtoPrefix(int prefixID)
Return the prefix string that has the given prefix id.

Parameters:
prefixID - - the dbid of the prefix.
Returns:
the prefix string or null if it does not exist.

IDtoBlank

protected String IDtoBlank(String bnID)
Return the Blank node string that has the given database id.

Parameters:
bnID - - the dbid of the blank node, as a string.
Returns:
the Blank node string or null if it does not exist.

IDtoURI

protected String IDtoURI(String uriID)
Return the URI string that has the given database id.

Parameters:
uriID - - the dbid of the uri, as a string.
Returns:
the uri string or null if it does not exist.

IDtoLiteral

protected String IDtoLiteral(int litID)
Return the long literal string that has the given database id.

Parameters:
litID - - the dbid of the literal..
Returns:
the long literal string or null if it does not exist.

IDtoString

protected String IDtoString(String dbidAsString,
                            String table,
                            String RDBcode)

IDtoString

protected String IDtoString(int dbID,
                            String table,
                            String RDBcode)

IDtoLongObject

protected DriverRDB.RDBLongObject IDtoLongObject(int dbid,
                                                 String table)

IDtoLongObject

protected DriverRDB.RDBLongObject IDtoLongObject(String idAsString,
                                                 String table)

wrapDBID

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

Throws:
RDFRDBException

genSQLReifQualStmt

public String genSQLReifQualStmt()
Description copied from interface: IRDBDriver
Generate an SQL string for a reified statement to match on the stmt URI.

Specified by:
genSQLReifQualStmt in interface IRDBDriver
Returns:
qualifier string

genSQLReifQualAnyObj

public String genSQLReifQualAnyObj(boolean objIsStmt)
Description copied from interface: IRDBDriver
Generate an SQL string for a reified statement to match on any subject, predicate or object column.

Specified by:
genSQLReifQualAnyObj in interface IRDBDriver
Parameters:
objIsStmt - If true, the object value is rdf:Statement so also match on the hasType column.
Returns:
qualifier string

genSQLReifQualObj

public String genSQLReifQualObj(char reifProp,
                                boolean hasObj)
Description copied from interface: IRDBDriver
Generate an SQL string for a reified statement to match on a property column.

Specified by:
genSQLReifQualObj in interface IRDBDriver
Parameters:
reifProp - The property column to match, one of S,P,O,T for subject, predicate, object or type, respectively.
hasObj - If true, the object value is known so do equality match. Otherwise, just check for non-null value.
Returns:
qualifier string

colidToColname

protected String colidToColname(char colid)

aliasToString

protected String aliasToString(int alias)

colAliasToString

protected String colAliasToString(int alias,
                                  char colid)

genSQLQualConst

public String genSQLQualConst(int alias,
                              char pred,
                              Node lit)
Description copied from interface: IRDBDriver
Generate an SQL string to match a table column value to a constant. If the literal does not occur in the database, a match condition is generated that will always return false. There's a known bug in this method. the literal is converted to a string BEFORE the query is run. consequently, there's a race condition. if the (long) literal is not in the database when the query is compiled but is added prior to running the query, then the query will (incorrectly) return no results. for now, we'll ignore this case and document it as a bug.

Specified by:
genSQLQualConst in interface IRDBDriver
Parameters:
alias - The table alias for this match.
pred - The column to match, one of S,P,O,N,T for subject, predicate, object, statement or type, respectively.
lit - The literal value to match.
Returns:
SQL string.

genSQLQualParam

public String genSQLQualParam(int alias,
                              char pred)
Description copied from interface: IRDBDriver
Generate an SQL string to match a table column value to a parameter.

Specified by:
genSQLQualParam in interface IRDBDriver
Parameters:
alias - The table alias for this match.
pred - The column to match, one of S,P,O,N,T for subject, predicate, object, statement or type, respectively.
Returns:
SQL string.

genSQLQualGraphId

public String genSQLQualGraphId(int alias,
                                int graphId)
Description copied from interface: IRDBDriver
Generate an SQL string to match a graph id.

Specified by:
genSQLQualGraphId in interface IRDBDriver
Parameters:
alias - The table alias for this match.
graphId - The identifer of the graph to match.
Returns:
SQL string.

genSQLJoin

public String genSQLJoin(int lhsAlias,
                         char lhsCol,
                         int rhsAlias,
                         char rhsCol)
Description copied from interface: IRDBDriver
Generate an SQL string to joing two table columns.

Specified by:
genSQLJoin in interface IRDBDriver
Parameters:
lhsAlias - The left side table alias for the join.
lhsCol - The left side column to join, one of S,P,O,N,T.
rhsAlias - The right side table alias to join.
rhsCol - The right side column to join.
Returns:
SQL string.

genSQLResList

public String genSQLResList(int[] resIndex,
                            VarIndex[] binding)
Description copied from interface: IRDBDriver
Generate an SQL string for a result list of a select stmt.

Specified by:
genSQLResList in interface IRDBDriver
Parameters:
binding - Array of Var containing the result list bindings.
Returns:
SQL string (not prefixed by "Select").

genSQLFromList

public String genSQLFromList(int aliasCnt,
                             String table)
Description copied from interface: IRDBDriver
Generate an SQL string for a from list of a select stmt.

Specified by:
genSQLFromList in interface IRDBDriver
Parameters:
aliasCnt - The number of table aliases in the from list.
table - The name of the table to be queried.
Returns:
SQL string (not prefixed by "From").

genSQLSelectKW

public String genSQLSelectKW()

genSQLFromKW

public String genSQLFromKW()

genSQLWhereKW

public String genSQLWhereKW()

genSQLSelectStmt

public String genSQLSelectStmt(String res,
                               String from,
                               String qual)
Description copied from interface: IRDBDriver
Generate an SQL Select statement given the result list, the from list and the where clause;

Specified by:
genSQLSelectStmt in interface IRDBDriver
Parameters:
res - The result list as a string.
from - The from list as a string.
qual - The where qualifier as a string.
Returns:
SQL statement.

getTableCount

protected int getTableCount(int graphId)

getLongObjectLength

public int getLongObjectLength()
Description copied from interface: IRDBDriver
Get the value of LongObjectLength

Specified by:
getLongObjectLength in interface IRDBDriver
Returns:
int

setLongObjectLength

public void setLongObjectLength(int len)
Description copied from interface: IRDBDriver
Set the value of LongObjectLength. Throws an exception if the database has been initialized.

Specified by:
setLongObjectLength in interface IRDBDriver

getIndexKeyLength

public int getIndexKeyLength()
Description copied from interface: IRDBDriver
Get the value of IndexKeyLength

Specified by:
getIndexKeyLength in interface IRDBDriver
Returns:
int

setIndexKeyLength

public void setIndexKeyLength(int len)
Description copied from interface: IRDBDriver
Set the value of IndexKeyLength. Throws an exception if the database has been initialized.

Specified by:
setIndexKeyLength in interface IRDBDriver

getIsTransactionDb

public boolean getIsTransactionDb()
Description copied from interface: IRDBDriver
Get the value of IsTransactionDb

Specified by:
getIsTransactionDb in interface IRDBDriver
Returns:
bool

setIsTransactionDb

public void setIsTransactionDb(boolean bool)
Description copied from interface: IRDBDriver
Set the value of IsTransactionDb. Throws an exception if the database has been initialized.

Specified by:
setIsTransactionDb in interface IRDBDriver
Parameters:
bool -

getDoCompressURI

public boolean getDoCompressURI()
Description copied from interface: IRDBDriver
Get the value of DoCompressURI

Specified by:
getDoCompressURI in interface IRDBDriver
Returns:
bool

setDoCompressURI

public void setDoCompressURI(boolean bool)
Description copied from interface: IRDBDriver
Set the value of DoCompressURI. Throws an exception if the database has been initialized.

Specified by:
setDoCompressURI in interface IRDBDriver
Parameters:
bool -

getCompressURILength

public int getCompressURILength()
Description copied from interface: IRDBDriver
Get the value of CompressURILength

Specified by:
getCompressURILength in interface IRDBDriver
Returns:
int

setCompressURILength

public void setCompressURILength(int len)
Description copied from interface: IRDBDriver
Set the value of CompressURILength. Throws an exception if the database has been initialized.

Specified by:
setCompressURILength in interface IRDBDriver

getDoDuplicateCheck

public boolean getDoDuplicateCheck()
Description copied from interface: IRDBDriver
Get the value of DoDuplicateCheck

Specified by:
getDoDuplicateCheck in interface IRDBDriver
Returns:
bool

setDoDuplicateCheck

public void setDoDuplicateCheck(boolean bool)
Description copied from interface: IRDBDriver
Set the value of DoDuplicateCheck.

Specified by:
setDoDuplicateCheck in interface IRDBDriver
Parameters:
bool -

dbIsOpen

protected boolean dbIsOpen()

checkDbIsOpen

protected void checkDbIsOpen()

checkDbUninitialized

protected void checkDbUninitialized()

getTableNamePrefix

public String getTableNamePrefix()
Description copied from interface: IRDBDriver
Get the value of TableNamePrefix

Specified by:
getTableNamePrefix in interface IRDBDriver
Returns:
String

setTableNamePrefix

public void setTableNamePrefix(String prefix)
Description copied from interface: IRDBDriver
Set the value of TableNamePrefix.

Specified by:
setTableNamePrefix in interface IRDBDriver

getStoreWithModel

public String getStoreWithModel()
Description copied from interface: IRDBDriver
Get the value of StoreWithModel

Specified by:
getStoreWithModel in interface IRDBDriver
Returns:
String

setStoreWithModel

public void setStoreWithModel(String modelName)
Description copied from interface: IRDBDriver
Set the value of StoreWithModel.

Specified by:
setStoreWithModel in interface IRDBDriver

getCompressCacheSize

public int getCompressCacheSize()
Description copied from interface: IRDBDriver
Get the value of CompressCacheSize

Specified by:
getCompressCacheSize in interface IRDBDriver
Returns:
int

setCompressCacheSize

public void setCompressCacheSize(int count)
Description copied from interface: IRDBDriver
Set the value of CompressCacheSize.

Specified by:
setCompressCacheSize in interface IRDBDriver

getBatchEnabled

public boolean getBatchEnabled()
Description copied from interface: IRDBDriver
Get the value of BatchEnabled

Specified by:
getBatchEnabled in interface IRDBDriver
Returns:
bool

setBatchEnabled

public void setBatchEnabled(boolean bool)
Description copied from interface: IRDBDriver
Set the value of BatchEnabled

Specified by:
setBatchEnabled in interface IRDBDriver
Parameters:
bool -


Copyright © 2003 SCAM. All Rights Reserved.