Package org.eclipse.rdf4j.sail.nativerdf
Class ValueStore
- java.lang.Object
-
- org.eclipse.rdf4j.model.base.AbstractValueFactory
-
- org.eclipse.rdf4j.model.impl.SimpleValueFactory
-
- org.eclipse.rdf4j.sail.nativerdf.ValueStore
-
- All Implemented Interfaces:
org.eclipse.rdf4j.model.ValueFactory
@InternalUseOnly public class ValueStore extends SimpleValueFactory
File-based indexed storage and retrieval of RDF values. ValueStore maps RDF values to integer IDs and vice-versa.- Author:
- Arjohn Kampman
-
-
Field Summary
Fields Modifier and Type Field Description static intNAMESPACE_CACHE_SIZEThe default namespace cache size.static intNAMESPACE_ID_CACHE_SIZEThe default namespace id cache size.static intVALUE_CACHE_SIZEThe default value cache size.static intVALUE_ID_CACHE_SIZEThe default value id cache size.
-
Constructor Summary
Constructors Constructor Description ValueStore(File dataDir)ValueStore(File dataDir, boolean forceSync)ValueStore(File dataDir, boolean forceSync, int valueCacheSize, int valueIDCacheSize, int namespaceCacheSize, int namespaceIDCacheSize)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckConsistency()Checks that every value has exactly one ID.voidclear()Removes all values from the ValueStore.voidclose()Closes the ValueStore, releasing any file references, etc.NativeBNodecreateBNode(String nodeID)NativeIRIcreateIRI(String uri)NativeIRIcreateIRI(String namespace, String localName)NativeLiteralcreateLiteral(String value)NativeLiteralcreateLiteral(String value, String language)NativeLiteralcreateLiteral(String value, org.eclipse.rdf4j.model.IRI datatype)intgetID(org.eclipse.rdf4j.model.Value value)Gets the ID for the specified value.NativeBNodegetNativeBNode(org.eclipse.rdf4j.model.BNode bnode)Creates a NativeBNode that is equal to the supplied bnode.NativeLiteralgetNativeLiteral(org.eclipse.rdf4j.model.Literal l)Creates an NativeLiteral that is equal to the supplied literal.NativeResourcegetNativeResource(org.eclipse.rdf4j.model.Resource resource)NativeIRIgetNativeURI(org.eclipse.rdf4j.model.IRI uri)Creates a NativeURI that is equal to the supplied URI.NativeValuegetNativeValue(org.eclipse.rdf4j.model.Value value)org.eclipse.rdf4j.common.concurrent.locks.LockgetReadLock()Gets a read lock on this value store that can be used to prevent values from being removed while the lock is active.ValueStoreRevisiongetRevision()NativeValuegetValue(int id)Gets the value for the specified ID.static voidmain(String[] args)intstoreValue(org.eclipse.rdf4j.model.Value value)Stores the supplied value and returns the ID that has been assigned to it.voidsync()Synchronizes any changes that are cached in memory to disk.-
Methods inherited from class org.eclipse.rdf4j.model.impl.SimpleValueFactory
createBNode, createFPLiteral, createFPLiteral, createIntegerLiteral, createIntegerLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createNumericLiteral, createNumericLiteral, createStatement, createStatement, createTriple, getInstance
-
-
-
-
Field Detail
-
VALUE_CACHE_SIZE
public static final int VALUE_CACHE_SIZE
The default value cache size.- See Also:
- Constant Field Values
-
VALUE_ID_CACHE_SIZE
public static final int VALUE_ID_CACHE_SIZE
The default value id cache size.- See Also:
- Constant Field Values
-
NAMESPACE_CACHE_SIZE
public static final int NAMESPACE_CACHE_SIZE
The default namespace cache size.- See Also:
- Constant Field Values
-
NAMESPACE_ID_CACHE_SIZE
public static final int NAMESPACE_ID_CACHE_SIZE
The default namespace id cache size.- 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) throws IOException
- Throws:
IOException
-
-
Method Detail
-
getRevision
public ValueStoreRevision getRevision()
-
getReadLock
public org.eclipse.rdf4j.common.concurrent.locks.Lock getReadLock() throws InterruptedExceptionGets 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.eclipse.rdf4j.model.Value value) throws IOExceptionGets the ID for the specified value.- Parameters:
value- A value.- Returns:
- The ID for the specified value, or
NativeValue.UNKNOWN_IDif no such ID could be found. - Throws:
IOException- If an I/O error occurred.
-
storeValue
public int storeValue(org.eclipse.rdf4j.model.Value value) throws IOExceptionStores 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 IOExceptionRemoves all values from the ValueStore.- Throws:
IOException- If an I/O error occurred.
-
sync
public void sync() throws IOExceptionSynchronizes any changes that are cached in memory to disk.- Throws:
IOException- If an I/O error occurred.
-
close
public void close() throws IOExceptionCloses the ValueStore, releasing any file references, etc. Once closed, the ValueStore can no longer be used.- Throws:
IOException- If an I/O error occurred.
-
checkConsistency
public void checkConsistency() throws SailException, IOExceptionChecks that every value has exactly one ID.- Throws:
IOExceptionSailException
-
createIRI
public NativeIRI createIRI(String uri)
- Specified by:
createIRIin interfaceorg.eclipse.rdf4j.model.ValueFactory- Overrides:
createIRIin classSimpleValueFactory
-
createIRI
public NativeIRI createIRI(String namespace, String localName)
- Specified by:
createIRIin interfaceorg.eclipse.rdf4j.model.ValueFactory- Overrides:
createIRIin classSimpleValueFactory
-
createBNode
public NativeBNode createBNode(String nodeID)
- Specified by:
createBNodein interfaceorg.eclipse.rdf4j.model.ValueFactory- Overrides:
createBNodein classSimpleValueFactory
-
createLiteral
public NativeLiteral createLiteral(String value)
- Specified by:
createLiteralin interfaceorg.eclipse.rdf4j.model.ValueFactory- Overrides:
createLiteralin classSimpleValueFactory
-
createLiteral
public NativeLiteral createLiteral(String value, String language)
- Specified by:
createLiteralin interfaceorg.eclipse.rdf4j.model.ValueFactory- Overrides:
createLiteralin classSimpleValueFactory
-
createLiteral
public NativeLiteral createLiteral(String value, org.eclipse.rdf4j.model.IRI datatype)
- Specified by:
createLiteralin interfaceorg.eclipse.rdf4j.model.ValueFactory- Overrides:
createLiteralin classSimpleValueFactory
-
getNativeValue
public NativeValue getNativeValue(org.eclipse.rdf4j.model.Value value)
-
getNativeResource
public NativeResource getNativeResource(org.eclipse.rdf4j.model.Resource resource)
-
getNativeURI
public NativeIRI getNativeURI(org.eclipse.rdf4j.model.IRI 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.eclipse.rdf4j.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.eclipse.rdf4j.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.
-
-