org.openrdf.sail.nativerdf
Class ValueStore

java.lang.Object
  extended by org.openrdf.model.impl.ValueFactoryBase
      extended by org.openrdf.sail.nativerdf.ValueStore
All Implemented Interfaces:
ValueFactory

public class ValueStore
extends ValueFactoryBase

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

Author:
Arjohn Kampman

Constructor Summary
ValueStore(File dataDir)
           
ValueStore(File dataDir, boolean forceSync)
           
 
Method Summary
 void clear()
          Removes all values from the ValueStore.
 void close()
          Closes the ValueStore, releasing any file references, etc.
 NativeBNode createBNode(String nodeID)
          Creates a new blank node with the given node identifier.
 NativeLiteral createLiteral(String value)
          Creates a new literal with the supplied label.
 NativeLiteral createLiteral(String value, String language)
          Creates a new literal with the supplied label and language attribute.
 NativeLiteral createLiteral(String value, URI datatype)
          Creates a new literal with the supplied label and datatype.
 Statement createStatement(Resource subject, URI predicate, Value object)
          Creates a new statement with the supplied subject, predicate and object.
 Statement createStatement(Resource subject, URI predicate, Value object, Resource context)
          Creates a new statement with the supplied subject, predicate and object and associated context.
 NativeURI createURI(String uri)
          Creates a new URI from the supplied string-representation.
 NativeURI createURI(String namespace, String localName)
          Creates a new URI from the supplied namespace and local name.
 int getID(Value value)
          Gets the ID for the specified value.
 NativeBNode getNativeBNode(BNode bnode)
          Creates a NativeBNode that is equal to the supplied bnode.
 NativeLiteral getNativeLiteral(Literal l)
          Creates an NativeLiteral that is equal to the supplied literal.
 NativeResource getNativeResource(Resource resource)
           
 NativeURI getNativeURI(URI uri)
          Creates a NativeURI that is equal to the supplied URI.
 NativeValue getNativeValue(Value value)
           
 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.
static void main(String[] args)
           
 int storeValue(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
 

Constructor Detail

ValueStore

public ValueStore(File dataDir)
           throws IOException
Throws:
IOException

ValueStore

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

getRevision

public ValueStoreRevision getRevision()

getReadLock

public 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(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(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)
Description copied from interface: ValueFactory
Creates a new URI from the supplied string-representation.

Parameters:
uri - A string-representation of a URI.
Returns:
An object representing the URI.

createURI

public NativeURI createURI(String namespace,
                           String localName)
Description copied from interface: ValueFactory
Creates a new URI from the supplied namespace and local name. Calling this method is funtionally equivalent to calling createURI(namespace+localName), but allows the ValueFactory to reuse supplied namespace and local name strings whenever possible. Note that the values returned by URI.getNamespace() and URI.getLocalName() are not necessarily the same as the values that are supplied to this method.

Parameters:
namespace - The URI's namespace.
localName - The URI's local name.

createBNode

public NativeBNode createBNode(String nodeID)
Description copied from interface: ValueFactory
Creates a new blank node with the given node identifier.

Parameters:
nodeID - The blank node identifier.
Returns:
An object representing the blank node.

createLiteral

public NativeLiteral createLiteral(String value)
Description copied from interface: ValueFactory
Creates a new literal with the supplied label.

Parameters:
value - The literal's label.

createLiteral

public NativeLiteral createLiteral(String value,
                                   String language)
Description copied from interface: ValueFactory
Creates a new literal with the supplied label and language attribute.

Parameters:
value - The literal's label.
language - The literal's language attribute, or null if the literal doesn't have a language.

createLiteral

public NativeLiteral createLiteral(String value,
                                   URI datatype)
Description copied from interface: ValueFactory
Creates a new literal with the supplied label and datatype.

Parameters:
value - The literal's label.
datatype - The literal's datatype, or null if the literal doesn't have a datatype.

createStatement

public Statement createStatement(Resource subject,
                                 URI predicate,
                                 Value object)
Description copied from interface: ValueFactory
Creates a new statement with the supplied subject, predicate and object.

Parameters:
subject - The statement's subject.
predicate - The statement's predicate.
object - The statement's object.
Returns:
The created statement.

createStatement

public Statement createStatement(Resource subject,
                                 URI predicate,
                                 Value object,
                                 Resource context)
Description copied from interface: ValueFactory
Creates a new statement with the supplied subject, predicate and object and associated context.

Parameters:
subject - The statement's subject.
predicate - The statement's predicate.
object - The statement's object.
context - The statement's context.
Returns:
The created statement.

getNativeValue

public NativeValue getNativeValue(Value value)

getNativeResource

public NativeResource getNativeResource(Resource resource)

getNativeURI

public NativeURI getNativeURI(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(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(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.

main

public static void main(String[] args)
                 throws Exception
Throws:
Exception


Copyright © 2001-2008 Aduna. All Rights Reserved.