org.mapdb
Class Volume.ByteBufferVol

java.lang.Object
  extended by org.mapdb.Volume
      extended by org.mapdb.Volume.ByteBufferVol
Direct Known Subclasses:
Volume.MappedFileVol, Volume.MemoryVol
Enclosing class:
Volume

public abstract static class Volume.ByteBufferVol
extends Volume

Abstract Volume over bunch of ByteBuffers It leaves ByteBufferVol details (allocation, disposal) on subclasses. Most methods are final for better performance (JIT compiler can inline those).


Nested Class Summary
 
Nested classes/interfaces inherited from class org.mapdb.Volume
Volume.ByteBufferVol, Volume.Factory, Volume.FileChannelVol, Volume.MappedFileVol, Volume.MemoryVol
 
Field Summary
protected  ByteBuffer[] chunks
           
protected  int chunkShift
           
protected  int chunkSize
           
protected  int chunkSizeModMask
           
protected  ReentrantLock growLock
           
protected  boolean hasLimit
           
protected  boolean readOnly
           
protected  long sizeLimit
           
 
Constructor Summary
protected Volume.ByteBufferVol(boolean readOnly, long sizeLimit, int chunkShift)
           
 
Method Summary
 byte getByte(long offset)
           
 DataInput2 getDataInput(long offset, int size)
           
 int getInt(long offset)
           
 long getLong(long offset)
           
 boolean isEmpty()
           
 boolean isSliced()
           
protected abstract  ByteBuffer makeNewBuffer(long offset)
           
 void putByte(long offset, byte value)
           
 void putData(long offset, byte[] src, int srcPos, int srcSize)
           
 void putData(long offset, ByteBuffer buf)
           
 void putInt(long offset, int value)
           
 void putLong(long offset, long value)
           
 boolean tryAvailable(long offset)
           
protected  void unmap(MappedByteBuffer b)
          Hack to unmap MappedByteBuffer.
 
Methods inherited from class org.mapdb.Volume
close, deleteFile, ensureAvailable, fileFactory, fileFactory, getFile, getPackedLong, getSixLong, getUnsignedByte, getUnsignedShort, memoryFactory, putPackedLong, putSixLong, putUnsignedByte, putUnsignedShort, sync, truncate, volumeForFile, volumeTransfer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

growLock

protected final ReentrantLock growLock

sizeLimit

protected final long sizeLimit

hasLimit

protected final boolean hasLimit

chunkShift

protected final int chunkShift

chunkSizeModMask

protected final int chunkSizeModMask

chunkSize

protected final int chunkSize

chunks

protected volatile ByteBuffer[] chunks

readOnly

protected final boolean readOnly
Constructor Detail

Volume.ByteBufferVol

protected Volume.ByteBufferVol(boolean readOnly,
                               long sizeLimit,
                               int chunkShift)
Method Detail

tryAvailable

public final boolean tryAvailable(long offset)
Specified by:
tryAvailable in class Volume

makeNewBuffer

protected abstract ByteBuffer makeNewBuffer(long offset)

putLong

public final void putLong(long offset,
                          long value)
Specified by:
putLong in class Volume

putInt

public final void putInt(long offset,
                         int value)
Specified by:
putInt in class Volume

putByte

public final void putByte(long offset,
                          byte value)
Specified by:
putByte in class Volume

putData

public void putData(long offset,
                    byte[] src,
                    int srcPos,
                    int srcSize)
Specified by:
putData in class Volume

putData

public final void putData(long offset,
                          ByteBuffer buf)
Specified by:
putData in class Volume

getLong

public final long getLong(long offset)
Specified by:
getLong in class Volume

getInt

public final int getInt(long offset)
Specified by:
getInt in class Volume

getByte

public final byte getByte(long offset)
Specified by:
getByte in class Volume

getDataInput

public final DataInput2 getDataInput(long offset,
                                     int size)
Specified by:
getDataInput in class Volume

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in class Volume

isSliced

public boolean isSliced()
Specified by:
isSliced in class Volume

unmap

protected void unmap(MappedByteBuffer b)
Hack to unmap MappedByteBuffer. Unmap is necessary on Windows, otherwise file is locked until JVM exits or BB is GCed. There is no public JVM API to unmap buffer, so this tries to use SUN proprietary API for unmap. Any error is silently ignored (for example SUN API does not exist on Android).



Copyright © 2014. All Rights Reserved.