pub struct PatternStore { /* private fields */ }Expand description
Pattern store with semantic search capability
Implementations§
Source§impl PatternStore
impl PatternStore
Sourcepub fn add_pattern(&mut self, pattern: TranspilationPattern)
pub fn add_pattern(&mut self, pattern: TranspilationPattern)
Add a pattern to the store
Sourcepub fn get_pattern(&self, id: &str) -> Option<&TranspilationPattern>
pub fn get_pattern(&self, id: &str) -> Option<&TranspilationPattern>
Get a pattern by ID
Sourcepub fn get_pattern_mut(&mut self, id: &str) -> Option<&mut TranspilationPattern>
pub fn get_pattern_mut(&mut self, id: &str) -> Option<&mut TranspilationPattern>
Get mutable reference to a pattern
Sourcepub fn deserialize(json: &str) -> Result<Self, Error>
pub fn deserialize(json: &str) -> Result<Self, Error>
Deserialize the store from JSON
Sourcepub fn cosine_similarity(&self, a: &[f32], b: &[f32]) -> f32
pub fn cosine_similarity(&self, a: &[f32], b: &[f32]) -> f32
Calculate cosine similarity between two embeddings
Sourcepub fn find_similar(
&self,
query: &[f32],
k: usize,
) -> Vec<&TranspilationPattern>
pub fn find_similar( &self, query: &[f32], k: usize, ) -> Vec<&TranspilationPattern>
Find k most similar patterns to query embedding
Uses brute-force linear scan. Consider HNSW indexing for large pattern sets.
Sourcepub fn update_confidence(&mut self, pattern_id: &str, success: bool)
pub fn update_confidence(&mut self, pattern_id: &str, success: bool)
Update pattern confidence based on compilation result
Uses exponential moving average: confidence = (1-α)confidence + αoutcome
Sourcepub fn patterns(&self) -> impl Iterator<Item = &TranspilationPattern>
pub fn patterns(&self) -> impl Iterator<Item = &TranspilationPattern>
Get all patterns (for iteration)
Trait Implementations§
Source§impl Default for PatternStore
impl Default for PatternStore
Source§fn default() -> PatternStore
fn default() -> PatternStore
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for PatternStore
impl RefUnwindSafe for PatternStore
impl Send for PatternStore
impl Sync for PatternStore
impl Unpin for PatternStore
impl UnwindSafe for PatternStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more