Documentation
¶
Index ¶
- Constants
- type ChunkState
- type LineStore
- func (s *LineStore) Append(l *line.LogLine)
- func (s *LineStore) ApplyOffloadResults()
- func (s *LineStore) ChunkCount() int
- func (s *LineStore) ChunkStateAt(ci int) ChunkState
- func (s *LineStore) Close()
- func (s *LineStore) DiskUsed() int64
- func (s *LineStore) Get(i int) *line.LogLine
- func (s *LineStore) IsHiddenGroupMember(i int) bool
- func (s *LineStore) Len() int
- func (s *LineStore) PrefetchAdjacent(cursor int)
- func (s *LineStore) RequestPrefetch(ci int)
- func (s *LineStore) RunOffloadCycle(cursor, offset, viewportH int)
- func (s *LineStore) Search(query string, startIdx int) int
- func (s *LineStore) SearchReverse(query string, startIdx int) int
- func (s *LineStore) Stub(i int) line.LineStub
- func (s *LineStore) UpdateStub(i int)
- func (s *LineStore) WaitOffloadsForTest()
Constants ¶
const ChunkSize = 8192
ChunkSize is the number of lines per chunk.
const DefaultDiskCap int64 = 1 << 30
DefaultDiskCap is the maximum disk usage for offloaded chunks (1 GB).
const OffloadThreshold = 50000
OffloadThreshold is the minimum total line count before offloading begins.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChunkState ¶
type ChunkState int
ChunkState tracks whether a chunk is in memory, on disk, or evicted.
const ( ChunkHot ChunkState = iota // in memory ChunkOffloading // queued for async disk write (still in memory) ChunkCold // serialized to disk, loadable ChunkEvicted // disk file deleted, data lost )
type LineStore ¶
type LineStore struct {
// contains filtered or unexported fields
}
LineStore manages log line storage with lightweight stubs always in memory. Lines are organized into fixed-size chunks. Each chunk can be independently offloaded to disk and reloaded on demand.
func NewFromSlice ¶
NewFromSlice creates a LineStore pre-populated from an existing slice. Used for benchmarks and tests that construct models directly.
func NewWithDiskCap ¶
NewWithDiskCap creates an empty LineStore with a custom disk cap.
func (*LineStore) ApplyOffloadResults ¶
func (s *LineStore) ApplyOffloadResults()
ApplyOffloadResults drains completion messages from the worker and flips their chunks from Offloading to Cold (or back to Hot on write error). Caller must hold the store's external synchronization (e.g. s.mu in sharedState) because this mutates c.state, c.lines, c.diskPath, diskUsed — fields read by other goroutines under the same lock.
func (*LineStore) ChunkCount ¶
ChunkCount returns the number of chunks.
func (*LineStore) ChunkStateAt ¶
func (s *LineStore) ChunkStateAt(ci int) ChunkState
ChunkStateAt returns the state of chunk ci.
func (*LineStore) Close ¶
func (s *LineStore) Close()
Close releases resources: stops the prefetch goroutine and removes temp files. Safe to call multiple times.
func (*LineStore) Get ¶
Get returns the LogLine at index i. If the chunk is cold, it loads it from disk first. If evicted, returns a placeholder.
func (*LineStore) IsHiddenGroupMember ¶
IsHiddenGroupMember returns true if line i is a non-head member of a multiline JSON group. Uses only stub data (no I/O).
func (*LineStore) PrefetchAdjacent ¶
PrefetchAdjacent pre-loads chunks adjacent to the cursor zone. Call after cursor movement to reduce latency when scrolling into cold regions.
func (*LineStore) RequestPrefetch ¶
RequestPrefetch asks the background goroutine to load a chunk. Non-blocking: if the prefetch channel is full, the request is dropped.
func (*LineStore) RunOffloadCycle ¶
RunOffloadCycle evaluates which chunks should be offloaded or reloaded based on the current cursor position and viewport. Only runs when the total line count exceeds OffloadThreshold.
Offloads are queued asynchronously — the actual serialize + WriteFile happens on the background worker goroutine (see offloadLoop), so the caller isn't blocked on disk I/O. Completions are applied via ApplyOffloadResults on the next cycle.
func (*LineStore) Search ¶
Search finds the next line containing query (case-insensitive) starting from startIdx, wrapping around. For hot chunks, searches in memory. For cold chunks, loads them from disk temporarily. Evicted chunks are skipped.
func (*LineStore) SearchReverse ¶
SearchReverse finds the previous line containing query starting from startIdx.
func (*LineStore) UpdateStub ¶
UpdateStub re-syncs the stub for line i from the actual LogLine data. Call after in-place mutations (e.g., parser multiline JSON detection, expand/collapse).
func (*LineStore) WaitOffloadsForTest ¶
func (s *LineStore) WaitOffloadsForTest()
WaitOffloadsForTest blocks until all queued offloads have been written by the worker, then applies their results. For use in tests that need deterministic "chunk is Cold now" behavior after RunOffloadCycle.