Class IDFile
java.lang.Object
org.eclipse.rdf4j.sail.nativerdf.datastore.IDFile
- All Implemented Interfaces:
Closeable
,AutoCloseable
Class supplying access to an ID file. An ID file maps IDs (integers >= 1) to file pointers (long integers). There
is a direct correlation between IDs and the position at which the file pointers are stored; the file pointer for ID X
is stored at position 8*X.
This class supports parallel reads but not parallel writes.
- Author:
- Arjohn Kampman
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Discards all stored data.void
void
close()
Closes the ID file, releasing any file locks that it might have.final File
getFile()
int
getMaxID()
Gets the largest ID that is stored in this ID file.long
getOffset
(int id) Gets the offset of the data entry with the specified ID.void
setOffset
(int id, long offset) Sets or updates the stored offset for the specified ID.int
storeOffset
(long offset) Stores the offset of a new data entry, returning the ID under which is stored.void
sync()
Syncs any unstored data to the hash file.void
sync
(boolean force)
-
Constructor Details
-
IDFile
- Throws:
IOException
-
IDFile
- Throws:
IOException
-
-
Method Details
-
getFile
-
getMaxID
public int getMaxID()Gets the largest ID that is stored in this ID file.- Returns:
- The largest ID, or 0 if the file does not contain any data.
-
storeOffset
Stores the offset of a new data entry, returning the ID under which is stored.- Throws:
IOException
-
setOffset
Sets or updates the stored offset for the specified ID.- Parameters:
id
- The ID to set the offset for, must be larger than 0.offset
- The (new) offset for the specified ID.- Throws:
IOException
-
getOffset
Gets the offset of the data entry with the specified ID.- Parameters:
id
- The ID to get the offset for, must be larger than 0.- Returns:
- The offset for the ID.
- Throws:
IOException
-
clear
Discards all stored data.- Throws:
IOException
- If an I/O error occurred.
-
sync
-
sync
- Throws:
IOException
-
close
Closes the ID file, releasing any file locks that it might have.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
clearCache
public void clearCache()
-