1pub mod algo;
2mod db;
3pub mod history;
4mod ingest;
5pub mod mask;
6pub mod reader;
7pub mod repograph;
8pub mod roles;
9pub mod schema;
10mod shared;
11pub mod subscription;
12
13pub use algo::{
14 AlgoDir, Community, CommunityReport, DegreeConfig, DegreeReport, LouvainConfig, PageRankConfig,
15 PageRankReport, WccConfig, WccReport,
16};
17pub use core_query::{CmpOp, Dir, Filter, ResultSet};
18pub use core_rules::suggest::DEFAULT_SEED as SUGGEST_DEFAULT_SEED;
19pub use core_rules::{
20 default_max_edges, is_keymatch_rooted, AggFn, Predicate, RuleDef, RuleSuggestion,
21 SuggestConfig, SuggestReport, ViewDef, ViewSource, ViewStore, DEFAULT_KEYMATCH_TOP_K,
22 DEFAULT_SCORED_TOP_K, MAX_CHAIN_DEPTH,
23};
24pub use core_storage::{Direction, GraphError, Result, Value};
25pub use db::{query_sub_exec_count, reset_query_sub_exec_count};
26pub use db::{
27 snapshot_version_at, write_snapshot_bak, BackupReport, BatchBuilder, BatchOp, DeleteReport,
28 EdgeAt, EdgeInfo, Explanation, ExportEdge, FsyncPolicy, GraphDb, MaskedEdge, MaskedNodeResult,
29 MutationEvent, NodeInfo, NodeRef, OpenOptions, Precondition, PredicateSummary, RuleStats,
30 SlowQueryEntry, SlowQuerySnapshot, SnapshotOptions, Stats, WhatIf, WriteAuthz, WRITE_LOCK_WAIT,
31};
32
33pub const SNAPSHOT_VERSION: u16 = core_storage::snapshot::VERSION;
38pub use history::{EdgeEvent, EdgeHistoryEvent, HistoryChange, HistoryEntry, HistoryResult};
39pub use ingest::{
40 json_to_rows, json_to_value, AutoFk, FkSkip, IngestOptions, IngestReport, JsonRows,
41};
42pub use mask::{MaskMode, NodeMask};
43pub use reader::{CommitDelta, FrozenOverlay, ReaderSnapshot, FOLD_EVERY_K};
44pub use roles::{RoleDef, WriteScope};
45pub use schema::{Schema, SchemaDiff};
46pub use shared::{SharedDb, WriteGuard};
47pub use subscription::{DbEvent, Subscription, DEFAULT_SUB_CAPACITY};
48
49pub type SectionVerifyResult = (u8, &'static str, usize, std::result::Result<(), String>);
53
54pub fn verify_snapshot(dir: &std::path::Path) -> crate::Result<Vec<SectionVerifyResult>> {
63 let snap_path = dir.join("snapshot.bin");
64 let mapped = core_storage::v8::MappedBase::map(&snap_path)?;
65 mapped.validate_section_bounds()?;
71 let results = mapped.verify_integrity();
72 mapped.validate_hot_sections()?;
73 Ok(results)
74}
75
76pub fn is_write_query(cypher: &str) -> std::result::Result<bool, String> {
81 let toks = core_query::cypher::lex(cypher).map_err(|e| format!("lex: {e}"))?;
82 Ok(core_query::cypher::is_write_tokens(&toks))
83}
84
85pub fn wal_commit_count_at(dir: &std::path::Path) -> crate::Result<u64> {
91 let wal_path = dir.join("wal.bin");
92 let bytes = match std::fs::read(&wal_path) {
93 Ok(b) => b,
94 Err(e) if e.kind() == std::io::ErrorKind::NotFound => Vec::new(),
95 Err(e) => return Err(core_storage::GraphError::Io(e)),
96 };
97 Ok(core_storage::wal::wal_commits(&bytes))
98}