Class DataStore
- java.lang.Object
-
- org.eclipse.rdf4j.sail.nativerdf.datastore.DataStore
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class DataStore extends Object implements Closeable
Class that provides indexed storage and retrieval of arbitrary length data.- Author:
- Arjohn Kampman
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Removes all values from the DataStore.voidclose()Closes the DataStore, releasing any file references, etc.byte[]getData(int id)Gets the value for the specified ID.intgetID(byte[] queryData)Gets the ID for the specified value.intgetMaxID()Returns the maximum value-ID that is in use.static voidmain(String[] args)intstoreData(byte[] data)Stores the supplied value and returns the ID that has been assigned to it.voidsync()Synchronizes any recent changes to the data to disk.
-
-
-
Constructor Detail
-
DataStore
public DataStore(File dataDir, String filePrefix) throws IOException
- Throws:
IOException
-
DataStore
public DataStore(File dataDir, String filePrefix, boolean forceSync) throws IOException
- Throws:
IOException
-
-
Method Detail
-
getData
public byte[] getData(int id) throws IOExceptionGets the value for the specified ID.- Parameters:
id- A value ID, should be larger than 0.- Returns:
- The value for the ID, or null if no such value could be found.
- Throws:
IOException- If an I/O error occurred.
-
getID
public int getID(byte[] queryData) throws IOExceptionGets the ID for the specified value.- Parameters:
queryData- The value to get the ID for, must not be null.- Returns:
- The ID for the specified value, or -1 if no such ID could be found.
- Throws:
IOException- If an I/O error occurred.
-
getMaxID
public int getMaxID()
Returns the maximum value-ID that is in use.- Returns:
- The largest ID, or 0 if the store does not contain any values.
-
storeData
public int storeData(byte[] data) throws IOExceptionStores the supplied value and returns the ID that has been assigned to it. In case the data to store is already present, the ID of this existing data is returned.- Parameters:
data- The data to store, must not be null.- Returns:
- The ID that has been assigned to the value.
- Throws:
IOException- If an I/O error occurred.
-
sync
public void sync() throws IOExceptionSynchronizes any recent changes to the data to disk.- Throws:
IOException- If an I/O error occurred.
-
clear
public void clear() throws IOExceptionRemoves all values from the DataStore.- Throws:
IOException- If an I/O error occurred.
-
close
public void close() throws IOExceptionCloses the DataStore, releasing any file references, etc. In case a transaction is currently open, it will be rolled back. Once closed, the DataStore can no longer be used.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException- If an I/O error occurred.
-
-