Package com.hypixel.hytale.storage
Class IndexedStorageFile
java.lang.Object
com.hypixel.hytale.storage.IndexedStorageFile
- All Implemented Interfaces:
Closeable,AutoCloseable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classprotected class -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intprivate int(package private) static final IndexedStorageFile.OffsetHelperprivate static final ThreadLocal<ByteBuffer> static final intprivate intstatic final intstatic final intstatic final intstatic final StampedLock[]private final FileChannelstatic final intprivate booleanstatic final int(package private) static final IndexedStorageFile.OffsetHelperstatic final intprivate StampedLock[]private static final ByteBuffer(package private) static final byte[]static final intstatic final intstatic final Stringprivate MappedByteBufferstatic final MetricsRegistry<IndexedStorageFile> static final FileAttribute<?>[]private final Pathstatic final intprivate StampedLock[]private final StampedLockprivate intstatic final intstatic final intprivate final BitSetprivate final StampedLockprivate intstatic final intstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static ByteBufferallocateDirect(int length) voidclose()protected IndexedStorageFilecreate(int blobCount, int segmentSize) findFreeSegment(int count) voidforce(boolean metaData) intintgetPath()protected StampedLockgetSegmentLock(int segmentIndex) intprivate static ByteBuffergetTempBuffer(int length) it.unimi.dsi.fastutil.ints.IntListkeys()lock()protected voidprivate static IndexedStorageFilemigrateV0(Path path, int blobCount, int segmentSize, Set<? extends OpenOption> options, FileAttribute<?>[] attrs, IndexedStorageFile storageFile) static IndexedStorageFileopen(Path path, int blobCount, int segmentSize, OpenOption... options) static IndexedStorageFileopen(Path path, int blobCount, int segmentSize, Set<? extends OpenOption> options, FileAttribute<?>... attrs) static IndexedStorageFileopen(Path path, OpenOption... options) static IndexedStorageFileopen(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) protected intpositionToSegment(long position) readBlob(int blobIndex) voidreadBlob(int blobIndex, ByteBuffer dest) intreadBlobCompressedLength(int blobIndex) protected ByteBufferreadBlobHeader(int firstSegmentIndex) intreadBlobLength(int blobIndex) protected voidprotected ByteBufferreadSegments(int firstSegmentIndex, int compressedLength) protected voidvoidremoveBlob(int blobIndex) protected intrequiredSegments(long dataLength) intprotected longsegmentOffset(int segmentIndex) protected longsegmentPosition(int segmentIndex) protected longintvoidsetCompressionLevel(int compressionLevel) voidsetFlushOnWrite(boolean flushOnWrite) longsize()toString()voidwriteBlob(int blobIndex, ByteBuffer src) protected voidwriteHeader(int blobCount, int segmentSize) protected intwriteSegments(ByteBuffer data)
-
Field Details
-
EMPTY_STAMPED_LOCKS
-
METRICS_REGISTRY
-
MAGIC_STRING
- See Also:
-
VERSION
public static final int VERSION- See Also:
-
DEFAULT_BLOB_COUNT
public static final int DEFAULT_BLOB_COUNT- See Also:
-
DEFAULT_SEGMENT_SIZE
public static final int DEFAULT_SEGMENT_SIZE- See Also:
-
DEFAULT_COMPRESSION_LEVEL
public static final int DEFAULT_COMPRESSION_LEVEL- See Also:
-
HOH
-
MAGIC_LENGTH
public static final int MAGIC_LENGTH- See Also:
-
MAGIC_OFFSET
public static final int MAGIC_OFFSET -
VERSION_OFFSET
public static final int VERSION_OFFSET -
BLOB_COUNT_OFFSET
public static final int BLOB_COUNT_OFFSET -
SEGMENT_SIZE_OFFSET
public static final int SEGMENT_SIZE_OFFSET -
HEADER_LENGTH
public static final int HEADER_LENGTH -
BOH
-
SRC_LENGTH_OFFSET
public static final int SRC_LENGTH_OFFSET -
COMPRESSED_LENGTH_OFFSET
public static final int COMPRESSED_LENGTH_OFFSET -
BLOB_HEADER_LENGTH
public static final int BLOB_HEADER_LENGTH -
INDEX_SIZE
public static final int INDEX_SIZE- See Also:
-
UNASSIGNED_INDEX
public static final int UNASSIGNED_INDEX- See Also:
-
FIRST_SEGMENT_INDEX
public static final int FIRST_SEGMENT_INDEX- See Also:
-
NO_ATTRIBUTES
-
MAGIC_BYTES
static final byte[] MAGIC_BYTES -
MAGIC_BUFFER
-
CACHED_TEMP_BUFFER
-
path
-
fileChannel
-
flushOnWrite
private boolean flushOnWrite -
compressionLevel
private int compressionLevel -
version
private int version -
blobCount
private int blobCount -
segmentSize
private int segmentSize -
indexLocks
-
mappedBlobIndexes
-
segmentLocksLock
-
segmentLocks
-
usedSegmentsLock
-
usedSegments
-
-
Constructor Details
-
IndexedStorageFile
-
-
Method Details
-
getTempBuffer
-
allocateDirect
-
open
@Nonnull public static IndexedStorageFile open(@Nonnull Path path, OpenOption... options) throws IOException - Throws:
IOException
-
open
@Nonnull public static IndexedStorageFile open(@Nonnull Path path, @Nonnull Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException - Throws:
IOException
-
open
@Nonnull public static IndexedStorageFile open(@Nonnull Path path, int blobCount, int segmentSize, OpenOption... options) throws IOException - Throws:
IOException
-
open
@Nonnull public static IndexedStorageFile open(@Nonnull Path path, int blobCount, int segmentSize, @Nonnull Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException - Throws:
IOException
-
migrateV0
private static IndexedStorageFile migrateV0(Path path, int blobCount, int segmentSize, Set<? extends OpenOption> options, FileAttribute<?>[] attrs, IndexedStorageFile storageFile) throws IOException - Throws:
IOException
-
getPath
-
getBlobCount
public int getBlobCount() -
getSegmentSize
public int getSegmentSize() -
getCompressionLevel
public int getCompressionLevel() -
setFlushOnWrite
public void setFlushOnWrite(boolean flushOnWrite) -
setCompressionLevel
public void setCompressionLevel(int compressionLevel) -
create
- Throws:
IOException
-
writeHeader
- Throws:
IOException
-
readHeader
- Throws:
IOException
-
memoryMapBlobIndexes
- Throws:
IOException
-
readUsedSegments
- Throws:
IOException
-
size
- Throws:
IOException
-
segmentSize
public int segmentSize() -
segmentCount
public int segmentCount() -
keys
@Nonnull public it.unimi.dsi.fastutil.ints.IntList keys() -
readBlobLength
- Throws:
IOException
-
readBlobCompressedLength
- Throws:
IOException
-
readBlob
- Throws:
IOException
-
readBlob
- Throws:
IOException
-
readBlobHeader
- Throws:
IOException
-
readSegments
@Nonnull protected ByteBuffer readSegments(int firstSegmentIndex, int compressedLength) throws IOException - Throws:
IOException
-
writeBlob
- Throws:
IOException
-
removeBlob
- Throws:
IOException
-
writeSegments
- Throws:
IOException
-
findFreeSegment
-
getSegmentLock
-
segmentsBase
protected long segmentsBase() -
segmentOffset
protected long segmentOffset(int segmentIndex) -
segmentPosition
protected long segmentPosition(int segmentIndex) -
positionToSegment
protected int positionToSegment(long position) -
requiredSegments
protected int requiredSegments(long dataLength) -
lock
- Throws:
IOException
-
force
- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
toString
-