Class DataFile
java.lang.Object
org.eclipse.rdf4j.sail.nativerdf.datastore.DataFile
- All Implemented Interfaces:
Closeable
,AutoCloseable
Class supplying access to a data file. A data file stores data sequentially. Each entry starts with the entry's
length (4 bytes), followed by the data itself. File offsets are used to identify entries.
- Author:
- Arjohn Kampman
-
Nested Class Summary
Modifier and TypeClassDescriptionclass
An iterator that iterates over the data that is stored in a data file. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Discards all stored data.void
close()
Closes the data file, releasing any file locks that it might have.byte[]
getData
(long offset) Gets the data that is stored at the specified offset.getFile()
iterator()
Gets an iterator that can be used to iterate over all stored data.long
storeData
(byte[] data) Stores the specified data and returns the byte-offset at which it has been stored.void
sync()
Syncs any unstored data to the hash file.void
sync
(boolean force)
-
Constructor Details
-
DataFile
- Throws:
IOException
-
DataFile
- Throws:
IOException
-
-
Method Details
-
getFile
-
storeData
Stores the specified data and returns the byte-offset at which it has been stored.- Parameters:
data
- The data to store, must not be null.- Returns:
- The byte-offset in the file at which the data was stored.
- Throws:
IOException
-
getData
Gets the data that is stored at the specified offset.- Parameters:
offset
- An offset in the data file, must be larger than 0.- Returns:
- The data that was found on the specified offset.
- Throws:
IOException
- If an I/O error occurred.
-
clear
Discards all stored data.- Throws:
IOException
- If an I/O error occurred.
-
sync
-
sync
- Throws:
IOException
-
close
Closes the data file, releasing any file locks that it might have.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
iterator
Gets an iterator that can be used to iterate over all stored data.- Returns:
- a DataIterator.
-