org.mapdb
Class Volume.FileChannelVol

java.lang.Object
  extended by org.mapdb.Volume
      extended by org.mapdb.Volume.FileChannelVol
Enclosing class:
Volume

public static final class Volume.FileChannelVol
extends Volume

Volume which uses FileChannel. Uses global lock and does not use mapped memory.


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  FileChannel channel
           
protected  int chunkSize
           
protected  File file
           
protected  Object growLock
           
protected  boolean hasLimit
           
protected  RandomAccessFile raf
           
protected  boolean readOnly
           
protected  long size
           
protected  long sizeLimit
           
 
Constructor Summary
Volume.FileChannelVol(File file, boolean readOnly, long sizeLimit, int chunkShift, int sizeIncrement)
           
 
Method Summary
protected static void checkFolder(File file, boolean readOnly)
           
 void close()
           
 void deleteFile()
           
 byte getByte(long offset)
           
 DataInput2 getDataInput(long offset, int size)
           
 File getFile()
          returns underlying file if it exists
 int getInt(long offset)
           
 long getLong(long offset)
           
 long getSixLong(long offset)
          Reads a long from the indicated position
 boolean isEmpty()
           
 boolean isSliced()
           
 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)
           
 void putSixLong(long offset, long value)
          Writes a long to the indicated position
protected  void readFully(long offset, ByteBuffer buf)
           
 void sync()
           
 void truncate(long size)
           
 boolean tryAvailable(long offset)
           
protected  void writeFully(long offset, ByteBuffer buf)
           
 
Methods inherited from class org.mapdb.Volume
ensureAvailable, fileFactory, fileFactory, getPackedLong, getUnsignedByte, getUnsignedShort, memoryFactory, putPackedLong, putUnsignedByte, putUnsignedShort, volumeForFile, volumeTransfer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

file

protected final File file

chunkSize

protected final int chunkSize

raf

protected RandomAccessFile raf

channel

protected FileChannel channel

readOnly

protected final boolean readOnly

sizeLimit

protected final long sizeLimit

hasLimit

protected final boolean hasLimit

size

protected volatile long size

growLock

protected final Object growLock
Constructor Detail

Volume.FileChannelVol

public Volume.FileChannelVol(File file,
                             boolean readOnly,
                             long sizeLimit,
                             int chunkShift,
                             int sizeIncrement)
Method Detail

checkFolder

protected static void checkFolder(File file,
                                  boolean readOnly)
                           throws IOException
Throws:
IOException

tryAvailable

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

truncate

public void truncate(long size)
Specified by:
truncate in class Volume

writeFully

protected void writeFully(long offset,
                          ByteBuffer buf)
                   throws IOException
Throws:
IOException

putSixLong

public final void putSixLong(long offset,
                             long value)
Description copied from class: Volume
Writes a long to the indicated position

Overrides:
putSixLong in class Volume

putLong

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

putInt

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

putByte

public 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 void putData(long offset,
                    ByteBuffer buf)
Specified by:
putData in class Volume

readFully

protected void readFully(long offset,
                         ByteBuffer buf)
                  throws IOException
Throws:
IOException

getSixLong

public final long getSixLong(long offset)
Description copied from class: Volume
Reads a long from the indicated position

Overrides:
getSixLong in class Volume

getLong

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

getInt

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

getByte

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

getDataInput

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

close

public void close()
Specified by:
close in class Volume

sync

public void sync()
Specified by:
sync in class Volume

isEmpty

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

deleteFile

public void deleteFile()
Specified by:
deleteFile in class Volume

isSliced

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

getFile

public File getFile()
Description copied from class: Volume
returns underlying file if it exists

Specified by:
getFile in class Volume


Copyright © 2014. All Rights Reserved.