diff --git a/cozo-core/benches/time_travel.rs b/cozo-core/benches/time_travel.rs index feec7bf8..73d3705d 100644 --- a/cozo-core/benches/time_travel.rs +++ b/cozo-core/benches/time_travel.rs @@ -10,13 +10,13 @@ extern crate test; -use std::cmp::max; use cozo::{DbInstance, NamedRows}; use itertools::Itertools; use lazy_static::{initialize, lazy_static}; use rand::Rng; use rayon::prelude::*; use serde_json::json; +use std::cmp::max; use std::collections::BTreeMap; use std::time::Instant; use test::Bencher; diff --git a/cozo-core/src/data/aggr.rs b/cozo-core/src/data/aggr.rs index 109c5d75..86652e0c 100644 --- a/cozo-core/src/data/aggr.rs +++ b/cozo-core/src/data/aggr.rs @@ -796,7 +796,6 @@ impl NormalAggrObj for AggrSmallestBy { } } - define_aggr!(AGGR_MIN_COST, true); pub(crate) struct AggrMinCost { diff --git a/cozo-core/src/data/json.rs b/cozo-core/src/data/json.rs index 96bbb7a4..dee88ba0 100644 --- a/cozo-core/src/data/json.rs +++ b/cozo-core/src/data/json.rs @@ -6,8 +6,8 @@ * You can obtain one at https://mozilla.org/MPL/2.0/. */ -use base64::Engine; use base64::engine::general_purpose::STANDARD; +use base64::Engine; use serde_json::json; pub(crate) use serde_json::Value as JsonValue; @@ -29,11 +29,7 @@ impl From for DataValue { JsonValue::Array(arr) => DataValue::List(arr.iter().map(DataValue::from).collect()), JsonValue::Object(d) => DataValue::List( d.into_iter() - .map(|(k, v)| { - DataValue::List( - [DataValue::from(k), DataValue::from(v)].into(), - ) - }) + .map(|(k, v)| DataValue::List([DataValue::from(k), DataValue::from(v)].into())) .collect(), ), } @@ -106,4 +102,4 @@ impl From for JsonValue { } } } -} \ No newline at end of file +} diff --git a/cozo-core/src/data/mod.rs b/cozo-core/src/data/mod.rs index 2f0bae9a..959a68c6 100644 --- a/cozo-core/src/data/mod.rs +++ b/cozo-core/src/data/mod.rs @@ -6,17 +6,16 @@ * You can obtain one at https://mozilla.org/MPL/2.0/. */ -pub(crate) mod json; -pub(crate) mod symb; -pub(crate) mod value; -pub(crate) mod tuple; -pub(crate) mod expr; -pub(crate) mod program; pub(crate) mod aggr; +pub(crate) mod expr; pub(crate) mod functions; -pub(crate) mod relation; +pub(crate) mod json; pub(crate) mod memcmp; +pub(crate) mod program; +pub(crate) mod relation; +pub(crate) mod symb; +pub(crate) mod tuple; +pub(crate) mod value; #[cfg(test)] mod tests; - diff --git a/cozo-core/src/data/tests/exprs.rs b/cozo-core/src/data/tests/exprs.rs index 359f2c90..6c20f4e4 100644 --- a/cozo-core/src/data/tests/exprs.rs +++ b/cozo-core/src/data/tests/exprs.rs @@ -6,20 +6,29 @@ * You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::{DataValue, new_cozo_mem}; +use crate::{new_cozo_mem, DataValue}; #[test] fn expression_eval() { let db = new_cozo_mem().unwrap(); - - let res = db.run_script(r#" + let res = db + .run_script( + r#" ?[a] := a = if(2 + 3 > 1 * 99999, 190291021 + 14341234212 / 2121) - "#, Default::default()).unwrap(); + "#, + Default::default(), + ) + .unwrap(); assert_eq!(res.rows[0][0], DataValue::Null); - let res = db.run_script(r#" + let res = db + .run_script( + r#" ?[a] := a = if(2 + 3 > 1, true, false) - "#, Default::default()).unwrap(); + "#, + Default::default(), + ) + .unwrap(); assert_eq!(res.rows[0][0].get_bool().unwrap(), true); -} \ No newline at end of file +} diff --git a/cozo-core/src/data/tests/json.rs b/cozo-core/src/data/tests/json.rs index d7609783..45ce4347 100644 --- a/cozo-core/src/data/tests/json.rs +++ b/cozo-core/src/data/tests/json.rs @@ -18,4 +18,4 @@ fn bad_values() { println!("{}", JsonValue::from(DataValue::from(f64::INFINITY))); println!("{}", JsonValue::from(DataValue::from(f64::NEG_INFINITY))); println!("{}", JsonValue::from(DataValue::from(f64::NAN))); -} \ No newline at end of file +} diff --git a/cozo-core/src/data/tests/mod.rs b/cozo-core/src/data/tests/mod.rs index 194902d2..8d41452f 100644 --- a/cozo-core/src/data/tests/mod.rs +++ b/cozo-core/src/data/tests/mod.rs @@ -6,10 +6,10 @@ * You can obtain one at https://mozilla.org/MPL/2.0/. */ -mod functions; mod aggrs; -mod validity; +mod exprs; +mod functions; mod json; mod memcmp; +mod validity; mod values; -mod exprs; \ No newline at end of file diff --git a/cozo-core/src/data/tuple.rs b/cozo-core/src/data/tuple.rs index 573fae21..f86fbe38 100644 --- a/cozo-core/src/data/tuple.rs +++ b/cozo-core/src/data/tuple.rs @@ -6,9 +6,9 @@ * You can obtain one at https://mozilla.org/MPL/2.0/. */ -use std::cmp::Reverse; use crate::data::functions::TERMINAL_VALIDITY; use miette::Result; +use std::cmp::Reverse; use crate::data::memcmp::MemCmpEncoder; use crate::data::value::{DataValue, Validity, ValidityTs}; diff --git a/cozo-core/src/data/value.rs b/cozo-core/src/data/value.rs index 84515888..ea873a8f 100644 --- a/cozo-core/src/data/value.rs +++ b/cozo-core/src/data/value.rs @@ -6,12 +6,12 @@ * You can obtain one at https://mozilla.org/MPL/2.0/. */ +use base64::engine::general_purpose::STANDARD; +use base64::Engine; use std::cmp::{Ordering, Reverse}; use std::collections::BTreeSet; use std::fmt::{Debug, Display, Formatter}; use std::hash::{Hash, Hasher}; -use base64::Engine; -use base64::engine::general_purpose::STANDARD; use ordered_float::OrderedFloat; use regex::Regex; diff --git a/cozo-core/src/fixed_rule/algos/all_pairs_shortest_path.rs b/cozo-core/src/fixed_rule/algos/all_pairs_shortest_path.rs index 2e4fa31f..c13eaf8a 100644 --- a/cozo-core/src/fixed_rule/algos/all_pairs_shortest_path.rs +++ b/cozo-core/src/fixed_rule/algos/all_pairs_shortest_path.rs @@ -6,9 +6,9 @@ * You can obtain one at https://mozilla.org/MPL/2.0/. */ +use graph::prelude::{DirectedCsrGraph, DirectedNeighborsWithValues, Graph}; use std::cmp::Reverse; use std::collections::BTreeMap; -use graph::prelude::{DirectedCsrGraph, DirectedNeighborsWithValues, Graph}; use itertools::Itertools; use miette::Result; @@ -17,11 +17,11 @@ use priority_queue::PriorityQueue; use rayon::prelude::*; use smartstring::{LazyCompact, SmartString}; -use crate::fixed_rule::algos::shortest_path_dijkstra::dijkstra_keep_ties; -use crate::fixed_rule::{FixedRule, FixedRulePayload}; use crate::data::expr::Expr; use crate::data::symb::Symbol; use crate::data::value::DataValue; +use crate::fixed_rule::algos::shortest_path_dijkstra::dijkstra_keep_ties; +use crate::fixed_rule::{FixedRule, FixedRulePayload}; use crate::parse::SourceSpan; use crate::runtime::db::Poison; use crate::runtime::temp_store::RegularTempStore; @@ -38,8 +38,7 @@ impl FixedRule for BetweennessCentrality { let edges = payload.get_input(0)?; let undirected = payload.bool_option("undirected", Some(false))?; - let (graph, indices, _inv_indices) = - edges.as_directed_weighted_graph(undirected, false)?; + let (graph, indices, _inv_indices) = edges.as_directed_weighted_graph(undirected, false)?; let n = graph.node_count(); if n == 0 { @@ -107,8 +106,7 @@ impl FixedRule for ClosenessCentrality { let edges = payload.get_input(0)?; let undirected = payload.bool_option("undirected", Some(false))?; - let (graph, indices, _inv_indices) = - edges.as_directed_weighted_graph(undirected, false)?; + let (graph, indices, _inv_indices) = edges.as_directed_weighted_graph(undirected, false)?; let n = graph.node_count(); if n == 0 { @@ -125,7 +123,10 @@ impl FixedRule for ClosenessCentrality { }) .collect::>()?; for (idx, centrality) in res.into_iter().enumerate() { - out.put(vec![indices[idx].clone(), DataValue::from(centrality as f64)]); + out.put(vec![ + indices[idx].clone(), + DataValue::from(centrality as f64), + ]); poison.check()?; } Ok(()) @@ -167,7 +168,6 @@ pub(crate) fn dijkstra_cost_only( distance[nxt_node as usize] = nxt_cost; back_pointers[nxt_node as usize] = node; } - } poison.check()?; } diff --git a/cozo-core/src/fixed_rule/algos/bfs.rs b/cozo-core/src/fixed_rule/algos/bfs.rs index 4988e998..c279d2f7 100644 --- a/cozo-core/src/fixed_rule/algos/bfs.rs +++ b/cozo-core/src/fixed_rule/algos/bfs.rs @@ -11,10 +11,10 @@ use std::collections::{BTreeMap, BTreeSet, VecDeque}; use miette::Result; use smartstring::{LazyCompact, SmartString}; -use crate::fixed_rule::{FixedRule, FixedRulePayload, NodeNotFoundError}; use crate::data::expr::{eval_bytecode_pred, Expr}; use crate::data::symb::Symbol; use crate::data::value::DataValue; +use crate::fixed_rule::{FixedRule, FixedRulePayload, NodeNotFoundError}; use crate::parse::SourceSpan; use crate::runtime::db::Poison; use crate::runtime::temp_store::RegularTempStore; @@ -79,7 +79,12 @@ impl FixedRule for Bfs { })?? }; - if eval_bytecode_pred(&condition_bytecode, &cand_tuple, &mut stack, condition_span)? { + if eval_bytecode_pred( + &condition_bytecode, + &cand_tuple, + &mut stack, + condition_span, + )? { found.push((starting_node.clone(), to_node.clone())); if found.len() >= limit { break 'outer; diff --git a/cozo-core/src/fixed_rule/algos/degree_centrality.rs b/cozo-core/src/fixed_rule/algos/degree_centrality.rs index 02857e9d..0e35d58c 100644 --- a/cozo-core/src/fixed_rule/algos/degree_centrality.rs +++ b/cozo-core/src/fixed_rule/algos/degree_centrality.rs @@ -11,10 +11,10 @@ use std::collections::BTreeMap; use miette::Result; use smartstring::{LazyCompact, SmartString}; -use crate::fixed_rule::{FixedRule, FixedRulePayload}; use crate::data::expr::Expr; use crate::data::symb::Symbol; use crate::data::value::DataValue; +use crate::fixed_rule::{FixedRule, FixedRulePayload}; use crate::parse::SourceSpan; use crate::runtime::db::Poison; use crate::runtime::temp_store::RegularTempStore; diff --git a/cozo-core/src/fixed_rule/algos/kruskal.rs b/cozo-core/src/fixed_rule/algos/kruskal.rs index cf8108a7..66704c82 100644 --- a/cozo-core/src/fixed_rule/algos/kruskal.rs +++ b/cozo-core/src/fixed_rule/algos/kruskal.rs @@ -6,9 +6,9 @@ * You can obtain one at https://mozilla.org/MPL/2.0/. */ +use graph::prelude::{DirectedCsrGraph, DirectedNeighborsWithValues, Graph}; use std::cmp::Reverse; use std::collections::BTreeMap; -use graph::prelude::{DirectedCsrGraph, DirectedNeighborsWithValues, Graph}; use itertools::Itertools; use miette::Result; @@ -16,10 +16,10 @@ use ordered_float::OrderedFloat; use priority_queue::PriorityQueue; use smartstring::{LazyCompact, SmartString}; -use crate::fixed_rule::{FixedRule, FixedRulePayload}; use crate::data::expr::Expr; use crate::data::symb::Symbol; use crate::data::value::DataValue; +use crate::fixed_rule::{FixedRule, FixedRulePayload}; use crate::parse::SourceSpan; use crate::runtime::db::Poison; use crate::runtime::temp_store::RegularTempStore; diff --git a/cozo-core/src/fixed_rule/algos/mod.rs b/cozo-core/src/fixed_rule/algos/mod.rs index 1761a51c..08f42642 100644 --- a/cozo-core/src/fixed_rule/algos/mod.rs +++ b/cozo-core/src/fixed_rule/algos/mod.rs @@ -16,13 +16,13 @@ pub(crate) mod label_propagation; pub(crate) mod louvain; pub(crate) mod pagerank; pub(crate) mod prim; +pub(crate) mod random_walk; +pub(crate) mod shortest_path_bfs; pub(crate) mod shortest_path_dijkstra; pub(crate) mod strongly_connected_components; pub(crate) mod top_sort; pub(crate) mod triangles; pub(crate) mod yen; -pub(crate) mod shortest_path_bfs; -pub(crate) mod random_walk; pub(crate) use all_pairs_shortest_path::{BetweennessCentrality, ClosenessCentrality}; pub(crate) use astar::ShortestPathAStar; @@ -34,10 +34,10 @@ pub(crate) use label_propagation::LabelPropagation; pub(crate) use louvain::CommunityDetectionLouvain; pub(crate) use pagerank::PageRank; pub(crate) use prim::MinimumSpanningTreePrim; +pub(crate) use random_walk::RandomWalk; +pub(crate) use shortest_path_bfs::ShortestPathBFS; pub(crate) use shortest_path_dijkstra::ShortestPathDijkstra; pub(crate) use strongly_connected_components::StronglyConnectedComponent; pub(crate) use top_sort::TopSort; pub(crate) use triangles::ClusteringCoefficients; pub(crate) use yen::KShortestPathYen; -pub(crate) use shortest_path_bfs::ShortestPathBFS; -pub(crate) use random_walk::RandomWalk; \ No newline at end of file diff --git a/cozo-core/src/fixed_rule/algos/pagerank.rs b/cozo-core/src/fixed_rule/algos/pagerank.rs index 90a45cb4..b45c12b1 100644 --- a/cozo-core/src/fixed_rule/algos/pagerank.rs +++ b/cozo-core/src/fixed_rule/algos/pagerank.rs @@ -41,7 +41,7 @@ impl FixedRule for PageRank { let (graph, indices, _) = edges.as_directed_graph(undirected)?; if indices.is_empty() { - return Ok(()) + return Ok(()); } let (ranks, _n_run, _) = page_rank( diff --git a/cozo-core/src/fixed_rule/algos/prim.rs b/cozo-core/src/fixed_rule/algos/prim.rs index 1c86e4bf..c919a6fd 100644 --- a/cozo-core/src/fixed_rule/algos/prim.rs +++ b/cozo-core/src/fixed_rule/algos/prim.rs @@ -6,9 +6,9 @@ * You can obtain one at https://mozilla.org/MPL/2.0/. */ +use graph::prelude::{DirectedCsrGraph, DirectedNeighborsWithValues, Graph}; use std::cmp::Reverse; use std::collections::BTreeMap; -use graph::prelude::{DirectedCsrGraph, DirectedNeighborsWithValues, Graph}; use miette::Diagnostic; use miette::Result; @@ -17,10 +17,10 @@ use priority_queue::PriorityQueue; use smartstring::{LazyCompact, SmartString}; use thiserror::Error; -use crate::fixed_rule::{FixedRule, FixedRulePayload}; use crate::data::expr::Expr; use crate::data::symb::Symbol; use crate::data::value::DataValue; +use crate::fixed_rule::{FixedRule, FixedRulePayload}; use crate::parse::SourceSpan; use crate::runtime::db::Poison; use crate::runtime::temp_store::RegularTempStore; diff --git a/cozo-core/src/fixed_rule/algos/random_walk.rs b/cozo-core/src/fixed_rule/algos/random_walk.rs index ef647fd3..9c2eb1bf 100644 --- a/cozo-core/src/fixed_rule/algos/random_walk.rs +++ b/cozo-core/src/fixed_rule/algos/random_walk.rs @@ -14,10 +14,10 @@ use rand::distributions::WeightedIndex; use rand::prelude::*; use smartstring::{LazyCompact, SmartString}; -use crate::fixed_rule::{FixedRule, FixedRulePayload, BadExprValueError, NodeNotFoundError}; use crate::data::expr::{eval_bytecode, Expr}; use crate::data::symb::Symbol; use crate::data::value::DataValue; +use crate::fixed_rule::{BadExprValueError, FixedRule, FixedRulePayload, NodeNotFoundError}; use crate::parse::SourceSpan; use crate::runtime::db::Poison; use crate::runtime::temp_store::RegularTempStore; diff --git a/cozo-core/src/fixed_rule/algos/shortest_path_dijkstra.rs b/cozo-core/src/fixed_rule/algos/shortest_path_dijkstra.rs index c20d30e9..d8e97954 100644 --- a/cozo-core/src/fixed_rule/algos/shortest_path_dijkstra.rs +++ b/cozo-core/src/fixed_rule/algos/shortest_path_dijkstra.rs @@ -6,10 +6,10 @@ * You can obtain one at https://mozilla.org/MPL/2.0/. */ +use graph::prelude::{DirectedCsrGraph, DirectedNeighborsWithValues, Graph}; use std::cmp::{Ordering, Reverse}; use std::collections::{BTreeMap, BTreeSet}; use std::iter; -use graph::prelude::{DirectedCsrGraph, DirectedNeighborsWithValues, Graph}; use itertools::Itertools; use miette::Result; @@ -19,10 +19,10 @@ use rayon::prelude::*; use smallvec::{smallvec, SmallVec}; use smartstring::{LazyCompact, SmartString}; -use crate::fixed_rule::{FixedRule, FixedRulePayload}; use crate::data::expr::Expr; use crate::data::symb::Symbol; use crate::data::value::DataValue; +use crate::fixed_rule::{FixedRule, FixedRulePayload}; use crate::parse::SourceSpan; use crate::runtime::db::Poison; use crate::runtime::temp_store::RegularTempStore; @@ -42,8 +42,7 @@ impl FixedRule for ShortestPathDijkstra { let undirected = payload.bool_option("undirected", Some(false))?; let keep_ties = payload.bool_option("keep_ties", Some(false))?; - let (graph, indices, inv_indices) = - edges.as_directed_weighted_graph(undirected, false)?; + let (graph, indices, inv_indices) = edges.as_directed_weighted_graph(undirected, false)?; let mut starting_nodes = BTreeSet::new(); for tuple in starting.iter()? { @@ -91,7 +90,11 @@ impl FixedRule for ShortestPathDijkstra { indices[start as usize].clone(), indices[target as usize].clone(), DataValue::from(cost as f64), - DataValue::List(path.into_iter().map(|u| indices[u as usize].clone()).collect_vec()), + DataValue::List( + path.into_iter() + .map(|u| indices[u as usize].clone()) + .collect_vec(), + ), ]; out.put(t) } @@ -135,7 +138,11 @@ impl FixedRule for ShortestPathDijkstra { indices[start as usize].clone(), indices[target as usize].clone(), DataValue::from(cost as f64), - DataValue::List(path.into_iter().map(|u| indices[u as usize].clone()).collect_vec()), + DataValue::List( + path.into_iter() + .map(|u| indices[u as usize].clone()) + .collect_vec(), + ), ]; out.put(t) } @@ -284,7 +291,7 @@ pub(crate) fn dijkstra( continue; } - for target in edges.out_neighbors_with_values(node) { + for target in edges.out_neighbors_with_values(node) { let nxt_node = target.target; let path_weight = target.value; diff --git a/cozo-core/src/fixed_rule/algos/strongly_connected_components.rs b/cozo-core/src/fixed_rule/algos/strongly_connected_components.rs index 6a0196cb..2054efc2 100644 --- a/cozo-core/src/fixed_rule/algos/strongly_connected_components.rs +++ b/cozo-core/src/fixed_rule/algos/strongly_connected_components.rs @@ -7,20 +7,20 @@ */ #![allow(unused_imports)] +use graph::prelude::{DirectedCsrGraph, DirectedNeighbors, Graph}; use std::cmp::min; use std::collections::BTreeMap; -use graph::prelude::{DirectedCsrGraph, DirectedNeighbors, Graph}; use itertools::Itertools; use miette::Result; use smartstring::{LazyCompact, SmartString}; -use crate::fixed_rule::{FixedRule, FixedRulePayload}; use crate::data::expr::Expr; use crate::data::program::{MagicFixedRuleApply, MagicSymbol}; use crate::data::symb::Symbol; use crate::data::tuple::Tuple; use crate::data::value::DataValue; +use crate::fixed_rule::{FixedRule, FixedRulePayload}; use crate::parse::SourceSpan; use crate::runtime::db::Poison; use crate::runtime::temp_store::{EpochStore, RegularTempStore}; @@ -47,8 +47,7 @@ impl FixedRule for StronglyConnectedComponent { ) -> Result<()> { let edges = payload.get_input(0)?; - let (graph, indices, mut inv_indices) = - edges.as_directed_graph(!self.strong)?; + let (graph, indices, mut inv_indices) = edges.as_directed_graph(!self.strong)?; let tarjan = TarjanSccG::new(graph).run(poison)?; for (grp_id, cc) in tarjan.iter().enumerate() { @@ -87,7 +86,6 @@ impl FixedRule for StronglyConnectedComponent { } } - pub(crate) struct TarjanSccG { graph: DirectedCsrGraph, id: u32, @@ -97,7 +95,6 @@ pub(crate) struct TarjanSccG { stack: Vec, } - impl TarjanSccG { pub(crate) fn new(graph: DirectedCsrGraph) -> Self { let graph_size = graph.node_count(); @@ -150,4 +147,3 @@ impl TarjanSccG { } } } - diff --git a/cozo-core/src/fixed_rule/algos/top_sort.rs b/cozo-core/src/fixed_rule/algos/top_sort.rs index 7f749fa0..f8d58321 100644 --- a/cozo-core/src/fixed_rule/algos/top_sort.rs +++ b/cozo-core/src/fixed_rule/algos/top_sort.rs @@ -6,16 +6,16 @@ * You can obtain one at https://mozilla.org/MPL/2.0/. */ -use std::collections::BTreeMap; use graph::prelude::{DirectedCsrGraph, DirectedNeighbors, Graph}; +use std::collections::BTreeMap; use miette::Result; use smartstring::{LazyCompact, SmartString}; -use crate::fixed_rule::{FixedRule, FixedRulePayload}; use crate::data::expr::Expr; use crate::data::symb::Symbol; use crate::data::value::DataValue; +use crate::fixed_rule::{FixedRule, FixedRulePayload}; use crate::parse::SourceSpan; use crate::runtime::db::Poison; use crate::runtime::temp_store::RegularTempStore; @@ -54,7 +54,6 @@ impl FixedRule for TopSort { } } - pub(crate) fn kahn_g(graph: &DirectedCsrGraph, poison: Poison) -> Result> { let graph_size = graph.node_count(); let mut in_degree = vec![0; graph_size as usize]; diff --git a/cozo-core/src/fixed_rule/algos/yen.rs b/cozo-core/src/fixed_rule/algos/yen.rs index f8cdeea5..214a7e94 100644 --- a/cozo-core/src/fixed_rule/algos/yen.rs +++ b/cozo-core/src/fixed_rule/algos/yen.rs @@ -102,7 +102,11 @@ impl FixedRule for KShortestPathYen { indices[start as usize].clone(), indices[goal as usize].clone(), DataValue::from(cost as f64), - DataValue::List(path.into_iter().map(|u| indices[u as usize].clone()).collect_vec()), + DataValue::List( + path.into_iter() + .map(|u| indices[u as usize].clone()) + .collect_vec(), + ), ]; out.put(t) } diff --git a/cozo-core/src/fixed_rule/mod.rs b/cozo-core/src/fixed_rule/mod.rs index 15a68b3c..f682aac5 100644 --- a/cozo-core/src/fixed_rule/mod.rs +++ b/cozo-core/src/fixed_rule/mod.rs @@ -566,7 +566,12 @@ pub trait FixedRule: Send + Sync { /// but implementation is simpler. pub struct SimpleFixedRule { return_arity: usize, - rule: Box, BTreeMap) -> Result + Send + Sync + 'static>, + rule: Box< + dyn Fn(Vec, BTreeMap) -> Result + + Send + + Sync + + 'static, + >, } impl SimpleFixedRule { @@ -580,7 +585,10 @@ impl SimpleFixedRule { // Every row of the returned relation must have length equal to `return_arity`. pub fn new(return_arity: usize, rule: R) -> Self where - R: Fn(Vec, BTreeMap) -> Result + Send + Sync + 'static, + R: Fn(Vec, BTreeMap) -> Result + + Send + + Sync + + 'static, { Self { return_arity, @@ -592,7 +600,11 @@ impl SimpleFixedRule { return_arity: usize, ) -> ( Self, - Receiver<(Vec, BTreeMap, Sender>)>, + Receiver<( + Vec, + BTreeMap, + Sender>, + )>, ) { let (db2app_sender, db2app_receiver) = bounded(0); ( diff --git a/cozo-core/src/fixed_rule/utilities/constant.rs b/cozo-core/src/fixed_rule/utilities/constant.rs index 669d3701..ab3d3175 100644 --- a/cozo-core/src/fixed_rule/utilities/constant.rs +++ b/cozo-core/src/fixed_rule/utilities/constant.rs @@ -12,11 +12,11 @@ use miette::{bail, ensure, Diagnostic, Result}; use smartstring::{LazyCompact, SmartString}; use thiserror::Error; -use crate::fixed_rule::{FixedRule, FixedRulePayload}; use crate::data::expr::Expr; use crate::data::program::WrongFixedRuleOptionError; use crate::data::symb::Symbol; use crate::data::value::DataValue; +use crate::fixed_rule::{FixedRule, FixedRulePayload}; use crate::parse::SourceSpan; use crate::runtime::db::Poison; use crate::runtime::temp_store::RegularTempStore; @@ -76,12 +76,14 @@ impl FixedRule for Constant { options: &mut BTreeMap, Expr>, span: SourceSpan, ) -> Result<()> { - let data = options.get("data").ok_or_else(|| WrongFixedRuleOptionError { - name: "data".to_string(), - span: Default::default(), - rule_name: "Constant".to_string(), - help: "a list of lists is required".to_string(), - })?; + let data = options + .get("data") + .ok_or_else(|| WrongFixedRuleOptionError { + name: "data".to_string(), + span: Default::default(), + rule_name: "Constant".to_string(), + help: "a list of lists is required".to_string(), + })?; let data = match data.clone().eval_to_const()? { DataValue::List(l) => l, _ => bail!(WrongFixedRuleOptionError { diff --git a/cozo-core/src/fixed_rule/utilities/csv.rs b/cozo-core/src/fixed_rule/utilities/csv.rs index cc01820c..19d575a9 100644 --- a/cozo-core/src/fixed_rule/utilities/csv.rs +++ b/cozo-core/src/fixed_rule/utilities/csv.rs @@ -12,15 +12,15 @@ use csv::StringRecord; use miette::{bail, ensure, IntoDiagnostic, Result}; use smartstring::{LazyCompact, SmartString}; -#[cfg(feature = "requests")] -use crate::fixed_rule::utilities::jlines::get_file_content_from_url; -use crate::fixed_rule::{FixedRule, FixedRulePayload, CannotDetermineArity}; use crate::data::expr::Expr; use crate::data::functions::{op_to_float, op_to_uuid, TERMINAL_VALIDITY}; use crate::data::program::{FixedRuleOptionNotFoundError, WrongFixedRuleOptionError}; use crate::data::relation::{ColType, NullableColType}; use crate::data::symb::Symbol; use crate::data::value::DataValue; +#[cfg(feature = "requests")] +use crate::fixed_rule::utilities::jlines::get_file_content_from_url; +use crate::fixed_rule::{CannotDetermineArity, FixedRule, FixedRulePayload}; use crate::parse::{parse_type, SourceSpan}; use crate::runtime::db::Poison; use crate::runtime::temp_store::RegularTempStore; diff --git a/cozo-core/src/fixed_rule/utilities/jlines.rs b/cozo-core/src/fixed_rule/utilities/jlines.rs index 5d18ae03..97b63997 100644 --- a/cozo-core/src/fixed_rule/utilities/jlines.rs +++ b/cozo-core/src/fixed_rule/utilities/jlines.rs @@ -20,11 +20,11 @@ use minreq::Response; use smartstring::{LazyCompact, SmartString}; use thiserror::Error; -use crate::fixed_rule::{FixedRule, FixedRulePayload, CannotDetermineArity}; use crate::data::expr::Expr; use crate::data::json::JsonValue; use crate::data::symb::Symbol; use crate::data::value::DataValue; +use crate::fixed_rule::{CannotDetermineArity, FixedRule, FixedRulePayload}; use crate::parse::SourceSpan; use crate::runtime::db::Poison; use crate::runtime::temp_store::RegularTempStore; diff --git a/cozo-core/src/fixed_rule/utilities/mod.rs b/cozo-core/src/fixed_rule/utilities/mod.rs index e5149992..77a249b8 100644 --- a/cozo-core/src/fixed_rule/utilities/mod.rs +++ b/cozo-core/src/fixed_rule/utilities/mod.rs @@ -11,7 +11,7 @@ pub(crate) mod csv; pub(crate) mod jlines; pub(crate) mod reorder_sort; -pub(crate) use constant::Constant; pub(crate) use self::csv::CsvReader; +pub(crate) use constant::Constant; pub(crate) use jlines::JsonReader; -pub(crate) use reorder_sort::ReorderSort; \ No newline at end of file +pub(crate) use reorder_sort::ReorderSort; diff --git a/cozo-core/src/parse/expr.rs b/cozo-core/src/parse/expr.rs index 03ea79c5..e524074f 100644 --- a/cozo-core/src/parse/expr.rs +++ b/cozo-core/src/parse/expr.rs @@ -15,7 +15,7 @@ use pest::pratt_parser::{Op, PrattParser}; use smartstring::{LazyCompact, SmartString}; use thiserror::Error; -use crate::data::expr::{get_op, Expr, Bytecode}; +use crate::data::expr::{get_op, Bytecode, Expr}; use crate::data::functions::{ OP_ADD, OP_AND, OP_COALESCE, OP_CONCAT, OP_DIV, OP_EQ, OP_GE, OP_GT, OP_LE, OP_LIST, OP_LT, OP_MINUS, OP_MOD, OP_MUL, OP_NEGATE, OP_NEQ, OP_OR, OP_POW, OP_SUB, @@ -55,14 +55,24 @@ pub(crate) struct InvalidExpression(#[label] pub(crate) SourceSpan); pub(crate) fn expr2bytecode(expr: &Expr, collector: &mut Vec) { match expr { - Expr::Binding { var, tuple_pos } => collector.push(Bytecode::Binding { var: var.clone(), tuple_pos: *tuple_pos }), - Expr::Const { val, span } => collector.push(Bytecode::Const { val: val.clone(), span: *span }), + Expr::Binding { var, tuple_pos } => collector.push(Bytecode::Binding { + var: var.clone(), + tuple_pos: *tuple_pos, + }), + Expr::Const { val, span } => collector.push(Bytecode::Const { + val: val.clone(), + span: *span, + }), Expr::Apply { op, args, span } => { let arity = args.len(); for arg in args.iter() { expr2bytecode(arg, collector); } - collector.push(Bytecode::Apply { op, arity, span: *span }) + collector.push(Bytecode::Apply { + op, + arity, + span: *span, + }) } Expr::Cond { clauses, span } => { let mut return_jump_pos = vec![]; @@ -70,11 +80,17 @@ pub(crate) fn expr2bytecode(expr: &Expr, collector: &mut Vec) { // +1 expr2bytecode(cond, collector); // -1 - collector.push(Bytecode::JumpIfFalse { jump_to: 0, span: *span }); + collector.push(Bytecode::JumpIfFalse { + jump_to: 0, + span: *span, + }); let false_jump_amend_pos = collector.len() - 1; // +1 in this branch expr2bytecode(val, collector); - collector.push(Bytecode::Goto { jump_to: 0, span: *span }); + collector.push(Bytecode::Goto { + jump_to: 0, + span: *span, + }); return_jump_pos.push(collector.len() - 1); collector[false_jump_amend_pos] = Bytecode::JumpIfFalse { jump_to: collector.len(), @@ -83,7 +99,10 @@ pub(crate) fn expr2bytecode(expr: &Expr, collector: &mut Vec) { } let total_len = collector.len(); for pos in return_jump_pos { - collector[pos] = Bytecode::Goto { jump_to: total_len, span: *span } + collector[pos] = Bytecode::Goto { + jump_to: total_len, + span: *span, + } } } } @@ -290,7 +309,10 @@ fn build_term(pair: Pair<'_>, param_pool: &BTreeMap) -> Resul .collect_vec(); if let Some((cond, _)) = clauses.last() { match cond { - Expr::Const { val: DataValue::Bool(true), ..} => {} + Expr::Const { + val: DataValue::Bool(true), + .. + } => {} _ => { clauses.push(( Expr::Const { diff --git a/cozo-core/src/parse/sys.rs b/cozo-core/src/parse/sys.rs index 4bcda1e5..6ac089a6 100644 --- a/cozo-core/src/parse/sys.rs +++ b/cozo-core/src/parse/sys.rs @@ -10,7 +10,7 @@ use std::collections::BTreeMap; use std::sync::Arc; use itertools::Itertools; -use miette::{miette, Diagnostic, Result, ensure}; +use miette::{ensure, miette, Diagnostic, Result}; use thiserror::Error; use crate::data::program::InputProgram; @@ -160,7 +160,6 @@ pub(crate) fn parse_sys( .map(|p| Symbol::new(p.as_str(), p.extract_span())) .collect_vec(); - #[derive(Debug, Diagnostic, Error)] #[error("index must have at least one column specified")] #[diagnostic(code(parser::empty_index))] @@ -182,7 +181,7 @@ pub(crate) fn parse_sys( Symbol::new(name.as_str(), name.extract_span()), ) } - _ => unreachable!() + _ => unreachable!(), } } Rule::list_fixed_rules => SysOp::ListFixedRules, diff --git a/cozo-core/src/query/logical.rs b/cozo-core/src/query/logical.rs index a1fdd8dd..986c4c4a 100644 --- a/cozo-core/src/query/logical.rs +++ b/cozo-core/src/query/logical.rs @@ -99,7 +99,7 @@ impl InputAtom { inner: Box::new(a), span, } - .negation_normal_form() + .negation_normal_form() }) .try_collect()?, span, @@ -113,7 +113,7 @@ impl InputAtom { inner: Box::new(a), span, } - .negation_normal_form() + .negation_normal_form() }) .try_collect()?, span, @@ -172,7 +172,7 @@ impl InputAtom { name, args: new_args, span, - valid_at + valid_at, }) } diff --git a/cozo-core/src/query/mod.rs b/cozo-core/src/query/mod.rs index 212b4fe6..1a562ed1 100644 --- a/cozo-core/src/query/mod.rs +++ b/cozo-core/src/query/mod.rs @@ -11,8 +11,8 @@ pub(crate) mod eval; pub(crate) mod graph; pub(crate) mod logical; pub(crate) mod magic; -pub(crate) mod stored; pub(crate) mod ra; pub(crate) mod reorder; +pub(crate) mod sort; +pub(crate) mod stored; pub(crate) mod stratify; -pub(crate) mod sort; \ No newline at end of file diff --git a/cozo-core/src/query/ra.rs b/cozo-core/src/query/ra.rs index fd6fff94..151e2dc7 100644 --- a/cozo-core/src/query/ra.rs +++ b/cozo-core/src/query/ra.rs @@ -16,7 +16,7 @@ use log::{debug, error}; use miette::{bail, Diagnostic, Result}; use thiserror::Error; -use crate::data::expr::{compute_bounds, eval_bytecode, eval_bytecode_pred, Expr, Bytecode}; +use crate::data::expr::{compute_bounds, eval_bytecode, eval_bytecode_pred, Bytecode, Expr}; use crate::data::program::MagicSymbol; use crate::data::relation::{ColType, NullableColType}; use crate::data::symb::Symbol; diff --git a/cozo-core/src/query/stored.rs b/cozo-core/src/query/stored.rs index 896b0472..11dba4b0 100644 --- a/cozo-core/src/query/stored.rs +++ b/cozo-core/src/query/stored.rs @@ -78,9 +78,13 @@ impl<'a> SessionTx<'a> { replaced_old_triggers = Some((old_handle.put_triggers, old_handle.rm_triggers)) } for trigger in &old_handle.replace_triggers { - let program = - parse_script(trigger, &Default::default(), &db.fixed_rules.read().unwrap(), cur_vld)? - .get_single_program()?; + let program = parse_script( + trigger, + &Default::default(), + &db.fixed_rules.read().unwrap(), + cur_vld, + )? + .get_single_program()?; let (_, cleanups) = db .run_query( diff --git a/cozo-core/src/query/stratify.rs b/cozo-core/src/query/stratify.rs index 661dcc8b..5164fadc 100644 --- a/cozo-core/src/query/stratify.rs +++ b/cozo-core/src/query/stratify.rs @@ -14,7 +14,7 @@ use miette::{ensure, Diagnostic, Result}; use thiserror::Error; use crate::data::program::{ - FixedRuleArg, MagicSymbol, NormalFormRulesOrFixed, NormalFormAtom, NormalFormProgram, + FixedRuleArg, MagicSymbol, NormalFormAtom, NormalFormProgram, NormalFormRulesOrFixed, StratifiedNormalFormProgram, }; use crate::data::symb::{Symbol, PROG_ENTRY}; @@ -104,7 +104,9 @@ fn convert_normal_form_program_to_graph( } } else { e.insert( - found_key_is_fixed_rule || found_key_is_meet || is_negated, + found_key_is_fixed_rule + || found_key_is_meet + || is_negated, ); } } @@ -112,7 +114,9 @@ fn convert_normal_form_program_to_graph( let old = *e.get(); let new_val = if has_aggr { if is_meet && k == found_key { - found_key_is_fixed_rule || found_key_is_meet || is_negated + found_key_is_fixed_rule + || found_key_is_meet + || is_negated } else { true } diff --git a/cozo-core/src/runtime/callback.rs b/cozo-core/src/runtime/callback.rs index 1f7fdcfc..9b1886d5 100644 --- a/cozo-core/src/runtime/callback.rs +++ b/cozo-core/src/runtime/callback.rs @@ -37,7 +37,7 @@ impl CallbackOp { pub fn as_str(&self) -> &'static str { match self { CallbackOp::Put => "Put", - CallbackOp::Rm => "Rm" + CallbackOp::Rm => "Rm", } } } diff --git a/cozo-core/src/runtime/imperative.rs b/cozo-core/src/runtime/imperative.rs index ce727ff8..38f0cdc0 100644 --- a/cozo-core/src/runtime/imperative.rs +++ b/cozo-core/src/runtime/imperative.rs @@ -85,32 +85,30 @@ impl<'s, S: Storage<'s>> Db { ImperativeStmt::Continue { target, span, .. } => { return Ok(Right(ControlCode::Continue(target.clone(), *span))); } - ImperativeStmt::Return {returns} => { + ImperativeStmt::Return { returns } => { if returns.is_empty() { - return Ok(Right(ControlCode::Termination(NamedRows::default()))) + return Ok(Right(ControlCode::Termination(NamedRows::default()))); } let mut current = None; for nxt in returns.iter().rev() { let mut nr = match nxt { - Left(prog) => { - self.execute_single_program( - prog.clone(), - tx, - cleanups, - cur_vld, - callback_targets, - callback_collector, - )? - } + Left(prog) => self.execute_single_program( + prog.clone(), + tx, + cleanups, + cur_vld, + callback_targets, + callback_collector, + )?, Right(rel) => { let relation = tx.get_relation(rel, false)?; - relation.as_named_rows(tx)? + relation.as_named_rows(tx)? } }; nr.next = current; current = Some(Box::new(nr)) } - return Ok(Right(ControlCode::Termination(*current.unwrap()))) + return Ok(Right(ControlCode::Termination(*current.unwrap()))); } ImperativeStmt::TempDebug { temp, .. } => { let relation = tx.get_relation(temp, false)?; diff --git a/cozo-core/src/runtime/mod.rs b/cozo-core/src/runtime/mod.rs index a817ea42..c110ece3 100644 --- a/cozo-core/src/runtime/mod.rs +++ b/cozo-core/src/runtime/mod.rs @@ -6,11 +6,11 @@ * You can obtain one at https://mozilla.org/MPL/2.0/. */ +pub(crate) mod callback; pub(crate) mod db; -pub(crate) mod transact; +pub(crate) mod imperative; pub(crate) mod relation; pub(crate) mod temp_store; -pub(crate) mod callback; -pub(crate) mod imperative; #[cfg(test)] mod tests; +pub(crate) mod transact; diff --git a/cozo-core/src/storage/mem.rs b/cozo-core/src/storage/mem.rs index c950e81f..c15e0a6f 100644 --- a/cozo-core/src/storage/mem.rs +++ b/cozo-core/src/storage/mem.rs @@ -6,6 +6,7 @@ * You can obtain one at https://mozilla.org/MPL/2.0/. */ +use crossbeam::sync::{ShardedLock, ShardedLockReadGuard, ShardedLockWriteGuard}; use std::cmp::Ordering; use std::collections::btree_map::Range; use std::collections::BTreeMap; @@ -13,8 +14,7 @@ use std::default::Default; use std::iter::Fuse; use std::mem; use std::ops::Bound; -use std::sync::{Arc}; -use crossbeam::sync::{ShardedLock, ShardedLockReadGuard, ShardedLockWriteGuard}; +use std::sync::Arc; use itertools::Itertools; use miette::{bail, Result}; diff --git a/cozo-core/src/storage/mod.rs b/cozo-core/src/storage/mod.rs index 83ca6615..b8017ac3 100644 --- a/cozo-core/src/storage/mod.rs +++ b/cozo-core/src/storage/mod.rs @@ -20,9 +20,9 @@ pub(crate) mod rocks; pub(crate) mod sled; #[cfg(feature = "storage-sqlite")] pub(crate) mod sqlite; +pub(crate) mod temp; #[cfg(feature = "storage-tikv")] pub(crate) mod tikv; -pub(crate) mod temp; // pub(crate) mod re; /// Swappable storage trait for Cozo's storage engine diff --git a/cozo-lib-c/build.rs b/cozo-lib-c/build.rs index fca1b64c..9b9f2c54 100644 --- a/cozo-lib-c/build.rs +++ b/cozo-lib-c/build.rs @@ -24,13 +24,15 @@ fn main() { .with_autogen_warning( "/* Warning, this file is autogenerated by cbindgen. Don't modify this manually. */", ) - .with_header(r#"/* + .with_header( + r#"/* Copyright 2022, The Cozo Project Authors. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. -*/"#) +*/"#, + ) .with_documentation(true) .generate() .expect("Unable to generate bindings") diff --git a/cozo-lib-java/src/lib.rs b/cozo-lib-java/src/lib.rs index d61ea221..f7267026 100644 --- a/cozo-lib-java/src/lib.rs +++ b/cozo-lib-java/src/lib.rs @@ -177,4 +177,4 @@ pub extern "system" fn Java_org_cozodb_CozoJavaBridge_importFromBackup( env.new_string(res).unwrap().into_raw() } } -} \ No newline at end of file +} diff --git a/cozo-lib-swift/build.rs b/cozo-lib-swift/build.rs index cc4032e3..f92f3b1a 100644 --- a/cozo-lib-swift/build.rs +++ b/cozo-lib-swift/build.rs @@ -10,4 +10,4 @@ fn main() { swift_bridge_build::parse_bridges(bridges) .write_all_concatenated(out_dir, env!("CARGO_PKG_NAME")); -} \ No newline at end of file +} diff --git a/cozorocks/build.rs b/cozorocks/build.rs index d7487dc5..a41a505f 100644 --- a/cozorocks/build.rs +++ b/cozorocks/build.rs @@ -6,9 +6,9 @@ * You can obtain one at https://mozilla.org/MPL/2.0/. */ +use std::env::var; use std::path::{Path, PathBuf}; use std::{env, fs, process::Command}; -use std::env::var; fn main() { let target = env::var("TARGET").unwrap(); @@ -82,8 +82,6 @@ fn main() { println!("cargo:rerun-if-changed=bridge/tx.h"); println!("cargo:rerun-if-changed=bridge/tx.cpp"); - - if !Path::new("rocksdb/AUTHORS").exists() { update_submodules(); } @@ -126,9 +124,7 @@ fn link(name: &str, bundled: bool) { fn fail_on_empty_directory(name: &str) { if fs::read_dir(name).unwrap().count() == 0 { - println!( - "The `{name}` directory is empty, did you forget to pull the submodules?" - ); + println!("The `{name}` directory is empty, did you forget to pull the submodules?"); println!("Try `git submodule update --init --recursive`"); panic!(); } @@ -382,4 +378,4 @@ fn update_submodules() { Ok((false, None)) => panic!("Command got killed"), Err(e) => panic!("Command failed with error: {e}"), } -} \ No newline at end of file +} diff --git a/cozorocks/src/bridge/iter.rs b/cozorocks/src/bridge/iter.rs index 98684664..dbe07b06 100644 --- a/cozorocks/src/bridge/iter.rs +++ b/cozorocks/src/bridge/iter.rs @@ -6,7 +6,6 @@ * You can obtain one at https://mozilla.org/MPL/2.0/. */ - use cxx::UniquePtr; use crate::bridge::ffi::*; diff --git a/cozorocks/src/bridge/mod.rs b/cozorocks/src/bridge/mod.rs index 576fcbe2..366afbaf 100644 --- a/cozorocks/src/bridge/mod.rs +++ b/cozorocks/src/bridge/mod.rs @@ -122,23 +122,10 @@ pub(crate) mod ffi { type RocksDbBridge; fn get_db_path(self: &RocksDbBridge) -> &CxxString; - fn open_db( - builder: &DbOpts, - status: &mut RocksDbStatus, - ) -> UniquePtr; + fn open_db(builder: &DbOpts, status: &mut RocksDbStatus) -> UniquePtr; fn transact(self: &RocksDbBridge) -> UniquePtr; - fn del_range( - self: &RocksDbBridge, - lower: &[u8], - upper: &[u8], - status: &mut RocksDbStatus, - ); - fn put( - self: &RocksDbBridge, - key: &[u8], - val: &[u8], - status: &mut RocksDbStatus, - ); + fn del_range(self: &RocksDbBridge, lower: &[u8], upper: &[u8], status: &mut RocksDbStatus); + fn put(self: &RocksDbBridge, key: &[u8], val: &[u8], status: &mut RocksDbStatus); fn compact_range( self: &RocksDbBridge, lower: &[u8], @@ -175,18 +162,8 @@ pub(crate) mod ffi { for_update: bool, status: &mut RocksDbStatus, ) -> UniquePtr; - fn exists( - self: &TxBridge, - key: &[u8], - for_update: bool, - status: &mut RocksDbStatus, - ); - fn put( - self: &TxBridge, - key: &[u8], - val: &[u8], - status: &mut RocksDbStatus, - ); + fn exists(self: &TxBridge, key: &[u8], for_update: bool, status: &mut RocksDbStatus); + fn put(self: &TxBridge, key: &[u8], val: &[u8], status: &mut RocksDbStatus); fn del(self: &TxBridge, key: &[u8], status: &mut RocksDbStatus); fn commit(self: Pin<&mut TxBridge>, status: &mut RocksDbStatus); fn rollback(self: Pin<&mut TxBridge>, status: &mut RocksDbStatus); diff --git a/cozoserver/src/main.rs b/cozoserver/src/main.rs index c0ec1dae..0c6bdbab 100644 --- a/cozoserver/src/main.rs +++ b/cozoserver/src/main.rs @@ -12,6 +12,7 @@ use std::fs; use std::net::Ipv6Addr; use std::process::exit; use std::str::FromStr; +use std::sync::Arc; use clap::Parser; use env_logger::Env; @@ -77,12 +78,14 @@ fn main() { eprintln!("{SECURITY_WARNING}"); } - let db = DbInstance::new( - args.engine.as_str(), - args.path.as_str(), - &args.config.clone(), - ) - .unwrap(); + let db = Arc::new( + DbInstance::new( + args.engine.as_str(), + args.path.as_str(), + &args.config.clone(), + ) + .unwrap(), + ); if let Some(restore_path) = &args.restore { db.restore_backup(restore_path).unwrap(); @@ -114,7 +117,7 @@ fn main() { } } -fn server_main(args: Args, db: DbInstance) { +fn server_main(args: Args, db: Arc) { let conf_path = format!("{}.{}.cozo_auth", args.path, args.engine); let auth_guard = match fs::read_to_string(&conf_path) { Ok(s) => s.trim().to_string(), diff --git a/cozoserver/src/repl.rs b/cozoserver/src/repl.rs index 6b0a4e5d..f76871aa 100644 --- a/cozoserver/src/repl.rs +++ b/cozoserver/src/repl.rs @@ -12,6 +12,7 @@ use std::collections::BTreeMap; use std::error::Error; use std::fs::File; use std::io::{Read, Write}; +use std::sync::Arc; use miette::{bail, miette, IntoDiagnostic}; use serde_json::{json, Value}; @@ -57,7 +58,7 @@ impl rustyline::validate::Validator for Indented { } } -pub(crate) fn repl_main(db: DbInstance) -> Result<(), Box> { +pub(crate) fn repl_main(db: Arc) -> Result<(), Box> { println!("Welcome to the Cozo REPL."); println!("Type a space followed by newline to enter multiline mode.");