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:
ValueFactory
File-based indexed storage and retrieval of RDF values. ValueStore maps RDF values to integer IDs and vice-versa.
- Author:
- Arjohn Kampman
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe default namespace cache size.static final intThe default namespace id cache size.static final intThe default value cache size.static final intThe default value id cache size. -
Constructor Summary
ConstructorsConstructorDescriptionValueStore(File dataDir) ValueStore(File dataDir, boolean forceSync) ValueStore(File dataDir, boolean forceSync, int valueCacheSize, int valueIDCacheSize, int namespaceCacheSize, int namespaceIDCacheSize) -
Method Summary
Modifier and TypeMethodDescriptionvoidChecks that every value has exactly one ID.voidclear()Removes all values from the ValueStore.voidclose()Closes the ValueStore, releasing any file references, etc.createBNode(String nodeID) Creates a new blank node with the given node identifier.Creates a new IRI from the supplied string-representation.Creates a new IRI from the supplied namespace and local name.createLiteral(String value) Creates a new literal with the supplied label.createLiteral(String value, String language) Creates a new literal with the supplied label and language attribute.createLiteral(String value, IRI datatype) Creates a new literal with the supplied label and datatype.intGets the ID for the specified value.<T extends NativeValue & IRI>
TgetIRI(int id) Gets the IRI for the specified ID.getNativeBNode(BNode bnode) Creates a NativeBNode that is equal to the supplied bnode.Creates an NativeLiteral that is equal to the supplied literal.getNativeResource(Resource resource) getNativeURI(IRI uri) Creates a NativeURI that is equal to the supplied URI.getNativeValue(Value value) Gets a read lock on this value store that can be used to prevent values from being removed while the lock is active.<T extends NativeValue & Resource>
TgetResource(int id) Gets the Resource for the specified ID.getValue(int id) Gets the value for the specified ID.static voidintstoreValue(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, getInstanceMethods inherited from class org.eclipse.rdf4j.model.base.AbstractValueFactory
createLiteral, createLiteral, createLiteral, createLiteral
-
Field Details
-
VALUE_CACHE_SIZE
public static final int VALUE_CACHE_SIZEThe default value cache size.- See Also:
-
VALUE_ID_CACHE_SIZE
public static final int VALUE_ID_CACHE_SIZEThe default value id cache size.- See Also:
-
NAMESPACE_CACHE_SIZE
public static final int NAMESPACE_CACHE_SIZEThe default namespace cache size.- See Also:
-
NAMESPACE_ID_CACHE_SIZE
public static final int NAMESPACE_ID_CACHE_SIZEThe default namespace id cache size.- See Also:
-
-
Constructor Details
-
ValueStore
- Throws:
IOException
-
ValueStore
- Throws:
IOException
-
ValueStore
public ValueStore(File dataDir, boolean forceSync, int valueCacheSize, int valueIDCacheSize, int namespaceCacheSize, int namespaceIDCacheSize) throws IOException - Throws:
IOException
-
-
Method Details
-
getRevision
-
getReadLock
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
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.
-
getResource
Gets the Resource for the specified ID.- Parameters:
id- A value ID.- Returns:
- The Resource for the ID, or null no such value could be found.
- Throws:
IOException- If an I/O error occurred.
-
getIRI
Gets the IRI for the specified ID.- Parameters:
id- A value ID.- Returns:
- The IRI for the ID, or null no such value could be found.
- Throws:
IOException- If an I/O error occurred.
-
getID
Gets 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
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
Removes all values from the ValueStore.- Throws:
IOException- If an I/O error occurred.
-
sync
Synchronizes any changes that are cached in memory to disk.- Throws:
IOException- If an I/O error occurred.
-
close
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.
-
checkConsistency
Checks that every value has exactly one ID.- Throws:
IOExceptionSailException
-
createIRI
Description copied from interface:ValueFactoryCreates a new IRI from the supplied string-representation.- Specified by:
createIRIin interfaceValueFactory- Overrides:
createIRIin classSimpleValueFactory- Parameters:
uri- A string-representation of a IRI.- Returns:
- An object representing the IRI.
-
createIRI
Description copied from interface:ValueFactoryCreates a new IRI from the supplied namespace and local name. Calling this method is funtionally equivalent to callingcreateIRI(namespace+localName), but allows the ValueFactory to reuse supplied namespace and local name strings whenever possible. Note that the values returned byIRI.getNamespace()andIRI.getLocalName()are not necessarily the same as the values that are supplied to this method.- Specified by:
createIRIin interfaceValueFactory- Overrides:
createIRIin classSimpleValueFactory- Parameters:
namespace- The IRI's namespace.localName- The IRI's local name.
-
createBNode
Description copied from interface:ValueFactoryCreates a new blank node with the given node identifier.- Specified by:
createBNodein interfaceValueFactory- Overrides:
createBNodein classSimpleValueFactory- Parameters:
nodeID- The blank node identifier.- Returns:
- An object representing the blank node.
-
createLiteral
Description copied from interface:ValueFactoryCreates a new literal with the supplied label. The return value ofLiteral.getDatatype()for the returned object must bexsd:string.- Specified by:
createLiteralin interfaceValueFactory- Overrides:
createLiteralin classSimpleValueFactory- Parameters:
value- The literal's label, must not be null.- Returns:
- A literal for the specified value.
-
createLiteral
Description copied from interface:ValueFactoryCreates a new literal with the supplied label and language attribute. The return value ofLiteral.getDatatype()for the returned object must berdf:langString.- Specified by:
createLiteralin interfaceValueFactory- Overrides:
createLiteralin classSimpleValueFactory- Parameters:
value- The literal's label, must not be null.language- The literal's language attribute, must not be null.- Returns:
- A literal for the specified value and language attribute.
-
createLiteral
Description copied from interface:ValueFactoryCreates a new literal with the supplied label and datatype.- Specified by:
createLiteralin interfaceValueFactory- Overrides:
createLiteralin classSimpleValueFactory- Parameters:
value- The literal's label, must not be null.datatype- The literal's datatype. If it is null, the datatypexsd:stringwill be assigned to this literal.- Returns:
- A literal for the specified value and type.
-
getNativeValue
-
getNativeResource
-
getNativeURI
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
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
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
- Throws:
Exception
-