Documentation
¶
Overview ¶
internal/chunkstore/store.go
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Stats ¶
type Stats struct {
TotalChunks uint64 // Total chunks processed
UniqueChunks uint64 // Unique chunks stored
DedupedChunks uint64 // Chunks that were deduplicated
BytesSaved uint64 // Bytes saved through deduplication
Evictions uint64 // Chunks evicted from store due to capacity limit
}
Stats contains deduplication statistics
func (Stats) DedupRatio ¶
DedupRatio returns the deduplication ratio as a percentage
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store maintains a thread-safe map of chunks for deduplication with bounded capacity
func NewStoreWithCapacity ¶
NewStoreWithCapacity creates a chunk store with a maximum capacity maxChunks: maximum number of chunks to keep (0 = unlimited)
func (*Store) All ¶
All returns all chunks ever seen (including evicted ones) This is critical: evicted chunks are removed from s.chunks but their metadata (hash, offset, sizes) must be preserved for the archive index
func (*Store) GetOrAdd ¶
func (s *Store) GetOrAdd(hash [32]byte, origSize uint64, writeFunc func() (offset uint64, comprSize uint64, err error)) (ChunkInfo, bool, error)
GetOrAdd checks if a chunk exists, and if not, calls writeFunc to store it Returns (ChunkInfo, isNew, error) If isNew=false, the chunk was deduplicated