org.universAAL.context.sesame.sail
Class ValueStore

Package class diagram package ValueStore
java.lang.Object
  extended by org.openrdf.model.impl.ValueFactoryBase
      extended by org.universAAL.context.sesame.sail.ValueStore
All Implemented Interfaces:
org.openrdf.model.ValueFactory

public class ValueStore
extends org.openrdf.model.impl.ValueFactoryBase

File-based indexed storage and retrieval of RDF values. ValueStore maps RDF values to integer IDs and vice-versa.

Author:
Arjohn Kampman

Field Summary
static int NAMESPACE_CACHE_SIZE
          The default namespace cache size: 64.
static int NAMESPACE_ID_CACHE_SIZE
          The default namespace id cache size: 32.
static int VALUE_CACHE_SIZE
          The default value cache size: 512.
static int VALUE_ID_CACHE_SIZE
          The default value id cache size: 128.
 
Constructor Summary
ValueStore(File dataDir)
           
ValueStore(File dataDir, boolean forceSync)
           
ValueStore(File dataDir, boolean forceSync, int valueCacheSize, int valueIDCacheSize, int namespaceCacheSize, int namespaceIDCacheSize, boolean encrypt)
           
 
Method Summary
 void clear()
          Removes all values from the ValueStore.
 void close()
          Closes the ValueStore, releasing any file references, etc.
 NativeBNode createBNode(String nodeID)
           
 NativeLiteral createLiteral(String value)
           
 NativeLiteral createLiteral(String value, String language)
           
 NativeLiteral createLiteral(String value, org.openrdf.model.URI datatype)
           
 org.openrdf.model.Statement createStatement(org.openrdf.model.Resource subject, org.openrdf.model.URI predicate, org.openrdf.model.Value object)
           
 org.openrdf.model.Statement createStatement(org.openrdf.model.Resource subject, org.openrdf.model.URI predicate, org.openrdf.model.Value object, org.openrdf.model.Resource context)
           
 NativeURI createURI(String uri)
           
 NativeURI createURI(String namespace, String localName)
           
 int getID(org.openrdf.model.Value value)
          Gets the ID for the specified value.
 NativeBNode getNativeBNode(org.openrdf.model.BNode bnode)
          Creates a NativeBNode that is equal to the supplied bnode.
 NativeLiteral getNativeLiteral(org.openrdf.model.Literal l)
          Creates an NativeLiteral that is equal to the supplied literal.
 NativeResource getNativeResource(org.openrdf.model.Resource resource)
           
 NativeURI getNativeURI(org.openrdf.model.URI uri)
          Creates a NativeURI that is equal to the supplied URI.
 NativeValue getNativeValue(org.openrdf.model.Value value)
           
 info.aduna.concurrent.locks.Lock getReadLock()
          Gets a read lock on this value store that can be used to prevent values from being removed while the lock is active.
 ValueStoreRevision getRevision()
           
 NativeValue getValue(int id)
          Gets the value for the specified ID.
 int storeValue(org.openrdf.model.Value value)
          Stores the supplied value and returns the ID that has been assigned to it.
 void sync()
          Synchronizes any changes that are cached in memory to disk.
 
Methods inherited from class org.openrdf.model.impl.ValueFactoryBase
createBNode, createFPLiteral, createIntegerLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createNumericLiteral, initBNodeParams
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VALUE_CACHE_SIZE

public static final int VALUE_CACHE_SIZE
The default value cache size: 512.

See Also:
Constant Field Values

VALUE_ID_CACHE_SIZE

public static final int VALUE_ID_CACHE_SIZE
The default value id cache size: 128.

See Also:
Constant Field Values

NAMESPACE_CACHE_SIZE

public static final int NAMESPACE_CACHE_SIZE
The default namespace cache size: 64.

See Also:
Constant Field Values

NAMESPACE_ID_CACHE_SIZE

public static final int NAMESPACE_ID_CACHE_SIZE
The default namespace id cache size: 32.

See Also:
Constant Field Values
Constructor Detail

ValueStore

public ValueStore(File dataDir)
           throws IOException
Throws:
IOException

ValueStore

public ValueStore(File dataDir,
                  boolean forceSync)
           throws IOException
Throws:
IOException

ValueStore

public ValueStore(File dataDir,
                  boolean forceSync,
                  int valueCacheSize,
                  int valueIDCacheSize,
                  int namespaceCacheSize,
                  int namespaceIDCacheSize,
                  boolean encrypt)
           throws IOException
Throws:
IOException
Method Detail

getRevision

public ValueStoreRevision getRevision()

getReadLock

public info.aduna.concurrent.locks.Lock getReadLock()
                                             throws InterruptedException
Gets a read lock on this value store that can be used to prevent values from being removed while the lock is active.

Throws:
InterruptedException

getValue

public NativeValue getValue(int id)
                     throws IOException
Gets the value for the specified ID.

Parameters:
id - A value ID.
Returns:
The value for the ID, or null no such value could be found.
Throws:
IOException - If an I/O error occurred.

getID

public int getID(org.openrdf.model.Value value)
          throws IOException
Gets the ID for the specified value.

Parameters:
value - A value.
Returns:
The ID for the specified value, or NativeValue.UNKNOWN_ID if no such ID could be found.
Throws:
IOException - If an I/O error occurred.

storeValue

public int storeValue(org.openrdf.model.Value value)
               throws IOException
Stores the supplied value and returns the ID that has been assigned to it. In case the value was already present, the value will not be stored again and the ID of the existing value is returned.

Parameters:
value - The Value to store.
Returns:
The ID that has been assigned to the value.
Throws:
IOException - If an I/O error occurred.

clear

public void clear()
           throws IOException
Removes all values from the ValueStore.

Throws:
IOException - If an I/O error occurred.

sync

public void sync()
          throws IOException
Synchronizes any changes that are cached in memory to disk.

Throws:
IOException - If an I/O error occurred.

close

public void close()
           throws IOException
Closes the ValueStore, releasing any file references, etc. Once closed, the ValueStore can no longer be used.

Throws:
IOException - If an I/O error occurred.

createURI

public NativeURI createURI(String uri)

createURI

public NativeURI createURI(String namespace,
                           String localName)

createBNode

public NativeBNode createBNode(String nodeID)

createLiteral

public NativeLiteral createLiteral(String value)

createLiteral

public NativeLiteral createLiteral(String value,
                                   String language)

createLiteral

public NativeLiteral createLiteral(String value,
                                   org.openrdf.model.URI datatype)

createStatement

public org.openrdf.model.Statement createStatement(org.openrdf.model.Resource subject,
                                                   org.openrdf.model.URI predicate,
                                                   org.openrdf.model.Value object)

createStatement

public org.openrdf.model.Statement createStatement(org.openrdf.model.Resource subject,
                                                   org.openrdf.model.URI predicate,
                                                   org.openrdf.model.Value object,
                                                   org.openrdf.model.Resource context)

getNativeValue

public NativeValue getNativeValue(org.openrdf.model.Value value)

getNativeResource

public NativeResource getNativeResource(org.openrdf.model.Resource resource)

getNativeURI

public NativeURI getNativeURI(org.openrdf.model.URI uri)
Creates a NativeURI that is equal to the supplied URI. This method returns the supplied URI itself if it is already a NativeURI that has been created by this ValueStore, which prevents unnecessary object creations.

Returns:
A NativeURI for the specified URI.

getNativeBNode

public NativeBNode getNativeBNode(org.openrdf.model.BNode bnode)
Creates a NativeBNode that is equal to the supplied bnode. This method returns the supplied bnode itself if it is already a NativeBNode that has been created by this ValueStore, which prevents unnecessary object creations.

Returns:
A NativeBNode for the specified bnode.

getNativeLiteral

public NativeLiteral getNativeLiteral(org.openrdf.model.Literal l)
Creates an NativeLiteral that is equal to the supplied literal. This method returns the supplied literal itself if it is already a NativeLiteral that has been created by this ValueStore, which prevents unnecessary object creations.

Returns:
A NativeLiteral for the specified literal.


Copyright © 2014 universAAL Consortium. All Rights Reserved.