org.mapdb
Class Volume

java.lang.Object
  extended by org.mapdb.Volume
Direct Known Subclasses:
Volume.ByteBufferVol, Volume.FileChannelVol

public abstract class Volume
extends Object

MapDB abstraction over raw storage (file, disk partition, memory etc...).

Implementations needs to be thread safe (especially 'ensureAvailable') operation. However updates do not have to be atomic, it is clients responsibility to ensure two threads are not writing/reading into the same location.

Author:
Jan Kotek

Nested Class Summary
static class Volume.ByteBufferVol
          Abstract Volume over bunch of ByteBuffers It leaves ByteBufferVol details (allocation, disposal) on subclasses.
static interface Volume.Factory
          Factory which creates two/three volumes used by each MapDB Storage Engine
static class Volume.FileChannelVol
          Volume which uses FileChannel.
static class Volume.MappedFileVol
           
static class Volume.MemoryVol
           
 
Constructor Summary
Volume()
           
 
Method Summary
abstract  void close()
           
abstract  void deleteFile()
           
 void ensureAvailable(long offset)
          Check space allocated by Volume is bigger or equal to given offset.
static Volume.Factory fileFactory(File indexFile, int rafMode, boolean readOnly, long sizeLimit, int chunkShift, int sizeIncrement)
           
static Volume.Factory fileFactory(File indexFile, int rafMode, boolean readOnly, long sizeLimit, int chunkShift, int sizeIncrement, File physFile, File transLogFile)
           
abstract  byte getByte(long offset)
           
abstract  DataInput getDataInput(long offset, int size)
           
abstract  File getFile()
          returns underlying file if it exists
abstract  int getInt(long offset)
           
abstract  long getLong(long offset)
           
 long getPackedLong(long pos)
           
 long getSixLong(long pos)
          Reads a long from the indicated position
 int getUnsignedByte(long offset)
           
 int getUnsignedShort(long offset)
           
abstract  boolean isEmpty()
           
abstract  boolean isSliced()
           
static Volume.Factory memoryFactory(boolean useDirectBuffer, long sizeLimit, int chunkShift)
           
abstract  void putByte(long offset, byte value)
           
abstract  void putData(long offset, byte[] src, int srcPos, int srcSize)
           
abstract  void putData(long offset, ByteBuffer buf)
           
abstract  void putInt(long offset, int value)
           
abstract  void putLong(long offset, long value)
           
 int putPackedLong(long pos, long value)
          Writes packed long at given position and returns number of bytes used.
 void putSixLong(long pos, long value)
          Writes a long to the indicated position
 void putUnsignedByte(long offset, int b)
           
 void putUnsignedShort(long offset, int value)
           
abstract  void sync()
           
abstract  void truncate(long size)
           
abstract  boolean tryAvailable(long offset)
           
static Volume volumeForFile(File f, boolean useRandomAccessFile, boolean readOnly, long sizeLimit, int chunkShift, int sizeIncrement)
           
static void volumeTransfer(long size, Volume from, Volume to)
          transfer data from one volume to second.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Volume

public Volume()
Method Detail

ensureAvailable

public void ensureAvailable(long offset)
Check space allocated by Volume is bigger or equal to given offset. So it is safe to write into smaller offsets.

Parameters:
offset -
Throws:
IOError - if Volume can not be expanded beyond given offset

tryAvailable

public abstract boolean tryAvailable(long offset)

truncate

public abstract void truncate(long size)

putLong

public abstract void putLong(long offset,
                             long value)

putInt

public abstract void putInt(long offset,
                            int value)

putByte

public abstract void putByte(long offset,
                             byte value)

putData

public abstract void putData(long offset,
                             byte[] src,
                             int srcPos,
                             int srcSize)

putData

public abstract void putData(long offset,
                             ByteBuffer buf)

getLong

public abstract long getLong(long offset)

getInt

public abstract int getInt(long offset)

getByte

public abstract byte getByte(long offset)

getDataInput

public abstract DataInput getDataInput(long offset,
                                       int size)

close

public abstract void close()

sync

public abstract void sync()

isEmpty

public abstract boolean isEmpty()

deleteFile

public abstract void deleteFile()

isSliced

public abstract boolean isSliced()

putUnsignedShort

public void putUnsignedShort(long offset,
                             int value)

getUnsignedShort

public int getUnsignedShort(long offset)

getUnsignedByte

public int getUnsignedByte(long offset)

putUnsignedByte

public void putUnsignedByte(long offset,
                            int b)

getSixLong

public long getSixLong(long pos)
Reads a long from the indicated position


putSixLong

public void putSixLong(long pos,
                       long value)
Writes a long to the indicated position


putPackedLong

public int putPackedLong(long pos,
                         long value)
Writes packed long at given position and returns number of bytes used.


getFile

public abstract File getFile()
returns underlying file if it exists


getPackedLong

public long getPackedLong(long pos)

volumeForFile

public static Volume volumeForFile(File f,
                                   boolean useRandomAccessFile,
                                   boolean readOnly,
                                   long sizeLimit,
                                   int chunkShift,
                                   int sizeIncrement)

fileFactory

public static Volume.Factory fileFactory(File indexFile,
                                         int rafMode,
                                         boolean readOnly,
                                         long sizeLimit,
                                         int chunkShift,
                                         int sizeIncrement)

fileFactory

public static Volume.Factory fileFactory(File indexFile,
                                         int rafMode,
                                         boolean readOnly,
                                         long sizeLimit,
                                         int chunkShift,
                                         int sizeIncrement,
                                         File physFile,
                                         File transLogFile)

memoryFactory

public static Volume.Factory memoryFactory(boolean useDirectBuffer,
                                           long sizeLimit,
                                           int chunkShift)

volumeTransfer

public static void volumeTransfer(long size,
                                  Volume from,
                                  Volume to)
transfer data from one volume to second. Second volume will be expanded if needed



Copyright © 2014. All Rights Reserved.