Documentation
¶
Index ¶
- func NewPrefixHashTableSyncable(table *PrefixHashTable) syncable.Syncable
- type Block
- type LPRadixCache
- func (c *LPRadixCache) AddPrefix(tokens []int, model string, podName string) (*TreeNode, []int, []int)
- func (c *LPRadixCache) Evict(now time.Time) []*TreeNode
- func (c *LPRadixCache) GetAllNodes() map[int]*TreeNode
- func (c *LPRadixCache) GetAllPodsInNode(node *TreeNode) []string
- func (c *LPRadixCache) GetNode(tokens []int) *TreeNode
- func (c *LPRadixCache) MatchPrefix(inputTokens []int, model string, pods []*v1.Pod) ([]int, []int, []*v1.Pod)
- func (c *LPRadixCache) MatchPrefixNodeReadOnly(inputTokens []int) (*TreeNode, []int)
- func (c *LPRadixCache) NewTreeNode(numPods int, parent *TreeNode, key []int, value []int) *TreeNode
- func (c *LPRadixCache) PrettyPrint()
- type PrefixHashTable
- func (c *PrefixHashTable) AddPrefix(prefixHashes []uint64, model, pod string)
- func (c *PrefixHashTable) ApplyRemoteForSync(ctx context.Context, id string, data []byte) error
- func (c *PrefixHashTable) ClearDirtyForSync(ctx context.Context) error
- func (c *PrefixHashTable) EnableDeltaSync()
- func (c *PrefixHashTable) EncodeBlockForSync(blockHash uint64) ([]byte, bool)
- func (c *PrefixHashTable) GetDeltaForSync(ctx context.Context) (updated map[string][]byte, deleted []string, err error)
- func (c *PrefixHashTable) GetPrefixHashes(tokens []byte) []uint64
- func (c *PrefixHashTable) GetSnapshotForSync(ctx context.Context) (map[string][]byte, error)
- func (c *PrefixHashTable) MatchPrefix(tokens []byte, model string, readyPods map[string]struct{}) (map[string]int, []uint64)
- type PrefixHashTableSyncable
- func (p *PrefixHashTableSyncable) ApplyRemote(ctx context.Context, id string, data []byte) error
- func (p *PrefixHashTableSyncable) ClearDirty(ctx context.Context) error
- func (p *PrefixHashTableSyncable) GetDelta(ctx context.Context) (map[string][]byte, []string, error)
- func (p *PrefixHashTableSyncable) GetSnapshot(ctx context.Context) (map[string][]byte, error)
- func (p *PrefixHashTableSyncable) Namespace() string
- type TreeNode
- func (n *TreeNode) AddOrUpdatePodForModel(model string, podName string, timestamp time.Time)
- func (n *TreeNode) ContextLength() int
- func (n *TreeNode) GetCachedPods() map[int]bool
- func (n *TreeNode) GetChildren() map[int]*TreeNode
- func (n *TreeNode) GetDepth() int
- func (n *TreeNode) GetEvictedPods() map[int]bool
- func (n *TreeNode) GetID() int
- func (n *TreeNode) GetKey() []int
- func (n *TreeNode) GetLastAccess() time.Time
- func (n *TreeNode) GetLoad() int
- func (n *TreeNode) GetModelToPodCount() int
- func (n *TreeNode) GetModelToPods() map[string]map[string]time.Time
- func (n *TreeNode) GetParent() *TreeNode
- func (n *TreeNode) GetPodsForModel(model string) map[string]time.Time
- func (n *TreeNode) GetRefCounter() []int
- func (n *TreeNode) GetValue() []int
- func (n *TreeNode) HasPodForModel(model, podName string) bool
- func (n *TreeNode) HasValidPods(currentPodSet map[string]bool) bool
- func (n *TreeNode) InitAndUpdateModelPod(model string, podName string, timestamp time.Time)
- func (n *TreeNode) NumTokens() int
- func (n *TreeNode) RemovePodsNotInCurrentPodSet(currentPodSet map[string]bool) bool
- func (n *TreeNode) RemovePodsNotInSet(currentPodSet map[string]bool) bool
- func (n *TreeNode) ResetCachedPods()
- func (n *TreeNode) ResetEvictedPods()
- func (n *TreeNode) ResetRefCounter(numPods int)
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 LPRadixCache ¶
type LPRadixCache struct {
// contains filtered or unexported fields
}
func NewLPRadixCache ¶
func NewLPRadixCache(numPods int) *LPRadixCache
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 (*LPRadixCache) MatchPrefixNodeReadOnly ¶ added in v0.7.0
func (c *LPRadixCache) MatchPrefixNodeReadOnly(inputTokens []int) (*TreeNode, []int)
func (*LPRadixCache) NewTreeNode ¶
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
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
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
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
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 (*TreeNode) ContextLength ¶
func (*TreeNode) GetCachedPods ¶
func (*TreeNode) GetChildren ¶
func (*TreeNode) GetEvictedPods ¶
func (*TreeNode) GetLastAccess ¶
func (*TreeNode) GetModelToPodCount ¶
func (*TreeNode) GetModelToPods ¶
GetModelToPods returns a deep copy of the model-to-pods mapping. Callers can safely iterate the returned maps without holding any lock.
func (*TreeNode) GetPodsForModel ¶
GetPodsForModel returns a copy of the pod map for the given model.
func (*TreeNode) GetRefCounter ¶
func (*TreeNode) HasPodForModel ¶
func (*TreeNode) InitAndUpdateModelPod ¶
func (*TreeNode) RemovePodsNotInCurrentPodSet ¶
func (*TreeNode) RemovePodsNotInSet ¶
func (*TreeNode) ResetCachedPods ¶
func (n *TreeNode) ResetCachedPods()
func (*TreeNode) ResetEvictedPods ¶
func (n *TreeNode) ResetEvictedPods()