Immutable blocks with mmap reads
Flush sealed head chunks to ULID-named block directories on disk. Each block contains CRC'd chunk segment files (mmap'd for reads), a binary index (symbol table, series, postings with TOC), and a meta.json written last as the immutability gate. WAL is truncated after block fsync, preserving the crash-safety ording invariant.
This commit is contained in:
@@ -28,6 +28,15 @@ func NewXORChunk() *XORChunk {
|
||||
return &XORChunk{b: bstream{stream: make([]byte, 2), count: 0}}
|
||||
}
|
||||
|
||||
// XORChunkFromBytes creates a read-only XORChunk from raw bytes.
|
||||
// The data must include the 2-byte sample count header (as returned by Bytes).
|
||||
// The returned chunk supports Iterator, NumSamples, and Bytes but not Appender.
|
||||
func XORChunkFromBytes(data []byte) *XORChunk {
|
||||
cp := make([]byte, len(data))
|
||||
copy(cp, data)
|
||||
return &XORChunk{b: bstream{stream: cp}}
|
||||
}
|
||||
|
||||
func (c *XORChunk) NumSamples() int {
|
||||
return int(binary.BigEndian.Uint16(c.b.bytes()))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user