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, BuildProgress, Predicate, RuleDef,
21 RuleSuggestion, SuggestConfig, SuggestReport, ViewDef, ViewSource, ViewStore,
22 DEFAULT_KEYMATCH_TOP_K, DEFAULT_SCORED_TOP_K, HNSW_BUILD_BATCH, MAX_CHAIN_DEPTH,
23};
24pub use core_storage::fs::RealFs;
25pub use core_storage::{Direction, GraphError, Result, Value};
26pub use db::{query_sub_exec_count, reset_query_sub_exec_count};
27pub use db::{
28 snapshot_version_at, valid_namespace, write_snapshot_bak, AsOfScope, BackupReport,
29 BatchBuilder, BatchOp, DeleteReport, EdgeAt, EdgeInfo, Explanation, ExportEdge, FsyncPolicy,
30 GraphDb, MaskedEdge, MaskedNodeResult, MutationEvent, NamespaceStats, NodeInfo, NodeRef,
31 OpenOptions, Precondition, PredicateSummary, RuleStats, SlowQueryEntry, SlowQuerySnapshot,
32 SnapshotOptions, Stats, WhatIf, WriteAuthz, NS_DEFAULT, NS_MAX_LEN, NS_PROP, WRITE_LOCK_WAIT,
33};
34
35pub const SNAPSHOT_VERSION: u16 = core_storage::snapshot::VERSION;
40pub use history::{EdgeEvent, EdgeHistoryEvent, HistoryChange, HistoryEntry, HistoryResult};
41pub use ingest::{
42 json_to_rows, json_to_value, AutoFk, FkSkip, IngestOptions, IngestReport, JsonRows,
43};
44pub use mask::{MaskMode, NodeMask, RoleMaskCache};
45pub use reader::{CommitDelta, FrozenOverlay, ReaderSnapshot, FOLD_EVERY_K};
46pub use roles::{PropPredicate, RoleDef, WriteScope};
47pub use schema::{Schema, SchemaDiff};
48pub use shared::{SharedDb, WriteGuard};
49pub use subscription::{DbEvent, Subscription, DEFAULT_SUB_CAPACITY};
50
51pub type SectionVerifyResult = (u8, &'static str, usize, std::result::Result<(), String>);
55
56pub fn verify_snapshot(dir: &std::path::Path) -> crate::Result<Vec<SectionVerifyResult>> {
65 let snap_path = dir.join("snapshot.bin");
66 let mapped = core_storage::v8::MappedBase::map(&snap_path)?;
67 mapped.validate_section_bounds()?;
73 let results = mapped.verify_integrity();
74 mapped.validate_hot_sections()?;
75 Ok(results)
76}
77
78pub fn is_write_query(cypher: &str) -> std::result::Result<bool, String> {
83 let toks = core_query::cypher::lex(cypher).map_err(|e| format!("lex: {e}"))?;
84 Ok(core_query::cypher::is_write_tokens(&toks))
85}
86
87pub fn wal_commit_count_at(dir: &std::path::Path) -> crate::Result<u64> {
93 let wal_path = dir.join("wal.bin");
94 let bytes = match std::fs::read(&wal_path) {
95 Ok(b) => b,
96 Err(e) if e.kind() == std::io::ErrorKind::NotFound => Vec::new(),
97 Err(e) => return Err(core_storage::GraphError::Io(e)),
98 };
99 Ok(core_storage::wal::wal_commits(&bytes))
100}