Interface DataAccess

All Superinterfaces:
AutoCloseable, Closeable
All Known Implementing Classes:
AbstractDataAccess, MMapDataAccess, RAMDataAccess

public interface DataAccess extends Closeable
Life cycle: (1) object creation, (2) configuration (e.g. segment size), (3) create or loadExisting, (4) usage and calling ensureCapacity if necessary, (5) close
Author:
Peter Karich
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    This method makes sure that the underlying used resources are released.
    create(long bytes)
    The first time you use a DataAccess object after configuring it you need to call this method.
    boolean
    ensureCapacity(long bytes)
    Ensures that the capacity of this object is at least the specified bytes.
    void
    This method makes sure that the underlying data is written to the storage.
    byte
    getByte(long currentPointer)
     
    void
    getBytes(long bytePos, byte[] values, int length)
    Get bytes from position 'index'
    long
     
    int
    getHeader(int bytePos)
    Get 4 bytes from the header at 'index'
    int
    getInt(long bytePos)
    Get 4 bytes from position 'bytePos'
    The logical identification of this object.
    int
     
    int
     
    short
    getShort(long bytePos)
    Get 2 bytes from position 'index'
     
    boolean
     
    boolean
     
    void
    setByte(long currentPointer, byte value)
     
    void
    setBytes(long bytePos, byte[] values, int length)
    Set bytes from position 'index' to the specified values
    void
    setHeader(int bytePos, int value)
    Set 4 bytes at the header space index to the specified value
    void
    setInt(long bytePos, int value)
    Set 4 bytes at position 'bytePos' to the specified value
    void
    setShort(long bytePos, short value)
    Set 2 bytes at position 'index' to the specified value
  • Method Details

    • getName

      String getName()
      The logical identification of this object.
    • setInt

      void setInt(long bytePos, int value)
      Set 4 bytes at position 'bytePos' to the specified value
    • getInt

      int getInt(long bytePos)
      Get 4 bytes from position 'bytePos'
    • setShort

      void setShort(long bytePos, short value)
      Set 2 bytes at position 'index' to the specified value
    • getShort

      short getShort(long bytePos)
      Get 2 bytes from position 'index'
    • setBytes

      void setBytes(long bytePos, byte[] values, int length)
      Set bytes from position 'index' to the specified values
    • getBytes

      void getBytes(long bytePos, byte[] values, int length)
      Get bytes from position 'index'
      Parameters:
      values - acts as output
    • setByte

      void setByte(long currentPointer, byte value)
    • getByte

      byte getByte(long currentPointer)
    • setHeader

      void setHeader(int bytePos, int value)
      Set 4 bytes at the header space index to the specified value
    • getHeader

      int getHeader(int bytePos)
      Get 4 bytes from the header at 'index'
    • create

      DataAccess create(long bytes)
      The first time you use a DataAccess object after configuring it you need to call this method. After that first call you have to use ensureCapacity to ensure that enough space is reserved.
    • flush

      void flush()
      This method makes sure that the underlying data is written to the storage. Keep in mind that a disc normally has an IO cache so that flush() is (less) probably not save against power loses.
    • close

      void close()
      This method makes sure that the underlying used resources are released. WARNING: it does NOT flush on close!
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • isClosed

      boolean isClosed()
    • loadExisting

      boolean loadExisting()
      Returns:
      true if successfully loaded from persistent storage.
    • getCapacity

      long getCapacity()
      Returns:
      the allocated storage size in bytes
    • ensureCapacity

      boolean ensureCapacity(long bytes)
      Ensures that the capacity of this object is at least the specified bytes. The first time you have to call 'create' instead.

      Returns:
      true if size was increased
      See Also:
    • getSegmentSize

      int getSegmentSize()
      Returns:
      the size of one segment in bytes
    • getSegments

      int getSegments()
      Returns:
      the number of segments.
    • getType

      DAType getType()
      Returns:
      the data access type of this object.