Class RAMDataAccess

java.lang.Object
com.graphhopper.storage.AbstractDataAccess
com.graphhopper.storage.RAMDataAccess
All Implemented Interfaces:
DataAccess, Closeable, AutoCloseable

public class RAMDataAccess extends AbstractDataAccess
This is an in-memory byte-based data structure with the possibility to be stored on flush(). Read thread-safe.

Author:
Peter Karich
  • Method Details

    • store

      public RAMDataAccess store(boolean store)
      Parameters:
      store - true if in-memory data should be saved when calling flush
    • isStoring

      public boolean isStoring()
      Overrides:
      isStoring in class AbstractDataAccess
    • create

      public RAMDataAccess create(long bytes)
      Description copied from interface: DataAccess
      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.
    • ensureCapacity

      public boolean ensureCapacity(long bytes)
      Description copied from interface: DataAccess
      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:
    • loadExisting

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

      public void flush()
      Description copied from interface: DataAccess
      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.
    • setInt

      public final void setInt(long bytePos, int value)
      Description copied from interface: DataAccess
      Set 4 bytes at position 'bytePos' to the specified value
    • getInt

      public final int getInt(long bytePos)
      Description copied from interface: DataAccess
      Get 4 bytes from position 'bytePos'
    • setShort

      public final void setShort(long bytePos, short value)
      Description copied from interface: DataAccess
      Set 2 bytes at position 'index' to the specified value
    • getShort

      public final short getShort(long bytePos)
      Description copied from interface: DataAccess
      Get 2 bytes from position 'index'
    • setBytes

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

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

      public final void setByte(long bytePos, byte value)
    • getByte

      public final byte getByte(long bytePos)
    • close

      public void close()
      Description copied from interface: DataAccess
      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
      Specified by:
      close in interface DataAccess
      Overrides:
      close in class AbstractDataAccess
    • getCapacity

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

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

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