use super::*;
use crate::storage::NativeStore;
use crate::{FactStore, Metadata};
use serde_json::Value;
use std::collections::BTreeSet;
mod diagnostic_copy;
mod execute;
mod orchestrate;
mod rebuild;
mod rebuild_state;
mod state_persistence;
mod switchover;
mod validate;
const DIM: usize = 4;
const EMBEDDING: [f32; 4] = [1.0, 0.0, 0.0, 0.0];
fn diagnose(
source: &std::path::Path,
target_model: &str,
target_dimension: usize,
destination: Option<&std::path::Path>,
) -> Result<DiagnosisReport, crate::MemoryError> {
let staging = tempfile::tempdir().expect("diagnostic staging");
super::diagnose(
source,
staging.path(),
&TargetContract::automatic(target_model, target_dimension),
destination,
)
}
const SEEDED: u64 = 7;
const PAGE: usize = 3;
const SCRAMBLED: &[u64] = &[2000, 41, 999, 3, 17, 1_000_000, 58, 7];
fn meta(pairs: &[(&str, Value)]) -> Metadata {
pairs
.iter()
.map(|(k, v)| ((*k).to_string(), v.clone()))
.collect()
}
fn seeded() -> (tempfile::TempDir, Metadata) {
let dir = tempfile::tempdir().expect("tempdir");
let ttl_metadata;
{
let store = NativeStore::open(dir.path(), DIM).expect("open store");
for id in 1..=SEEDED {
store
.store_with_metadata(
id,
&format!("fact number {id}"),
&EMBEDDING,
&meta(&[
("project", Value::from("veles")),
("_veles_hub", Value::Bool(id == 1)),
]),
)
.expect("seed fact");
}
store
.store_with_metadata_and_ttl(
100,
"a fact under a ttl",
&EMBEDDING,
&meta(&[("project", Value::from("veles"))]),
3600,
)
.expect("seed ttl fact");
ttl_metadata = store
.get_metadata(100)
.expect("read back")
.expect("the ttl fact exists");
}
(dir, ttl_metadata)
}
fn database(dir: &tempfile::TempDir) -> velesdb_core::Database {
velesdb_core::Database::open(dir.path()).expect("open database")
}
mod cli;
mod diagnosis;
mod edges;
mod enumeration;
mod performance;
mod preservation;
mod state;
mod strategy;