prefixcacheindexer

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPrefixHashTableSyncable added in v0.7.0

func NewPrefixHashTableSyncable(table *PrefixHashTable) syncable.Syncable

NewPrefixHashTableSyncable returns a Syncable for the given table. Register it with statesync.Manager. EncodeBlockForSync supports optional write-through; default integration uses periodic delta sync only.

Types

type Block

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

type LPRadixCache

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

func NewLPRadixCache

func NewLPRadixCache(numPods int) *LPRadixCache

func (*LPRadixCache) AddPrefix

func (c *LPRadixCache) AddPrefix(tokens []int, model string, podName string) (*TreeNode, []int, []int)

func (*LPRadixCache) Evict

func (c *LPRadixCache) Evict(now time.Time) []*TreeNode

func (*LPRadixCache) GetAllNodes

func (c *LPRadixCache) GetAllNodes() map[int]*TreeNode

GetAllNodes returns a snapshot copy of the internal node map. Callers can safely iterate the returned map without holding any lock.

func (*LPRadixCache) GetAllPodsInNode

func (c *LPRadixCache) GetAllPodsInNode(node *TreeNode) []string

func (*LPRadixCache) GetNode

func (c *LPRadixCache) GetNode(tokens []int) *TreeNode

GetNode adds internal method to get node

func (*LPRadixCache) MatchPrefix

func (c *LPRadixCache) MatchPrefix(inputTokens []int, model string, pods []*v1.Pod) ([]int, []int, []*v1.Pod)

func (*LPRadixCache) MatchPrefixNodeReadOnly added in v0.7.0

func (c *LPRadixCache) MatchPrefixNodeReadOnly(inputTokens []int) (*TreeNode, []int)

func (*LPRadixCache) NewTreeNode

func (c *LPRadixCache) NewTreeNode(numPods int, parent *TreeNode, key []int, value []int) *TreeNode

func (*LPRadixCache) PrettyPrint

func (c *LPRadixCache) PrettyPrint()

type PrefixHashTable

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

func GetSharedPrefixHashTable added in v0.6.0

func GetSharedPrefixHashTable() *PrefixHashTable

func NewPrefixHashTable

func NewPrefixHashTable() *PrefixHashTable

func (*PrefixHashTable) AddPrefix

func (c *PrefixHashTable) AddPrefix(prefixHashes []uint64, model, pod string)

AddPrefix add prefix hashes for input tokens

func (*PrefixHashTable) ApplyRemoteForSync added in v0.7.0

func (c *PrefixHashTable) ApplyRemoteForSync(ctx context.Context, id string, data []byte) error

ApplyRemoteForSync applies one entity from remote (Redis) into the local store. id is the block hash as string; data is the serialized Block.

func (*PrefixHashTable) ClearDirtyForSync added in v0.7.0

func (c *PrefixHashTable) ClearDirtyForSync(ctx context.Context) error

ClearDirtyForSync clears the dirty set after a successful delta push.

func (*PrefixHashTable) EnableDeltaSync added in v0.7.0

func (c *PrefixHashTable) EnableDeltaSync()

EnableDeltaSync initializes dirty-set tracking so GetDeltaForSync/ClearDirtyForSync can be used. Call this once before registering with statesync.Manager. It is safe to call multiple times; subsequent calls are no-ops.

func (*PrefixHashTable) EncodeBlockForSync added in v0.7.0

func (c *PrefixHashTable) EncodeBlockForSync(blockHash uint64) ([]byte, bool)

EncodeBlockForSync returns the serialized form of the block for the given block hash, or nil if not present. Use with statesync.Sync.Put for optional write-through after AddPrefix; default gateway wiring uses periodic delta push only.

func (*PrefixHashTable) GetDeltaForSync added in v0.7.0

func (c *PrefixHashTable) GetDeltaForSync(ctx context.Context) (updated map[string][]byte, deleted []string, err error)

GetDeltaForSync returns only entities that changed since last ClearDirtyForSync (updated id->bytes; deleted is nil — evictions are not tracked).

If a block was marked dirty then evicted from the local LRU before the next push, it is skipped here (no Redis delete is sent). Stale Redis keys for that entity age out via per-key TTL; do not assume immediate cross-replica delete propagation.

func (*PrefixHashTable) GetPrefixHashes

func (c *PrefixHashTable) GetPrefixHashes(tokens []byte) []uint64

func (*PrefixHashTable) GetSnapshotForSync added in v0.7.0

func (c *PrefixHashTable) GetSnapshotForSync(ctx context.Context) (map[string][]byte, error)

GetSnapshotForSync returns the current prefix cache state as id -> serialized Block for use by a Redis sync layer. Caller must not modify the returned map.

func (*PrefixHashTable) MatchPrefix

func (c *PrefixHashTable) MatchPrefix(tokens []byte, model string, readyPods map[string]struct{}) (map[string]int, []uint64)

MatchPrefix matches the input token prefix's if already cached returns map[podname]%prefixmatch along with all prefix hashes

type PrefixHashTableSyncable added in v0.7.0

type PrefixHashTableSyncable struct {
	Table *PrefixHashTable
}

PrefixHashTableSyncable adapts PrefixHashTable to syncable.Syncable so it can be registered with statesync.Manager for cross-replica sync.

func (*PrefixHashTableSyncable) ApplyRemote added in v0.7.0

func (p *PrefixHashTableSyncable) ApplyRemote(ctx context.Context, id string, data []byte) error

ApplyRemote implements syncable.Syncable.

func (*PrefixHashTableSyncable) ClearDirty added in v0.7.0

func (p *PrefixHashTableSyncable) ClearDirty(ctx context.Context) error

ClearDirty implements syncable.DeltaSyncable.

func (*PrefixHashTableSyncable) GetDelta added in v0.7.0

func (p *PrefixHashTableSyncable) GetDelta(ctx context.Context) (map[string][]byte, []string, error)

GetDelta implements syncable.DeltaSyncable (delta push instead of full snapshot).

func (*PrefixHashTableSyncable) GetSnapshot added in v0.7.0

func (p *PrefixHashTableSyncable) GetSnapshot(ctx context.Context) (map[string][]byte, error)

GetSnapshot implements syncable.Syncable.

func (*PrefixHashTableSyncable) Namespace added in v0.7.0

func (p *PrefixHashTableSyncable) Namespace() string

Namespace implements syncable.Syncable.

type TreeNode

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

func (*TreeNode) AddOrUpdatePodForModel

func (n *TreeNode) AddOrUpdatePodForModel(model string, podName string, timestamp time.Time)

func (*TreeNode) ContextLength

func (n *TreeNode) ContextLength() int

func (*TreeNode) GetCachedPods

func (n *TreeNode) GetCachedPods() map[int]bool

func (*TreeNode) GetChildren

func (n *TreeNode) GetChildren() map[int]*TreeNode

func (*TreeNode) GetDepth

func (n *TreeNode) GetDepth() int

func (*TreeNode) GetEvictedPods

func (n *TreeNode) GetEvictedPods() map[int]bool

func (*TreeNode) GetID

func (n *TreeNode) GetID() int

func (*TreeNode) GetKey

func (n *TreeNode) GetKey() []int

func (*TreeNode) GetLastAccess

func (n *TreeNode) GetLastAccess() time.Time

func (*TreeNode) GetLoad

func (n *TreeNode) GetLoad() int

func (*TreeNode) GetModelToPodCount

func (n *TreeNode) GetModelToPodCount() int

func (*TreeNode) GetModelToPods

func (n *TreeNode) GetModelToPods() map[string]map[string]time.Time

GetModelToPods returns a deep copy of the model-to-pods mapping. Callers can safely iterate the returned maps without holding any lock.

func (*TreeNode) GetParent

func (n *TreeNode) GetParent() *TreeNode

func (*TreeNode) GetPodsForModel

func (n *TreeNode) GetPodsForModel(model string) map[string]time.Time

GetPodsForModel returns a copy of the pod map for the given model.

func (*TreeNode) GetRefCounter

func (n *TreeNode) GetRefCounter() []int

func (*TreeNode) GetValue

func (n *TreeNode) GetValue() []int

func (*TreeNode) HasPodForModel

func (n *TreeNode) HasPodForModel(model, podName string) bool

func (*TreeNode) HasValidPods

func (n *TreeNode) HasValidPods(currentPodSet map[string]bool) bool

func (*TreeNode) InitAndUpdateModelPod

func (n *TreeNode) InitAndUpdateModelPod(model string, podName string, timestamp time.Time)

func (*TreeNode) NumTokens

func (n *TreeNode) NumTokens() int

func (*TreeNode) RemovePodsNotInCurrentPodSet

func (n *TreeNode) RemovePodsNotInCurrentPodSet(currentPodSet map[string]bool) bool

func (*TreeNode) RemovePodsNotInSet

func (n *TreeNode) RemovePodsNotInSet(currentPodSet map[string]bool) bool

func (*TreeNode) ResetCachedPods

func (n *TreeNode) ResetCachedPods()

func (*TreeNode) ResetEvictedPods

func (n *TreeNode) ResetEvictedPods()

func (*TreeNode) ResetRefCounter

func (n *TreeNode) ResetRefCounter(numPods int)

Jump to

Keyboard shortcuts

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