Class DataFile
java.lang.Object
org.eclipse.rdf4j.sail.nativerdf.datastore.DataFile
- All Implemented Interfaces:
Closeable, AutoCloseable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassAn iterator that iterates over the data that is stored in a data file. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Discards all stored data.voidclose()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()longReturns the current file size (after flushing any pending writes).longgetFreeMemory(Runtime rt) iterator()Gets an iterator that can be used to iterate over all stored data.longstoreData(byte[] data) Stores the specified data and returns the byte-offset at which it has been stored.voidsync()Syncs any unstored data to the hash file.voidsync(boolean force) byte[]tryRecoverBetweenOffsets(long startOffset, long endOffset) Attempts to recover data bytes between two known entry offsets when the length field atstartOffsetis corrupt (e.g., zero).
-
Field Details
-
LARGE_READ_THRESHOLD_PROPERTY
- See Also:
-
LARGE_READ_THRESHOLD
public static final int LARGE_READ_THRESHOLD
-
-
Constructor Details
-
DataFile
- Throws:
IOException
-
DataFile
- Throws:
IOException
-
-
Method Details
-
getFile
-
getFileSize
Returns the current file size (after flushing any pending writes).- Throws:
IOException
-
tryRecoverBetweenOffsets
Attempts to recover data bytes between two known entry offsets when the length field atstartOffsetis corrupt (e.g., zero). This returns up toendOffset - startOffset - 4bytes starting after the length field, capped to a reasonable maximum to avoid large allocations.- Throws:
IOException
-
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.
-
getFreeMemory
-
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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
iterator
Gets an iterator that can be used to iterate over all stored data.- Returns:
- a DataIterator.
-