Class TableDiskAccess

java.lang.Object
org.basex.io.random.TableAccess
org.basex.io.random.TableDiskAccess

public final class TableDiskAccess extends TableAccess
This class stores the table on disk and reads it page-wise.
Author:
BaseX Team 2005-21, BSD License, Christian Gruen, Tim Petrowsky
  • Constructor Summary

    Constructors
    Constructor
    Description
    TableDiskAccess(MetaData meta, boolean write)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Closes the table access.
    protected void
    copy(byte[] entries, int pre, int last)
    Copies the specified values into the database.
    void
    delete(int pre, int count)
    Deletes the specified number of entries from the database.
    protected void
    Marks the data structures as dirty.
    void
    flush(boolean all)
    Flushes the table contents.
    void
    insert(int pre, byte[] entries)
    Inserts the specified entries into the database.
    boolean
    lock(boolean write)
    Tries to acquires a lock on the table.
    static boolean
    locked(String db, Context ctx)
    Checks if the table of the specified database is locked.
    int
    read1(int pre, int offset)
    Reads a byte value and returns it as an integer value.
    int
    read2(int pre, int offset)
    Reads a short value and returns it as an integer value.
    int
    read4(int pre, int offset)
    Reads an integer value.
    long
    read5(int pre, int offset)
    Reads a 5-byte value and returns it as a long value.
     
    void
    write1(int pre, int offset, int value)
    Writes a byte value to the specified position.
    void
    write2(int pre, int offset, int value)
    Writes a short value to the specified position.
    void
    write4(int pre, int offset, int value)
    Writes an integer value to the specified position.
    void
    write5(int pre, int offset, long value)
    Writes a 5-byte value to the specified position.

    Methods inherited from class org.basex.io.random.TableAccess

    replace

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • TableDiskAccess

      public TableDiskAccess(MetaData meta, boolean write) throws IOException
      Constructor.
      Parameters:
      meta - meta data
      write - write lock
      Throws:
      IOException - I/O exception
  • Method Details

    • locked

      public static boolean locked(String db, Context ctx)
      Checks if the table of the specified database is locked.
      Parameters:
      db - name of database
      ctx - database context
      Returns:
      result of check
    • flush

      public void flush(boolean all) throws IOException
      Description copied from class: TableAccess
      Flushes the table contents.
      Specified by:
      flush in class TableAccess
      Parameters:
      all - flush all contents or only buffers
      Throws:
      IOException - I/O exception
    • close

      public void close() throws IOException
      Description copied from class: TableAccess
      Closes the table access.
      Specified by:
      close in class TableAccess
      Throws:
      IOException - I/O exception
    • lock

      public boolean lock(boolean write)
      Description copied from class: TableAccess
      Tries to acquires a lock on the table. If a lock exists, it is first released.
      Specified by:
      lock in class TableAccess
      Parameters:
      write - write/read lock
      Returns:
      success flag
    • read1

      public int read1(int pre, int offset)
      Description copied from class: TableAccess
      Reads a byte value and returns it as an integer value.
      Specified by:
      read1 in class TableAccess
      Parameters:
      pre - pre value
      offset - offset
      Returns:
      integer value
    • read2

      public int read2(int pre, int offset)
      Description copied from class: TableAccess
      Reads a short value and returns it as an integer value.
      Specified by:
      read2 in class TableAccess
      Parameters:
      pre - pre value
      offset - offset
      Returns:
      integer value
    • read4

      public int read4(int pre, int offset)
      Description copied from class: TableAccess
      Reads an integer value.
      Specified by:
      read4 in class TableAccess
      Parameters:
      pre - pre value
      offset - offset
      Returns:
      integer value
    • read5

      public long read5(int pre, int offset)
      Description copied from class: TableAccess
      Reads a 5-byte value and returns it as a long value.
      Specified by:
      read5 in class TableAccess
      Parameters:
      pre - pre value
      offset - offset
      Returns:
      integer value
    • write1

      public void write1(int pre, int offset, int value)
      Description copied from class: TableAccess
      Writes a byte value to the specified position.
      Specified by:
      write1 in class TableAccess
      Parameters:
      pre - pre value
      offset - offset
      value - value to be written
    • write2

      public void write2(int pre, int offset, int value)
      Description copied from class: TableAccess
      Writes a short value to the specified position.
      Specified by:
      write2 in class TableAccess
      Parameters:
      pre - pre value
      offset - offset
      value - value to be written
    • write4

      public void write4(int pre, int offset, int value)
      Description copied from class: TableAccess
      Writes an integer value to the specified position.
      Specified by:
      write4 in class TableAccess
      Parameters:
      pre - pre value
      offset - offset
      value - value to be written
    • write5

      public void write5(int pre, int offset, long value)
      Description copied from class: TableAccess
      Writes a 5-byte value to the specified position.
      Specified by:
      write5 in class TableAccess
      Parameters:
      pre - pre value
      offset - offset
      value - value to be written
    • copy

      protected void copy(byte[] entries, int pre, int last)
      Description copied from class: TableAccess
      Copies the specified values into the database.
      Specified by:
      copy in class TableAccess
      Parameters:
      entries - entries to copy
      pre - first target pre value
      last - last pre value
    • delete

      public void delete(int pre, int count)
      Description copied from class: TableAccess
      Deletes the specified number of entries from the database.
      Specified by:
      delete in class TableAccess
      Parameters:
      pre - pre value of the first node to delete
      count - number of entries to be deleted
    • insert

      public void insert(int pre, byte[] entries)
      Description copied from class: TableAccess
      Inserts the specified entries into the database.
      Specified by:
      insert in class TableAccess
      Parameters:
      pre - pre value
      entries - array of bytes containing the entries to insert
    • dirty

      protected void dirty()
      Description copied from class: TableAccess
      Marks the data structures as dirty.
      Specified by:
      dirty in class TableAccess
    • toString

      public String toString()
      Overrides:
      toString in class Object