index

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 19, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Intersect

func Intersect(a, b []int) []int

Intersect returns the sorted intersection of two sorted slices.

func Union

func Union(a, b []int) []int

Union returns the sorted union of two sorted slices.

Types

type HistogramBucket

type HistogramBucket struct {
	Start  time.Time
	End    time.Time
	Count  int
	Errors int // count of error/fatal in this bucket
}

HistogramBucket represents one bar in the time histogram.

type Index

type Index struct {
	Records []parser.Record

	TotalCount int
	// contains filtered or unexported fields
}

Index provides fast lookups over a set of parsed log records.

func Build

func Build(records []parser.Record) *Index

Build creates an index from a slice of records.

func (*Index) AddRecords added in v0.2.0

func (idx *Index) AddRecords(records []parser.Record)

AddRecords appends new records to the index incrementally.

func (*Index) AllIDs

func (idx *Index) AllIDs() []int

AllIDs returns all record indices.

func (*Index) Complement

func (idx *Index) Complement(ids []int) []int

Complement returns all IDs not in the given sorted slice.

func (*Index) FieldLookup

func (idx *Index) FieldLookup(field, value string) []int

FieldLookup returns record IDs where field has the given value.

func (*Index) FieldNames added in v0.6.0

func (idx *Index) FieldNames() []string

FieldNames returns all indexed field names, sorted alphabetically.

func (*Index) FieldValues added in v0.6.0

func (idx *Index) FieldValues(field string) []string

func (*Index) FullTextSearch

func (idx *Index) FullTextSearch(text string) []int

FullTextSearch scans all records for a substring match in any field value. Returns matching record IDs.

func (*Index) Histogram

func (idx *Index) Histogram(buckets int, ids []int) []HistogramBucket

Histogram returns bucketed counts for the time range of the given record IDs. If ids is nil, uses all records with timestamps.

func (*Index) NumericGreater

func (idx *Index) NumericGreater(field string, value float64) []int

NumericGreater returns record IDs where field > value.

func (*Index) NumericGreaterEqual

func (idx *Index) NumericGreaterEqual(field string, value float64) []int

NumericGreaterEqual returns record IDs where field >= value.

func (*Index) NumericLess

func (idx *Index) NumericLess(field string, value float64) []int

NumericLess returns record IDs where field < value.

func (*Index) NumericLessEqual

func (idx *Index) NumericLessEqual(field string, value float64) []int

NumericLessEqual returns record IDs where field <= value.

func (*Index) TimeAfter added in v0.4.0

func (idx *Index) TimeAfter(t time.Time) []int

TimeAfter returns record IDs where timestamp > t.

func (*Index) TimeAfterEqual added in v0.4.0

func (idx *Index) TimeAfterEqual(t time.Time) []int

TimeAfterEqual returns record IDs where timestamp >= t.

func (*Index) TimeBefore added in v0.4.0

func (idx *Index) TimeBefore(t time.Time) []int

TimeBefore returns record IDs where timestamp < t.

func (*Index) TimeBeforeEqual added in v0.4.0

func (idx *Index) TimeBeforeEqual(t time.Time) []int

TimeBeforeEqual returns record IDs where timestamp <= t.

func (*Index) TimeRange

func (idx *Index) TimeRange(start, end time.Time) []int

TimeRange returns record IDs within [start, end].

type NumericEntry

type NumericEntry struct {
	Value    float64
	RecordID int
}

NumericEntry holds a float64 value and the index of the record it belongs to.

type TimeEntry

type TimeEntry struct {
	Time     time.Time
	RecordID int
}

TimeEntry holds a timestamp and the index of the record it belongs to.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL