Chunk

A chunk of data, containing one or multiple pages.

Chunks are page aligned (each page is usually 4096 bytes). There are at most 67 million (2^26) chunks, each chunk is at most 2 GB large.

Methods
static Chunk fromString(String s)
Build a block from the given string.
static Chunk fromString(String s)
Build a block from the given string.
Parameters:
s - the string
Returns:
the block
static String getMetaKey(int chunkId)
Get the metadata key for the given chunk id.
static String getMetaKey(int chunkId)
Get the metadata key for the given chunk id.
Parameters:
chunkId - the chunk id
Returns:
the metadata key
static Chunk readChunkHeader(ByteBuffer buff, long start)
Read the header from the byte buffer.
static Chunk readChunkHeader(ByteBuffer buff, long start)
Read the header from the byte buffer.
Parameters:
buff - the source buffer
start - the start of the chunk in the file
Returns:
the chunk
String asString()
Get the chunk data as a string.
String asString()
Get the chunk data as a string.
Returns:
the string
boolean equals(Object o)
boolean equals(Object o)
int getFillRate()
Calculate the fill rate in %.
int getFillRate()
Calculate the fill rate in %. 0 means empty, 100 means full.
Returns:
the fill rate
byte[] getFooterBytes()
byte[] getFooterBytes()
int hashCode()
int hashCode()
String toString()
String toString()
void writeChunkHeader(WriteBuffer buff, int minLength)
Write the chunk header.
void writeChunkHeader(WriteBuffer buff, int minLength)
Write the chunk header.
Parameters:
buff - the target buffer
minLength - the minimum length

Fields
static int FOOTER_LENGTH = 128
static int MAX_HEADER_LENGTH = 1024
static int MAX_ID = 67108863
static long block
static int collectPriority
static int id
static int len
static int mapId
static long maxLen
static long maxLenLive
static long metaRootPos
static long next
static int pageCount
static int pageCountLive
static long time
static long unused
static long version

MAX_HEADER_LENGTH = 1024

The maximum length of a chunk header, in bytes.

FOOTER_LENGTH = 128

The length of the chunk footer. The longest footer is: chunk:ffffffff,block:ffffffffffffffff, version:ffffffffffffffff,fletcher:ffffffff

MAX_ID = 67108863

The maximum chunk id.

block

The start block number within the file.

collectPriority

The garbage collection priority. Priority 0 means it needs to be collected, a high value means low priority.

id

The chunk id.

len

The length in number of blocks.

mapId

The last used map id.

maxLen

The sum of the max length of all pages.

maxLenLive

The sum of the max length of all pages that are in use.

metaRootPos

The position of the meta root.

next

The predicted position of the next chunk.

pageCount

The total number of pages in this chunk.

pageCountLive

The number of pages still alive.

time

When this chunk was created, in milliseconds after the store was created.

unused

When this chunk was no longer needed, in milliseconds after the store was created. After this, the chunk is kept alive a bit longer (in case it is referenced in older versions).

version

The version stored in this chunk.