Skip to main content

FeedbackStore

Struct FeedbackStore 

Source
pub struct FeedbackStore { /* private fields */ }
Expand description

SQLite-backed feedback store.

Implementations§

Source§

impl FeedbackStore

Source

pub fn open(path: impl AsRef<Path>) -> Result<Self>

Open or create a store at path.

Source

pub fn open_in_memory() -> Result<Self>

Open an in-memory store (test / ephemeral).

§Examples
use samkhya_core::feedback::FeedbackStore;

let store = FeedbackStore::open_in_memory().unwrap();
assert_eq!(store.count().unwrap(), 0);
Source

pub fn record(&self, obs: &Observation) -> Result<i64>

Record an observation.

§Examples
use samkhya_core::feedback::{FeedbackStore, Observation};

let store = FeedbackStore::open_in_memory().unwrap();
let obs = Observation {
    template_hash: "tpch-q1".into(),
    plan_fingerprint: "hash-join#42".into(),
    est_rows: 1000,
    actual_rows: 950,
    latency_ms: Some(12.5),
};
let id = store.record(&obs).unwrap();
assert!(id > 0);
assert_eq!(store.count().unwrap(), 1);
Source

pub fn history(&self, template_hash: &str) -> Result<Vec<Observation>>

Return all observations for a given query template, oldest first.

Source

pub fn count(&self) -> Result<u64>

Number of observations stored.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V