gomemindex

package module
v0.0.0-...-2a8b813 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package gomemindexer - simple versioned, deduplicated in-memory index library.

Goals:

  • Generic, type-safe field indexes (equality + range + time as-of)
  • Versioned objects with per-object fine-grained locking
  • Interning (dedup) table for repeated values
  • Top-level Indexer to register fields and operate on objects
  • Designed for real-time updates (e.g., stream consumer) and concurrent queries

NOTE: This is a focused demo-quality library designed to be extended.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddToIndex

func AddToIndex[T any, V constraints.Ordered](idx *Indexer[T], field string, value V, objectID string, ts time.Time)

func Intersect

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

----------------------------- Simple set helpers -----------------------------

func QueryEquals

func QueryEquals[T any, V constraints.Ordered](idx *Indexer[T], field string, value V, asOf *time.Time) []string

func QueryRange

func QueryRange[T any, V constraints.Ordered](idx *Indexer[T], field string, min, max V, asOf *time.Time) []string

func RegisterField

func RegisterField[T any, V constraints.Ordered](idx *Indexer[T], name string)

----------------------------- Generic functions for field operations -----------------------------

func Union

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

Types

type FieldIndex

type FieldIndex[T constraints.Ordered] struct {
	// contains filtered or unexported fields
}

FieldIndex requires T to be ordered for range queries

func NewFieldIndex

func NewFieldIndex[T constraints.Ordered]() *FieldIndex[T]

func (*FieldIndex[T]) Add

func (fi *FieldIndex[T]) Add(value T, objectID string, ts time.Time)

func (*FieldIndex[T]) Get

func (fi *FieldIndex[T]) Get(value T, asOf *time.Time) []string

func (*FieldIndex[T]) Range

func (fi *FieldIndex[T]) Range(min, max T, asOf *time.Time) []string

type Indexer

type Indexer[T any] struct {
	Intern *InternTable
	// contains filtered or unexported fields
}

----------------------------- Indexer: top-level API -----------------------------

func NewIndexer

func NewIndexer[T any]() *Indexer[T]

func (*Indexer[T]) AddVersion

func (idx *Indexer[T]) AddVersion(objectID string, ts time.Time, obj *T)

----------------------------- Non-generic methods remain -----------------------------

func (*Indexer[T]) AsOf

func (idx *Indexer[T]) AsOf(objectID string, asOf time.Time) (*T, bool)

func (*Indexer[T]) Latest

func (idx *Indexer[T]) Latest(objectID string) (*T, bool)

type InternTable

type InternTable struct {
	// contains filtered or unexported fields
}

----------------------------- InternTable: deduplicate & intern values -----------------------------

func NewInternTable

func NewInternTable() *InternTable

func (*InternTable) Get

func (it *InternTable) Get(hash string) (*string, bool)

func (*InternTable) Intern

func (it *InternTable) Intern(hash, val string) *string

type VersionedObject

type VersionedObject[T any] struct {
	Timestamp time.Time
	Data      *T
}

----------------------------- VersionedStore: per-object version slices with per-object locking -----------------------------

type VersionedStore

type VersionedStore[T any] struct {
	// contains filtered or unexported fields
}

func NewVersionedStore

func NewVersionedStore[T any]() *VersionedStore[T]

func (*VersionedStore[T]) Add

func (vs *VersionedStore[T]) Add(objectID string, ts time.Time, data *T)

func (*VersionedStore[T]) AsOf

func (vs *VersionedStore[T]) AsOf(objectID string, asOf time.Time) (*T, bool)

func (*VersionedStore[T]) Latest

func (vs *VersionedStore[T]) Latest(objectID string) (*T, bool)

func (*VersionedStore[T]) ObjectIDs

func (vs *VersionedStore[T]) ObjectIDs() []string

Jump to

Keyboard shortcuts

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