Skip to main content

Module segment

Module segment 

Source
Expand description

Segment Cache โ€” scan-resistant cache for decoded Arrow arrays from segment files.

Caches decoded column data keyed by (SegmentId, row_group, column_name). Uses W-TinyLFU admission control with LRU eviction and a configurable memory bound. The frequency sketch (Count-Min Sketch) prevents sequential scan patterns from thrashing the cache by rejecting cold newcomers when they would evict hotter items.

Also features singleflight dedup (only one loader per cache key), O(1) eviction via an LRU linked list, and probabilistic promotion to minimise write-lock contention on the hot read path.

Structsยง

CacheLoadError
Error returned to waiter threads when a singleflight cache load fails.
SegmentCache
LRU segment cache with configurable memory bound.
SegmentCacheKey
Key for segment cache lookups.