1pub mod algo;
2mod db;
3pub mod digest;
4mod exact_knn;
5pub mod explain_digest;
6pub mod history;
7mod ingest;
8pub mod mask;
9pub mod memory;
10pub mod memory_schema;
11pub mod reader;
12pub mod restore;
13pub mod roles;
14pub mod schema;
15mod shared;
16pub mod subscription;
17
18pub use algo::{
19 AlgoDir, Community, CommunityReport, DegreeConfig, DegreeReport, LouvainConfig, PageRankConfig,
20 PageRankReport, WccConfig, WccReport,
21};
22pub use core_query::{CmpOp, Dir, Filter, ResultSet};
23pub use core_rules::suggest::DEFAULT_SEED as SUGGEST_DEFAULT_SEED;
24pub use core_rules::{
25 default_max_edges, is_keymatch_rooted, AggFn, BuildProgress, Predicate, RuleDef,
26 RuleSuggestion, SuggestConfig, SuggestReport, ViewDef, ViewSource, ViewStore,
27 DEFAULT_KEYMATCH_TOP_K, DEFAULT_SCORED_TOP_K, HNSW_BUILD_BATCH, MAX_CHAIN_DEPTH,
28};
29pub use core_storage::fs::RealFs;
30pub use core_storage::{Direction, GraphError, Result, Value};
31pub use db::{
32 ambiguous_exactness_last_warning, ambiguous_exactness_warns, ambiguous_exactness_warns_reset,
33};
34pub use db::{query_sub_exec_count, reset_query_sub_exec_count};
35pub use db::{
36 snapshot_version_at, valid_namespace, write_snapshot_bak, AsOfScope, BackupReport,
37 BatchBuilder, BatchOp, BatchOutcome, DeleteReport, EdgeAt, EdgeInfo, Explanation, ExportEdge,
38 FsyncPolicy, GraphDb, MaskedEdge, MaskedNodeResult, MutationEvent, NamespaceStats, NodeInfo,
39 NodeRef, OnConflict, OpenOptions, Precondition, PredicateSummary, RuleStats, SlowQueryEntry,
40 SlowQuerySnapshot, SnapshotOptions, Stats, WhatIf, WriteAuthz,
41 MERGE_CREATE_NEEDS_ONE_NAMESPACE, NS_DEFAULT, NS_MAX_LEN, NS_PROP, WRITE_LOCK_WAIT,
42};
43pub use exact_knn::{with_pairwise_caps, PAIRWISE_GRAM_MAX, PAIRWISE_MAX_N};
44
45pub const FIND_SIMILAR_DEFAULT_MIN: f64 = 0.8;
56
57pub const SNAPSHOT_VERSION: u16 = core_storage::snapshot::VERSION;
69pub use history::{EdgeEvent, EdgeHistoryEvent, HistoryChange, HistoryEntry, HistoryResult};
70pub use ingest::{
71 json_to_rows, json_to_value, AutoFk, FkSkip, IngestOptions, IngestReport, JsonRows,
72};
73pub use mask::{MaskMode, NodeMask, RoleMaskCache, Scope};
74pub use reader::{CommitDelta, FrozenOverlay, ReaderSnapshot, FOLD_EVERY_K};
75pub use roles::{PropPredicate, RoleDef, WriteScope};
76pub use schema::{Schema, SchemaDiff};
77pub use shared::{SharedDb, WriteGuard};
78pub use subscription::{DbEvent, Subscription, DEFAULT_SUB_CAPACITY};
79
80pub type SectionVerifyResult = (u8, &'static str, usize, std::result::Result<(), String>);
84
85pub fn verify_snapshot(dir: &std::path::Path) -> crate::Result<Vec<SectionVerifyResult>> {
94 let snap_path = dir.join("snapshot.bin");
95 let mapped = core_storage::v8::MappedBase::map(&snap_path)?;
96 mapped.validate_section_bounds()?;
102 let results = mapped.verify_integrity();
103 mapped.validate_hot_sections()?;
104 Ok(results)
105}
106
107pub fn is_write_query(cypher: &str) -> std::result::Result<bool, String> {
112 let toks = core_query::cypher::lex(cypher).map_err(|e| format!("lex: {e}"))?;
113 Ok(core_query::cypher::is_write_tokens(&toks))
114}
115
116pub fn wal_commit_count_at(dir: &std::path::Path) -> crate::Result<u64> {
122 let wal_path = dir.join("wal.bin");
123 let bytes = match std::fs::read(&wal_path) {
124 Ok(b) => b,
125 Err(e) if e.kind() == std::io::ErrorKind::NotFound => Vec::new(),
126 Err(e) => return Err(core_storage::GraphError::Io(e)),
127 };
128 Ok(core_storage::wal::wal_commits(&bytes))
129}