Documentation
¶
Index ¶
- Variables
- func Flush(dataDir string, series []SeriesFlush) (string, error)
- func FlushCompacted(dataDir string, series []SeriesFlush, level int, sources []string) (string, error)
- type BlockMeta
- type BlockStats
- type ChunkData
- type CompactionInfo
- type Reader
- func (r *Reader) AllPostings() []uint64
- func (r *Reader) ChunkIterator(ref index.ChunkRef) (chunkenc.ChunkIterator, error)
- func (r *Reader) Close() error
- func (r *Reader) Condemn()
- func (r *Reader) Dir() string
- func (r *Reader) LabelValues(name string) []string
- func (r *Reader) Labels(ref uint64) ([]labels.Label, bool)
- func (r *Reader) Postings(name, value string) []uint64
- func (r *Reader) RawChunkData(ref index.ChunkRef) ([]byte, error)
- func (r *Reader) Ref()
- func (r *Reader) Release() bool
- func (r *Reader) Series() []index.SeriesEntry
- func (r *Reader) SeriesByRef(ref uint64) (index.SeriesEntry, bool)
- func (r *Reader) SeriesChunkIterator(ref uint64, mint, maxt int64) (chunkenc.ChunkIterator, error)
- type SeriesFlush
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func Flush ¶
func Flush(dataDir string, series []SeriesFlush) (string, error)
Flush writes a new immutable block from the given series data. It creates a ULID-named directory under dataDir containing:
- chunks/ with segment files
- index file
- meta.json (written last as the immutability gate)
Returns the block ULID and any error.
func FlushCompacted ¶
func FlushCompacted(dataDir string, series []SeriesFlush, level int, sources []string) (string, error)
FlushCompacted writes a new immutable block from compacted series data, recording the compaction level and source block ULIDs.
Types ¶
type BlockMeta ¶
type BlockMeta struct {
ULID string `json:"ulid"`
MinTime int64 `json:"minTime"`
MaxTime int64 `json:"maxTime"`
Stats BlockStats `json:"stats"`
Compaction CompactionInfo `json:"compaction"`
Version int `json:"version"`
}
BlockMeta describes a block on disk.
type BlockStats ¶
type BlockStats struct {
NumSamples int `json:"numSamples"`
NumSeries int `json:"numSeries"`
NumChunks int `json:"numChunks"`
}
BlockStats holds summary statistics for a block.
type ChunkData ¶
type ChunkData struct {
MinT int64
MaxT int64
Data []byte // raw XOR chunk bytes (including 2-byte sample count header)
}
ChunkData describes a single chunk to be flushed to a block.
type CompactionInfo ¶
CompactionInfo records the block's compaction lineage.
type Reader ¶
type Reader struct {
Meta BlockMeta
// contains filtered or unexported fields
}
Reader provides read access to an immutable on-disk block.
func (*Reader) AllPostings ¶
AllPostings returns sorted refs for all series in the block.
func (*Reader) ChunkIterator ¶
ChunkIterator returns an iterator for a chunk at the given ref.
func (*Reader) Condemn ¶
func (r *Reader) Condemn()
Condemn marks the block for directory deletion when refcount reaches zero.
func (*Reader) LabelValues ¶
LabelValues returns sorted unique values for the given label name.
func (*Reader) RawChunkData ¶
RawChunkData returns the raw chunk bytes at the given ref (for compaction).
func (*Reader) Ref ¶
func (r *Reader) Ref()
Ref increments the refcount. Called by Querier on snapshot.
func (*Reader) Release ¶
Release decrements the refcount. Returns true if the refcount hit zero and the block is condemned (caller should delete the directory).
func (*Reader) Series ¶
func (r *Reader) Series() []index.SeriesEntry
Series returns all series entries from the index.
func (*Reader) SeriesByRef ¶
func (r *Reader) SeriesByRef(ref uint64) (index.SeriesEntry, bool)
SeriesByRef looks up a series by ref.
func (*Reader) SeriesChunkIterator ¶
SeriesChunkIterator returns an iterator over all chunks for a series in a time range. Chunks are iterated in order.
type SeriesFlush ¶
SeriesFlush describes a series with its sealed chunks for block writing.
type ValidationError ¶
type ValidationError struct {
Block string // ULID or directory name
Section string // "meta", "index", "chunks"
Detail string
}
ValidationError describes a single integrity issue found during validation.
func Validate ¶
func Validate(dir string) []ValidationError
Validate performs integrity checks on a single block directory. It checks meta.json consistency, index integrity (magic, version, TOC CRC), and CRC validation on every chunk entry.
func (ValidationError) Error ¶
func (e ValidationError) Error() string