use std::any::Any;
use std::collections::BTreeMap;
use std::sync::Arc;
use std::time::Instant;
use anyhow::Result;
use lora_compiler::CompiledQuery;
use lora_executor::{LoraValue, MutableExecutionContext, MutableExecutor, Row};
use lora_store::{GraphStorage, GraphStorageMut};
use crate::database::Database;
impl<S> Database<S>
where
S: GraphStorage + GraphStorageMut + Any + Clone + Send + Sync + 'static,
{
pub(crate) fn execute_mutating_optimistic(
&self,
params: BTreeMap<String, LoraValue>,
deadline: Option<Instant>,
compiled: &Arc<CompiledQuery>,
) -> Result<Vec<Row>> {
self.run_with_durable_recorder(|staged| {
let mut executor = MutableExecutor::with_deadline(
MutableExecutionContext {
storage: staged,
params,
},
deadline,
);
executor
.execute_compiled_rows(compiled)
.map_err(anyhow::Error::from)
})
}
}