org.openanzo.common.rdb.layout
Class CompositeNodeLayout

java.lang.Object
  extended by org.openanzo.common.rdb.layout.CompositeNodeLayout

public class CompositeNodeLayout
extends java.lang.Object

Provides cached access to RDF Nodes persisted in a relational database according to the 'node centric layout' schema. RDF Nodes are allocated IDs when they are stored allowing any database table to store a reference to a node using a BIGINT column and this class for converting Nodes to and from the IDs stored in the database.

Author:
Stephen Evanchik, Joe Betz

Constructor Summary
CompositeNodeLayout(SQLCache sqlCache, Sequence sequences, LiteralIndexer literalIndexer, java.lang.String containerName, int cacheSize, int maxLength, java.lang.String optimizationString, boolean supportsTempTables, java.lang.String sessionPrefix)
          Construct a layout to store nodes in a database
CompositeNodeLayout(SQLCache sqlCache, Sequence sequences, LiteralIndexer literalIndexer, java.lang.String containerName, int maxLength, java.lang.String optimizationString, boolean supportsTempTables, java.lang.String sessionPrefix, CacheProvider cacheProvider)
          Construct a layout to store nodes in a database
 
Method Summary
 org.openrdf.model.Value cache(java.lang.Long id, java.lang.String value, java.lang.Long modifierId)
          Create Value object from provided ID and value and cache result
 void clearCache()
          Clear all of the in memory node caches as well as the datatype and language caches
 void clearUncommittedCache()
          Clear the in-memory uncommitted cache data
 void commitUncommittedCache()
          Commit the in-memory uncommitted cache data
 java.lang.Long fetchId(org.openrdf.model.Value value)
          Fetch the ID of the Value from the appropriate table
 org.openrdf.model.Value fetchValue(java.lang.Long id)
          Fetch the stored Value for the provided ID
 ClosableIterator<NodeSQL.GetAllLiteralsResult> getAllLiterals()
          Get an Iterator over all the Literal values stored in the database
 java.lang.String getBlankNodeTableName()
          Get the Blank Node table name
 ValueLayoutCacheProxy getDatatypeLayout()
          Get the DataType layout
 java.lang.Object getIfCached(java.lang.Long id)
          Get the Object for this ID, if already cached
 java.lang.Long getIfCached(org.openrdf.model.Value value)
          Get the ID for this Value, if already cached
 ValueLayoutCacheProxy getLanguageLayout()
          Get the Language layout
 LiteralIndexer getLiteralIndexer()
          Get the literalIndexer
 java.lang.String getLiteralTableName()
          Get the Literal table name
 java.lang.String getLongLiteralTableName()
          Get the Long Literal table name
 java.lang.String getLongURITableName()
          Get the Long URI table name
 java.lang.String getLongXMLTableName()
          Get the Long XML table name
 NodeConverter getNodeConverter()
          Get the nodeConverter
 NodeLayoutCacheProxy<org.openrdf.model.Literal> getNodeLiteralLayout()
          Get the nodeLiteralLayout
 NodeType getNodeType(org.openrdf.model.Value n)
          Determine the NodeType for a given node
 NodeLayoutCacheProxy<org.openrdf.model.URI> getNodeURILayout()
          Get the nodeURILayout
 java.lang.String getURITableName()
          Get the URI table name
 java.lang.String getXMLTableName()
          Get the XML table name
 boolean isCached(java.lang.Long id)
          Return true if a Value with this ID is already cached
 boolean isCached(org.openrdf.model.Value value)
          Return true if a ID for this Value is already cached
 boolean isLong(org.openrdf.model.Value n)
          Determine whether or not a node's string representation is longer than the maximum length.
 java.lang.String[] listTables()
          Get the array of table names where the nodes are stored
 java.util.Map<java.lang.Long,org.openrdf.model.Value> resolveStoredIds(java.util.Set<java.lang.Long> ids)
          Resolve the Values of the set of provided IDs
 java.util.Map<org.openrdf.model.Value,java.lang.Long> resolveStoredNodes(java.util.Set<org.openrdf.model.Value> nodesToResolve, boolean storeUnresolvedNodes)
          Resolve the IDs of the set of provided Values,optionally storing Values if they are not already stored based.
 java.lang.Long store(org.openrdf.model.Value value)
          Store value in appropriate table and return ID
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompositeNodeLayout

public CompositeNodeLayout(SQLCache sqlCache,
                           Sequence sequences,
                           LiteralIndexer literalIndexer,
                           java.lang.String containerName,
                           int maxLength,
                           java.lang.String optimizationString,
                           boolean supportsTempTables,
                           java.lang.String sessionPrefix,
                           CacheProvider cacheProvider)
Construct a layout to store nodes in a database

Parameters:
sqlCache - The interface to the SQL prepared statement cache
sequences - A sequence object that is used to get IDs
literalIndexer - Literal indexer for the underlying connection
containerName - The name of the logical container for the nodes. This container name is used to generate the table names for each node type (i.e. Node_URI or Node_Literal, etc.)
maxLength - The maximum length of a node's string representation before it is considered long
optimizationString - String prepended to queries to enable database specific optimizations
supportsTempTables - true if the database supports temporary tables, false otherwise.
sessionPrefix - prefix for references to temporary tables within queries
cacheProvider - set of id to value caches

CompositeNodeLayout

public CompositeNodeLayout(SQLCache sqlCache,
                           Sequence sequences,
                           LiteralIndexer literalIndexer,
                           java.lang.String containerName,
                           int cacheSize,
                           int maxLength,
                           java.lang.String optimizationString,
                           boolean supportsTempTables,
                           java.lang.String sessionPrefix)
Construct a layout to store nodes in a database

Parameters:
sqlCache - The interface to the SQL prepared statement cache
sequences - A sequence object that is used to get IDs
literalIndexer - Literal indexer for the underlying connection
containerName - The name of the logical container for the nodes. This container name is used to generate the table names for each node type (i.e. Node_URI or Node_Literal, etc.)
cacheSize - Size of the id/value caches
maxLength - The maximum length of a node's string representation before it is considered long
optimizationString - String prepended to queries to enable database specific optimizations
supportsTempTables - true if the database supports temporary tables, false otherwise.
sessionPrefix - prefix for references to temporary tables within queries
Method Detail

getNodeType

public NodeType getNodeType(org.openrdf.model.Value n)
Determine the NodeType for a given node

Parameters:
n - The node to retrieve its specific type
Returns:
The type of the node

isLong

public boolean isLong(org.openrdf.model.Value n)
Determine whether or not a node's string representation is longer than the maximum length.

Parameters:
n - The node to test
Returns:
true of the node is a 'long' node, false otherwise

listTables

public java.lang.String[] listTables()
Get the array of table names where the nodes are stored

Returns:
An array of table names where each node type is stored

getDatatypeLayout

public ValueLayoutCacheProxy getDatatypeLayout()
Get the DataType layout

Returns:
the DataType layout

getLanguageLayout

public ValueLayoutCacheProxy getLanguageLayout()
Get the Language layout

Returns:
the Language layout

clearCache

public void clearCache()
Clear all of the in memory node caches as well as the datatype and language caches


clearUncommittedCache

public void clearUncommittedCache()
Clear the in-memory uncommitted cache data


commitUncommittedCache

public void commitUncommittedCache()
Commit the in-memory uncommitted cache data


store

public java.lang.Long store(org.openrdf.model.Value value)
Store value in appropriate table and return ID

Parameters:
value - value to store
Returns:
ID of value stored in table

fetchId

public java.lang.Long fetchId(org.openrdf.model.Value value)
Fetch the ID of the Value from the appropriate table

Parameters:
value - value to store
Returns:
ID of value stored in table

fetchValue

public org.openrdf.model.Value fetchValue(java.lang.Long id)
Fetch the stored Value for the provided ID

Parameters:
id - ID of value to retrieve
Returns:
Value for provided ID

resolveStoredNodes

public java.util.Map<org.openrdf.model.Value,java.lang.Long> resolveStoredNodes(java.util.Set<org.openrdf.model.Value> nodesToResolve,
                                                                                boolean storeUnresolvedNodes)
Resolve the IDs of the set of provided Values,optionally storing Values if they are not already stored based.

Parameters:
nodesToResolve - Set of Values to resolve
storeUnresolvedNodes - Store Values that are not already stored
Returns:
Map of Values to their resolved IDs

resolveStoredIds

public java.util.Map<java.lang.Long,org.openrdf.model.Value> resolveStoredIds(java.util.Set<java.lang.Long> ids)
Resolve the Values of the set of provided IDs

Parameters:
ids - Set of IDs to resolve
Returns:
Map of IDs to their resolved Values

cache

public org.openrdf.model.Value cache(java.lang.Long id,
                                     java.lang.String value,
                                     java.lang.Long modifierId)
Create Value object from provided ID and value and cache result

Parameters:
id - ID of node
value - String value of node
modifierId - modifierId for literals
Returns:
convert Value for provided data

getIfCached

public java.lang.Object getIfCached(java.lang.Long id)
Get the Object for this ID, if already cached

Parameters:
id - of Object to retrieve
Returns:
the Object for this ID, if already cached

getIfCached

public java.lang.Long getIfCached(org.openrdf.model.Value value)
Get the ID for this Value, if already cached

Parameters:
value - node value to find cached ID
Returns:
the ID for this Value, if already cached

isCached

public boolean isCached(java.lang.Long id)
Return true if a Value with this ID is already cached

Parameters:
id - to check
Returns:
true if a Value with this ID is already cached

isCached

public boolean isCached(org.openrdf.model.Value value)
Return true if a ID for this Value is already cached

Parameters:
value - node value to check
Returns:
true if a ID for this Value is already cached

getNodeURILayout

public NodeLayoutCacheProxy<org.openrdf.model.URI> getNodeURILayout()
Get the nodeURILayout

Returns:
the nodeURILayout

getNodeConverter

public NodeConverter getNodeConverter()
Get the nodeConverter

Returns:
the nodeConverter

getNodeLiteralLayout

public NodeLayoutCacheProxy<org.openrdf.model.Literal> getNodeLiteralLayout()
Get the nodeLiteralLayout

Returns:
the nodeLiteralLayout

getAllLiterals

public ClosableIterator<NodeSQL.GetAllLiteralsResult> getAllLiterals()
Get an Iterator over all the Literal values stored in the database

Returns:
an Iterator over all the Literal values stored in the database

getLiteralIndexer

public LiteralIndexer getLiteralIndexer()
Get the literalIndexer

Returns:
the literalIndexer

getURITableName

public java.lang.String getURITableName()
Get the URI table name

Returns:
URI table name

getLongURITableName

public java.lang.String getLongURITableName()
Get the Long URI table name

Returns:
Long URI table name

getLiteralTableName

public java.lang.String getLiteralTableName()
Get the Literal table name

Returns:
Literal table name

getLongLiteralTableName

public java.lang.String getLongLiteralTableName()
Get the Long Literal table name

Returns:
Long Literal table name

getXMLTableName

public java.lang.String getXMLTableName()
Get the XML table name

Returns:
XML table name

getLongXMLTableName

public java.lang.String getLongXMLTableName()
Get the Long XML table name

Returns:
Long XML table name

getBlankNodeTableName

public java.lang.String getBlankNodeTableName()
Get the Blank Node table name

Returns:
Blank Node table name


Copyright © 2007 Cambridge Semantics Inc.. All Rights Reserved.