IndexedStorageFile

public class IndexedStorageFile implements Closeable

Class IndexedStorageFile. Provides indexedstoragefile functionality for the Hytale server.

java.lang.Object > IndexedStorageFile

Field Summary

flushOnWrite

private boolean flushOnWrite

Field flushOnWrite.

compressionLevel

private int compressionLevel

Field compressionLevel.

version

private int version

Field version.

blobCount

private int blobCount

Field blobCount.

segmentSize

private int segmentSize

Field segmentSize.

indexLocks

private StampedLock[] indexLocks

Field indexLocks.

mappedBlobIndexes

private MappedByteBuffer mappedBlobIndexes

Field mappedBlobIndexes.

segmentLocks

private StampedLock[] segmentLocks

Field segmentLocks.

buffer

final ByteBuffer buffer

Field buffer.

tempFile

final Path tempFile

Field tempFile.

tempPath

final Path tempPath

Field tempPath.

newOptions

final HashSet newOptions

Field newOptions.

blob

final ByteBuffer blob

Field blob.

header

final ByteBuffer header

Field header.

dst

final byte[] dst

Field dst.

stamp

final long stamp

Field stamp.

indexPos

final int indexPos

Field indexPos.

segmentStamp

final long segmentStamp

Field segmentStamp.

blobHeaderBuffer

final ByteBuffer blobHeaderBuffer

Field blobHeaderBuffer.

segmentsCount

final int segmentsCount

Field segmentsCount.

count

final int count

Field count.

list

final IntArrayList list

Field list.

lock

final StampedLock lock

Field lock.

segmentIndex

final int segmentIndex

Field segmentIndex.

firstSegmentIndex

final int firstSegmentIndex

Field firstSegmentIndex.

compressedLength

final int compressedLength

Field compressedLength.

tempDest

final ByteBuffer tempDest

Field tempDest.

segmentPosition

final long segmentPosition

Field segmentPosition.

srcLength

final int srcLength

Field srcLength.

maxCompressedLength

final int maxCompressedLength

Field maxCompressedLength.

dest

final ByteBuffer dest

Field dest.

tempSrc

final ByteBuffer tempSrc

Field tempSrc.

oldFirstSegmentIndex

final int oldFirstSegmentIndex

Field oldFirstSegmentIndex.

oldCompressedLength

final int oldCompressedLength

Field oldCompressedLength.

usedSegmentsStamp

final long usedSegmentsStamp

Field usedSegmentsStamp.

oldSegmentLength

final int oldSegmentLength

Field oldSegmentLength.

dataRemaining

final int dataRemaining

Field dataRemaining.

segmentLock

final SegmentRangeWriteLock segmentLock

Field segmentLock.

stamps

final long[] stamps

Field stamps.

indexesStamp

final long indexesStamp

Field indexesStamp.

newLength

final int newLength

Field newLength.

newArray

final StampedLock[] newArray

Field newArray.

segmentOffset

final long segmentOffset

Field segmentOffset.

index

private int index

Field index.

cur

final int cur

Field cur.

Method Detail

getTempBuffer

static ByteBuffer getTempBuffer (final int length)

Method getTempBuffer.

Parameters:
final int length

allocateDirect

static ByteBuffer allocateDirect (final int length)

Method allocateDirect.

Parameters:
final int length

open

static IndexedStorageFile open (@Nonnull final Path path, final OpenOption... options)

Method open.

Parameters:
@Nonnull final Path path
final OpenOption... options

IndexedStorageFile

public new IndexedStorageFile (path, FileChannel.open(path, options, attrs)

Method IndexedStorageFile.

Parameters:
path path
FileChannel.open(path FileChannel.open(path
options options
attrs attrs

migrateV0

static IndexedStorageFile migrateV0 (final Path path, final int blobCount, final int segmentSize, final Set options, final FileAttribute[] attrs, IndexedStorageFile storageFile)

Method migrateV0.

Parameters:
final Path path
final int blobCount
final int segmentSize
final Set options
final FileAttribute[] attrs
IndexedStorageFile storageFile

IndexedStorageFile_v0

public new IndexedStorageFile_v0 (tempPath, FileChannel.open(tempPath, options, attrs)

Method IndexedStorageFile_v0.

Parameters:
tempPath tempPath
FileChannel.open(tempPath FileChannel.open(tempPath
options options
attrs attrs

getPath

public Path getPath ()

Method getPath.

getBlobCount

public int getBlobCount ()

Method getBlobCount.

getSegmentSize

public int getSegmentSize ()

Method getSegmentSize.

getCompressionLevel

public int getCompressionLevel ()

Method getCompressionLevel.

setFlushOnWrite

public void setFlushOnWrite (final boolean flushOnWrite)

Method setFlushOnWrite.

Parameters:
final boolean flushOnWrite

setCompressionLevel

public void setCompressionLevel (final int compressionLevel)

Method setCompressionLevel.

Parameters:
final int compressionLevel

create

protected IndexedStorageFile create (final int blobCount, final int segmentSize)

Method create.

Parameters:
final int blobCount
final int segmentSize

writeHeader

protected void writeHeader (final int blobCount, final int segmentSize)

Method writeHeader.

Parameters:
final int blobCount
final int segmentSize

readHeader

protected void readHeader ()

Method readHeader.

memoryMapBlobIndexes

protected void memoryMapBlobIndexes ()

Method memoryMapBlobIndexes.

readUsedSegments

protected void readUsedSegments ()

Method readUsedSegments.

size

public long size ()

Method size.

segmentSize

public int segmentSize ()

Method segmentSize.

segmentCount

public int segmentCount ()

Method segmentCount.

keys

public IntList keys ()

Method keys.

readBlobLength

public int readBlobLength (final int blobIndex)

Method readBlobLength.

Parameters:
final int blobIndex

readBlobCompressedLength

public int readBlobCompressedLength (final int blobIndex)

Method readBlobCompressedLength.

Parameters:
final int blobIndex

readBlob

public ByteBuffer readBlob (final int blobIndex)

Method readBlob.

Parameters:
final int blobIndex

readBlobHeader

protected ByteBuffer readBlobHeader (final int firstSegmentIndex)

Method readBlobHeader.

Parameters:
final int firstSegmentIndex

readSegments

protected ByteBuffer readSegments (final int firstSegmentIndex, final int compressedLength)

Method readSegments.

Parameters:
final int firstSegmentIndex
final int compressedLength

writeBlob

public void writeBlob (final int blobIndex, @Nonnull final ByteBuffer src)

Method writeBlob.

Parameters:
final int blobIndex
@Nonnull final ByteBuffer src

removeBlob

public void removeBlob (final int blobIndex)

Method removeBlob.

Parameters:
final int blobIndex

writeSegments

protected int writeSegments (@Nonnull final ByteBuffer data)

Method writeSegments.

Parameters:
@Nonnull final ByteBuffer data

findFreeSegment

private SegmentRangeWriteLock findFreeSegment (final int count)

Method findFreeSegment.

Parameters:
final int count

getSegmentLock

protected StampedLock getSegmentLock (final int segmentIndex)

Method getSegmentLock.

Parameters:
final int segmentIndex

segmentsBase

protected long segmentsBase ()

Method segmentsBase.

segmentOffset

protected long segmentOffset (final int segmentIndex)

Method segmentOffset.

Parameters:
final int segmentIndex

segmentPosition

protected long segmentPosition (final int segmentIndex)

Method segmentPosition.

Parameters:
final int segmentIndex

positionToSegment

protected int positionToSegment (final long position)

Method positionToSegment.

Parameters:
final long position

requiredSegments

protected int requiredSegments (final long dataLength)

Method requiredSegments.

Parameters:
final long dataLength

lock

public FileLock lock ()

Method lock.

force

public void force (final boolean metaData)

Method force.

Parameters:
final boolean metaData

close

public void close ()

Method close.

toString

public String toString ()

Method toString.

length

public int length ()

Method length.

unlock

protected void unlock ()

Method unlock.