use crate::{
db::{DbSession, EntityResponse, PersistedRow, Query, QueryError, query::plan::FieldSlot},
traits::{CanisterKind, EntityValue},
types::Id,
value::Value,
};
impl<C: CanisterKind> DbSession<C> {
pub(in crate::db) fn execute_fluent_bytes<E>(&self, query: &Query<E>) -> Result<u64, QueryError>
where
E: PersistedRow<Canister = C> + EntityValue,
{
self.execute_with_plan(query, |load, plan| load.bytes(plan))
}
pub(in crate::db) fn execute_fluent_bytes_by_slot<E>(
&self,
query: &Query<E>,
target_slot: FieldSlot,
) -> Result<u64, QueryError>
where
E: PersistedRow<Canister = C> + EntityValue,
{
self.execute_with_plan(query, move |load, plan| {
load.bytes_by_slot(plan, target_slot)
})
}
pub(in crate::db) fn execute_fluent_take<E>(
&self,
query: &Query<E>,
take_count: u32,
) -> Result<EntityResponse<E>, QueryError>
where
E: PersistedRow<Canister = C> + EntityValue,
{
self.execute_with_plan(query, move |load, plan| load.take(plan, take_count))
}
pub(in crate::db) fn execute_fluent_top_k_rows_by_slot<E>(
&self,
query: &Query<E>,
target_slot: FieldSlot,
take_count: u32,
) -> Result<EntityResponse<E>, QueryError>
where
E: PersistedRow<Canister = C> + EntityValue,
{
self.execute_with_plan(query, move |load, plan| {
load.top_k_by_slot(plan, target_slot, take_count)
})
}
pub(in crate::db) fn execute_fluent_bottom_k_rows_by_slot<E>(
&self,
query: &Query<E>,
target_slot: FieldSlot,
take_count: u32,
) -> Result<EntityResponse<E>, QueryError>
where
E: PersistedRow<Canister = C> + EntityValue,
{
self.execute_with_plan(query, move |load, plan| {
load.bottom_k_by_slot(plan, target_slot, take_count)
})
}
pub(in crate::db) fn execute_fluent_top_k_values_by_slot<E>(
&self,
query: &Query<E>,
target_slot: FieldSlot,
take_count: u32,
) -> Result<Vec<Value>, QueryError>
where
E: PersistedRow<Canister = C> + EntityValue,
{
self.execute_with_plan(query, move |load, plan| {
load.top_k_by_values_slot(plan, target_slot, take_count)
})
}
pub(in crate::db) fn execute_fluent_bottom_k_values_by_slot<E>(
&self,
query: &Query<E>,
target_slot: FieldSlot,
take_count: u32,
) -> Result<Vec<Value>, QueryError>
where
E: PersistedRow<Canister = C> + EntityValue,
{
self.execute_with_plan(query, move |load, plan| {
load.bottom_k_by_values_slot(plan, target_slot, take_count)
})
}
pub(in crate::db) fn execute_fluent_top_k_values_with_ids_by_slot<E>(
&self,
query: &Query<E>,
target_slot: FieldSlot,
take_count: u32,
) -> Result<Vec<(Id<E>, Value)>, QueryError>
where
E: PersistedRow<Canister = C> + EntityValue,
{
self.execute_with_plan(query, move |load, plan| {
load.top_k_by_with_ids_slot(plan, target_slot, take_count)
})
}
pub(in crate::db) fn execute_fluent_bottom_k_values_with_ids_by_slot<E>(
&self,
query: &Query<E>,
target_slot: FieldSlot,
take_count: u32,
) -> Result<Vec<(Id<E>, Value)>, QueryError>
where
E: PersistedRow<Canister = C> + EntityValue,
{
self.execute_with_plan(query, move |load, plan| {
load.bottom_k_by_with_ids_slot(plan, target_slot, take_count)
})
}
}