org.eclipse.rdf4j.sail.nativerdf.datastore

## Class IDFile

- java.lang.Object
- - org.eclipse.rdf4j.sail.nativerdf.datastore.IDFile

- All Implemented Interfaces:
    Closeable, AutoCloseable

      public class IDFile
      extends Object
      implements Closeable

  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.
  Author:
    Arjohn Kampman

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `IDFile(File file)`
    `IDFile(File file, boolean forceSync)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clear()` Discards all stored data.
    `void` | `close()` Closes the ID file, releasing any file locks that it might have.
    `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.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### IDFile

          public IDFile(File file)
                 throws IOException

      Throws:
        `IOException`

    - #### IDFile

          public IDFile(File file,
                        boolean forceSync)
                 throws IOException

      Throws:
        `IOException`

  - ### Method Detail

    - #### getFile

          public final File getFile()

    - #### getMaxID

          public int getMaxID()
                       throws IOException

      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.
      Throws:
        `IOException` - If an I/O error occurs.

    - #### storeOffset

          public int storeOffset(long offset)
                          throws IOException

      Stores the offset of a new data entry, returning the ID under which is stored.
      Throws:
        `IOException`

    - #### setOffset

          public void setOffset(int id,
                                long offset)
                         throws IOException

      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

          public long getOffset(int id)
                         throws IOException

      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

          public void clear()
                     throws IOException

      Discards all stored data.
      Throws:
        `IOException` - If an I/O error occurred.

    - #### sync

          public void sync()
                    throws IOException

      Syncs any unstored data to the hash file.
      Throws:
        `IOException`

    - #### close

          public void close()
                     throws IOException

      Closes the ID file, releasing any file locks that it might have.
      Specified by:
        `close` in interface `Closeable`
      Specified by:
        `close` in interface `AutoCloseable`
      Throws:
        `IOException`

Copyright © 2015-2020 Eclipse Foundation. All Rights Reserved.