pub struct AdaptiveTiering<I: PatternIndex> {
pub index: I,
pub config: TierConfig,
/* private fields */
}Expand description
Pattern-aware tiering advisor.
Combines a PatternIndex with a TierConfig to suggest tier
assignments based on the tiers of semantically similar blocks.
§Algorithm
Given a block’s metadata and a set of nearest neighbors (from the
pattern index), each neighbor’s known tier contributes a weighted
vote proportional to its cosine similarity. The tier with the
highest cumulative vote is suggested, unless it matches the block’s
current tier (in which case None is returned).
Fields§
§index: IThe underlying pattern vector index.
config: TierConfigTiering configuration (thresholds, hysteresis, etc.).
Implementations§
Source§impl<I: PatternIndex> AdaptiveTiering<I>
impl<I: PatternIndex> AdaptiveTiering<I>
Sourcepub fn new(index: I, config: TierConfig) -> Self
pub fn new(index: I, config: TierConfig) -> Self
Create a new AdaptiveTiering with the given index and config.
Sourcepub fn register_block(&mut self, key: BlockKey, tier: Tier)
pub fn register_block(&mut self, key: BlockKey, tier: Tier)
Register (or update) the known tier for a block.
This must be called whenever a block changes tier so that
suggest_tier can use accurate neighbor
tier information for voting.
Sourcepub fn remove_block(&mut self, key: BlockKey)
pub fn remove_block(&mut self, key: BlockKey)
Remove a block from the tier registry and the pattern index.
Sourcepub fn registered_count(&self) -> usize
pub fn registered_count(&self) -> usize
Number of blocks registered in the tier map.
Sourcepub fn suggest_tier(
&self,
meta: &BlockMeta,
neighbors: &[(BlockKey, f32)],
) -> Option<Tier>
pub fn suggest_tier( &self, meta: &BlockMeta, neighbors: &[(BlockKey, f32)], ) -> Option<Tier>
Suggest a tier for meta based on its nearest neighbors.
neighbors should be the output of
PatternIndex::search_nearest: a list of (BlockKey, similarity)
pairs. Each neighbor whose tier is known contributes a weighted
vote. The tier with the highest total vote is returned, unless it
matches the block’s current tier.
Returns None if:
neighborsis empty,- no neighbors have known tiers, or
- the consensus tier matches the block’s current tier.