Class TableAccess

java.lang.Object
org.basex.io.random.TableAccess
Direct Known Subclasses:
TableDiskAccess, TableMemAccess

public abstract class TableAccess extends Object
This abstract class defines the methods for accessing the database table representation.
Author:
BaseX Team 2005-21, BSD License, Christian Gruen
  • Method Summary

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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • flush

      public abstract void flush(boolean all) throws IOException
      Flushes the table contents.
      Parameters:
      all - flush all contents or only buffers
      Throws:
      IOException - I/O exception
    • close

      public abstract void close() throws IOException
      Closes the table access.
      Throws:
      IOException - I/O exception
    • lock

      public abstract boolean lock(boolean write)
      Tries to acquires a lock on the table. If a lock exists, it is first released.
      Parameters:
      write - write/read lock
      Returns:
      success flag
    • read1

      public abstract int read1(int pre, int offset)
      Reads a byte value and returns it as an integer value.
      Parameters:
      pre - pre value
      offset - offset
      Returns:
      integer value
    • read2

      public abstract int read2(int pre, int offset)
      Reads a short value and returns it as an integer value.
      Parameters:
      pre - pre value
      offset - offset
      Returns:
      integer value
    • read4

      public abstract int read4(int pre, int offset)
      Reads an integer value.
      Parameters:
      pre - pre value
      offset - offset
      Returns:
      integer value
    • read5

      public abstract long read5(int pre, int offset)
      Reads a 5-byte value and returns it as a long value.
      Parameters:
      pre - pre value
      offset - offset
      Returns:
      integer value
    • write1

      public abstract void write1(int pre, int offset, int value)
      Writes a byte value to the specified position.
      Parameters:
      pre - pre value
      offset - offset
      value - value to be written
    • write2

      public abstract void write2(int pre, int offset, int value)
      Writes a short value to the specified position.
      Parameters:
      pre - pre value
      offset - offset
      value - value to be written
    • write4

      public abstract void write4(int pre, int offset, int value)
      Writes an integer value to the specified position.
      Parameters:
      pre - pre value
      offset - offset
      value - value to be written
    • write5

      public abstract void write5(int pre, int offset, long value)
      Writes a 5-byte value to the specified position.
      Parameters:
      pre - pre value
      offset - offset
      value - value to be written
    • replace

      public final void replace(int pre, byte[] entries, int count)
      Replaces entries in the database.
      Parameters:
      pre - node to be replaced
      entries - new entries
      count - number of entries to be replaced
    • dirty

      protected abstract void dirty()
      Marks the data structures as dirty.
    • copy

      protected abstract void copy(byte[] entries, int pre, int last)
      Copies the specified values into the database.
      Parameters:
      entries - entries to copy
      pre - first target pre value
      last - last pre value
    • delete

      public abstract void delete(int pre, int count)
      Deletes the specified number of entries from the database.
      Parameters:
      pre - pre value of the first node to delete
      count - number of entries to be deleted
    • insert

      public abstract void insert(int pre, byte[] entries)
      Inserts the specified entries into the database.
      Parameters:
      pre - pre value
      entries - array of bytes containing the entries to insert