Package com._1c.g5.v8.xmdb.impl
Class Volume
java.lang.Object
com._1c.g5.v8.xmdb.impl.Volume
Wrapper around file with databse
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected FileChannelprotected Fileprotected RandomAccessFileprotected final boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close volumestatic voidCopy file with all its contentsvoiddrop()Drop volume (close and delete from disc)bytegetByte(long offset) Read byte value from volumeintgetData(long offset, ByteBuffer bytes, int bytesPos, int size) Read data from volumegetFile()Get volume fileintgetInt(long offset) Read integer value from volumelonggetLong(long offset) Read long value from volumebooleanisEmpty()Test is volume empty (have zero size)longlength()Get length of volumevoidputByte(long offset, byte value) Put byte value into volumevoidputData(long offset, ByteBuffer buf) Write entire buffer into volumevoidputData(long offset, ByteBuffer[] bufs) Write entire buffers into volumevoidputData(long offset, ByteBuffer data, int size) Write data from byteBuffer into volumevoidputInt(long offset, int value) Put integer value into volumevoidputLong(long offset, long value) Put long value into volumevoidRename db file to specified namevoidreopen()Reopen previously closed volumevoidsync()Call sync command to write all cached data
-
Field Details
-
file
-
raf
-
readOnly
protected final boolean readOnly -
fc
-
-
Constructor Details
-
Volume
Volume constructor, open or create volume file- Parameters:
file- the file where volume should store (notnull)readOnly- open for read-onlytrueflag (otherwise open in read-write mode)
-
-
Method Details
-
renameTo
Rename db file to specified name- Parameters:
newName- the new name (notnull)
-
putData
Write data from byteBuffer into volume- Parameters:
offset- the offset in volume to wheredata- the buffer with data (reading from current bufer position) (notnull)size- the size of data to write
-
getData
Read data from volume- Parameters:
offset- the offset in volumebytes- the buffer to store readed data (notnull)bytesPos- the offset in buffer to store datasize- the size of data to read- Returns:
- the number of bytes read.
-
putData
Write entire buffer into volume- Parameters:
offset- the offset in volumebuf- buffer to write (notnull)
-
putData
Write entire buffers into volume- Parameters:
offset- the offset in volumebufs- the buffers to write (notnull)
-
copyFile
Copy file with all its contents- Parameters:
sourceFile- the source file (notnull)destFile- the destination file (notnull)
-
drop
public void drop()Drop volume (close and delete from disc) -
close
public void close()Close volume -
reopen
public void reopen()Reopen previously closed volume -
sync
public void sync()Call sync command to write all cached data -
isEmpty
public boolean isEmpty()Test is volume empty (have zero size)- Returns:
trueif volume is emptyfalseotherwise.
-
length
public long length()Get length of volume- Returns:
- the volume length in bytes
-
getFile
Get volume file- Returns:
- volume file
-
putLong
public void putLong(long offset, long value) Put long value into volume- Parameters:
offset- the offset in volume to writevalue- the value to write
-
getLong
public long getLong(long offset) Read long value from volume- Parameters:
offset- the offset in volume to read from- Returns:
- readed value
-
putInt
public void putInt(long offset, int value) Put integer value into volume- Parameters:
offset- the offset in volume to writevalue- the valut to write
-
getInt
public int getInt(long offset) Read integer value from volume- Parameters:
offset- the offset in volume to read from- Returns:
- readed value
-
putByte
public void putByte(long offset, byte value) Put byte value into volume- Parameters:
offset- the offset in volume to writevalue- the value to write
-
getByte
public byte getByte(long offset) Read byte value from volume- Parameters:
offset- the offset in volume to read from- Returns:
- readed value
-