pub mod algo;
mod db;
pub mod history;
mod ingest;
pub mod mask;
pub mod reader;
pub mod roles;
pub mod schema;
mod shared;
pub mod subscription;
pub use algo::{
AlgoDir, DegreeConfig, DegreeReport, PageRankConfig, PageRankReport, WccConfig, WccReport,
};
pub use core_query::{CmpOp, Dir, Filter, ResultSet};
pub use core_rules::suggest::DEFAULT_SEED as SUGGEST_DEFAULT_SEED;
pub use core_rules::{
default_max_edges, is_keymatch_rooted, AggFn, Predicate, RuleDef, RuleSuggestion,
SuggestConfig, SuggestReport, ViewDef, ViewSource, ViewStore, DEFAULT_KEYMATCH_TOP_K,
DEFAULT_SCORED_TOP_K, MAX_CHAIN_DEPTH,
};
pub use core_storage::{Direction, GraphError, Result, Value};
pub use db::{query_sub_exec_count, reset_query_sub_exec_count};
pub use db::{
snapshot_version_at, write_snapshot_bak, BackupReport, BatchBuilder, BatchOp, DeleteReport,
EdgeInfo, Explanation, ExportEdge, FsyncPolicy, GraphDb, MaskedEdge, MaskedNodeResult,
MutationEvent, NodeInfo, NodeRef, OpenOptions, Precondition, PredicateSummary, RuleStats,
SlowQueryEntry, SlowQuerySnapshot, SnapshotOptions, Stats, WriteAuthz,
};
pub const SNAPSHOT_VERSION: u16 = core_storage::snapshot::VERSION;
pub use history::{EdgeEvent, EdgeHistoryEvent, HistoryChange, HistoryEntry, HistoryResult};
pub use ingest::{
json_to_rows, json_to_value, AutoFk, FkSkip, IngestOptions, IngestReport, JsonRows,
};
pub use mask::{MaskMode, NodeMask};
pub use reader::{CommitDelta, FrozenOverlay, ReaderSnapshot, FOLD_EVERY_K};
pub use roles::{RoleDef, WriteScope};
pub use schema::{Schema, SchemaDiff};
pub use shared::SharedDb;
pub use subscription::{DbEvent, Subscription, DEFAULT_SUB_CAPACITY};
pub type SectionVerifyResult = (u8, &'static str, usize, std::result::Result<(), String>);
pub fn verify_snapshot(dir: &std::path::Path) -> crate::Result<Vec<SectionVerifyResult>> {
let snap_path = dir.join("snapshot.bin");
let mapped = core_storage::v8::MappedBase::map(&snap_path)?;
mapped.validate_section_bounds()?;
let results = mapped.verify_integrity();
mapped.validate_hot_sections()?;
Ok(results)
}
pub fn is_write_query(cypher: &str) -> std::result::Result<bool, String> {
let toks = core_query::cypher::lex(cypher).map_err(|e| format!("lex: {e}"))?;
Ok(core_query::cypher::is_write_tokens(&toks))
}
pub fn wal_commit_count_at(dir: &std::path::Path) -> crate::Result<u64> {
let wal_path = dir.join("wal.bin");
let bytes = match std::fs::read(&wal_path) {
Ok(b) => b,
Err(e) if e.kind() == std::io::ErrorKind::NotFound => Vec::new(),
Err(e) => return Err(core_storage::GraphError::Io(e)),
};
Ok(core_storage::wal::wal_commits(&bytes))
}