Skip to content

Commit d134995

Browse files
committed
make everything compile again
1 parent 3b29579 commit d134995

19 files changed

Lines changed: 76 additions & 138 deletions

File tree

cozo-core/Cargo.toml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ exclude = [
1717

1818
default = ["compact"]
1919
## Enables the `minimal`, `requests` and `graph-algo` features.
20-
compact = ["minimal", "requests", "graph-algo", "rayon"]
20+
compact = ["minimal", "requests", "graph-algo"]
2121
## Enables the `minimal`, `requests` and `graph-algo` features in single threaded mode.
2222
compact-single-threaded = ["minimal", "requests", "graph-algo"]
2323
## Enables the `storage-sqlite` feature.
@@ -33,7 +33,7 @@ storage-sqlite = ["dep:sqlite", "dep:sqlite3-src"]
3333
## You can also [fine-tune](https://github.com/cozodb/cozo/blob/main/TUNING_ROCKSDB.md) RocksDB options.
3434
storage-rocksdb = ["dep:cozorocks"]
3535
## Enables the graph algorithms.
36-
graph-algo = []
36+
graph-algo = ["graph", "rayon"]
3737
## Allows the utilities to make web requests to fetch data.
3838
requests = ["dep:minreq"]
3939
## Uses jemalloc as the global allocator, can make a difference in performance.
@@ -42,10 +42,6 @@ jemalloc = ["dep:tikv-jemallocator-global", "cozorocks?/jemalloc"]
4242
io-uring = ["cozorocks?/io-uring"]
4343
## Polyfills for the WASM target
4444
wasm = ["uuid/js", "dep:js-sys"]
45-
## Allows threading and enables the use of the `rayon` library for parallelizing algorithms.
46-
rayon = ["dep:rayon", "dep:graph"]
47-
## Disallows the use of threads.
48-
nothread = []
4945

5046
#! The following features are highly experimental:
5147

@@ -67,12 +63,6 @@ storage-tikv = ["dep:tikv-client", "dep:tokio"]
6763
#! (utilities are still available),
6864
#! which could be OK if you only want to deal with pure Datalog.
6965
#!
70-
#! If having multiple threads
71-
#! running in the background is undesirable, you can enable the `nothread` feature.
72-
#!
73-
#! The `rayon` feature enables some algorithms to make use of parallelism. This is desirable in most circumstances.
74-
#! Naturally, it is incompatible with `nothread`.
75-
#!
7666
#! The `requests` feature allows the database to make outgoing HTTP requests to fetch data
7767
#! into queries -- only enable it if you need it.
7868
#!

cozo-core/src/data/functions.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use std::time::{SystemTime, UNIX_EPOCH};
1313

1414
use chrono::{DateTime, TimeZone, Utc};
1515
use itertools::Itertools;
16-
#[cfg(feature = "wasm")]
16+
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
1717
use js_sys::Date;
1818
use miette::{bail, ensure, miette, Result};
1919
use num_traits::FloatConst;
@@ -1462,12 +1462,12 @@ pub(crate) fn op_to_uuid(args: &[DataValue]) -> Result<DataValue> {
14621462
}
14631463

14641464
define_op!(OP_NOW, 0, false);
1465-
#[cfg(feature = "wasm")]
1465+
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
14661466
pub(crate) fn op_now(_args: &[DataValue]) -> Result<DataValue> {
14671467
let d: f64 = Date::now() / 1000.;
14681468
Ok(DataValue::from(d))
14691469
}
1470-
#[cfg(not(feature = "wasm"))]
1470+
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
14711471
pub(crate) fn op_now(_args: &[DataValue]) -> Result<DataValue> {
14721472
let now = SystemTime::now();
14731473
Ok(DataValue::from(
@@ -1477,12 +1477,12 @@ pub(crate) fn op_now(_args: &[DataValue]) -> Result<DataValue> {
14771477

14781478
define_op!(OP_FORMAT_TIMESTAMP, 1, true);
14791479
pub(crate) fn op_format_timestamp(args: &[DataValue]) -> Result<DataValue> {
1480-
#[cfg(feature = "wasm")]
1480+
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
14811481
let dt = Utc
14821482
.timestamp_millis_opt(Date::now() as i64)
14831483
.latest()
14841484
.ok_or_else(|| miette!("bad time input"))?;
1485-
#[cfg(not(feature = "wasm"))]
1485+
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
14861486
let dt = {
14871487
let f = args[0]
14881488
.get_float()
@@ -1526,14 +1526,14 @@ define_op!(OP_RAND_UUID_V1, 0, false);
15261526
pub(crate) fn op_rand_uuid_v1(_args: &[DataValue]) -> Result<DataValue> {
15271527
let mut rng = rand::thread_rng();
15281528
let uuid_ctx = uuid::v1::Context::new(rng.gen());
1529-
#[cfg(feature = "wasm")]
1529+
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
15301530
let ts = {
15311531
let since_epoch: f64 = Date::now();
15321532
let seconds = since_epoch.floor();
15331533
let fractional = (since_epoch - seconds) * 1.0e9;
15341534
Timestamp::from_unix(uuid_ctx, seconds as u64, fractional as u32)
15351535
};
1536-
#[cfg(not(feature = "wasm"))]
1536+
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
15371537
let ts = {
15381538
let now = SystemTime::now();
15391539
let since_epoch = now.duration_since(UNIX_EPOCH).unwrap();

cozo-core/src/fixed_rule/algos/mod.rs

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,38 @@
66
* You can obtain one at https://mozilla.org/MPL/2.0/.
77
*/
88

9-
#[cfg(feature = "graph-algo")]
109
pub(crate) mod all_pairs_shortest_path;
11-
#[cfg(feature = "graph-algo")]
1210
pub(crate) mod astar;
13-
#[cfg(feature = "graph-algo")]
1411
pub(crate) mod bfs;
15-
#[cfg(feature = "graph-algo")]
1612
pub(crate) mod degree_centrality;
17-
#[cfg(feature = "graph-algo")]
1813
pub(crate) mod dfs;
19-
#[cfg(feature = "graph-algo")]
2014
pub(crate) mod kruskal;
21-
#[cfg(feature = "graph-algo")]
2215
pub(crate) mod label_propagation;
23-
#[cfg(feature = "graph-algo")]
2416
pub(crate) mod louvain;
25-
#[cfg(feature = "graph-algo")]
2617
pub(crate) mod pagerank;
27-
#[cfg(feature = "graph-algo")]
2818
pub(crate) mod prim;
29-
#[cfg(feature = "graph-algo")]
3019
pub(crate) mod shortest_path_dijkstra;
3120
pub(crate) mod strongly_connected_components;
32-
#[cfg(feature = "graph-algo")]
3321
pub(crate) mod top_sort;
34-
#[cfg(feature = "graph-algo")]
3522
pub(crate) mod triangles;
36-
#[cfg(feature = "graph-algo")]
3723
pub(crate) mod yen;
38-
#[cfg(feature = "graph-algo")]
3924
pub(crate) mod shortest_path_bfs;
25+
pub(crate) mod random_walk;
26+
27+
pub(crate) use all_pairs_shortest_path::{BetweennessCentrality, ClosenessCentrality};
28+
pub(crate) use astar::ShortestPathAStar;
29+
pub(crate) use bfs::Bfs;
30+
pub(crate) use degree_centrality::DegreeCentrality;
31+
pub(crate) use dfs::Dfs;
32+
pub(crate) use kruskal::MinimumSpanningForestKruskal;
33+
pub(crate) use label_propagation::LabelPropagation;
34+
pub(crate) use louvain::CommunityDetectionLouvain;
35+
pub(crate) use pagerank::PageRank;
36+
pub(crate) use prim::MinimumSpanningTreePrim;
37+
pub(crate) use shortest_path_dijkstra::ShortestPathDijkstra;
38+
pub(crate) use strongly_connected_components::StronglyConnectedComponent;
39+
pub(crate) use top_sort::TopSort;
40+
pub(crate) use triangles::ClusteringCoefficients;
41+
pub(crate) use yen::KShortestPathYen;
42+
pub(crate) use shortest_path_bfs::ShortestPathBFS;
43+
pub(crate) use random_walk::RandomWalk;
File renamed without changes.

cozo-core/src/fixed_rule/mod.rs

Lines changed: 8 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@
99
use std::collections::BTreeMap;
1010
use std::sync::Arc;
1111

12+
#[allow(unused_imports)]
1213
use either::{Left, Right};
14+
#[cfg(feature = "graph-algo")]
1315
use graph::prelude::{CsrLayout, DirectedCsrGraph, GraphBuilder};
1416
use lazy_static::lazy_static;
17+
#[allow(unused_imports)]
1518
use miette::{bail, ensure, Diagnostic, Report, Result};
1619
use smartstring::{LazyCompact, SmartString};
1720
use thiserror::Error;
@@ -25,49 +28,14 @@ use crate::data::symb::Symbol;
2528
use crate::data::tuple::TupleIter;
2629
use crate::data::value::DataValue;
2730
#[cfg(feature = "graph-algo")]
28-
use crate::fixed_rule::algos::all_pairs_shortest_path::{
29-
BetweennessCentrality, ClosenessCentrality,
30-
};
31-
#[cfg(feature = "graph-algo")]
32-
use crate::fixed_rule::algos::astar::ShortestPathAStar;
33-
#[cfg(feature = "graph-algo")]
34-
use crate::fixed_rule::algos::bfs::Bfs;
35-
#[cfg(feature = "graph-algo")]
36-
use crate::fixed_rule::algos::degree_centrality::DegreeCentrality;
37-
#[cfg(feature = "graph-algo")]
38-
use crate::fixed_rule::algos::dfs::Dfs;
39-
#[cfg(feature = "graph-algo")]
40-
use crate::fixed_rule::algos::kruskal::MinimumSpanningForestKruskal;
41-
#[cfg(feature = "graph-algo")]
42-
use crate::fixed_rule::algos::label_propagation::LabelPropagation;
43-
#[cfg(feature = "graph-algo")]
44-
use crate::fixed_rule::algos::louvain::CommunityDetectionLouvain;
45-
#[cfg(feature = "graph-algo")]
46-
use crate::fixed_rule::algos::pagerank::PageRank;
47-
#[cfg(feature = "graph-algo")]
48-
use crate::fixed_rule::algos::prim::MinimumSpanningTreePrim;
49-
#[cfg(feature = "graph-algo")]
50-
use crate::fixed_rule::algos::shortest_path_bfs::ShortestPathBFS;
51-
#[cfg(feature = "graph-algo")]
52-
use crate::fixed_rule::algos::shortest_path_dijkstra::ShortestPathDijkstra;
53-
#[cfg(feature = "graph-algo")]
54-
use crate::fixed_rule::algos::strongly_connected_components::StronglyConnectedComponent;
55-
#[cfg(feature = "graph-algo")]
56-
use crate::fixed_rule::algos::top_sort::TopSort;
57-
#[cfg(feature = "graph-algo")]
58-
use crate::fixed_rule::algos::triangles::ClusteringCoefficients;
59-
#[cfg(feature = "graph-algo")]
60-
use crate::fixed_rule::algos::yen::KShortestPathYen;
61-
use crate::fixed_rule::utilities::constant::Constant;
62-
use crate::fixed_rule::utilities::csv::CsvReader;
63-
use crate::fixed_rule::utilities::jlines::JsonReader;
64-
use crate::fixed_rule::utilities::random_walk::RandomWalk;
65-
use crate::fixed_rule::utilities::reorder_sort::ReorderSort;
31+
use crate::fixed_rule::algos::*;
32+
use crate::fixed_rule::utilities::*;
6633
use crate::parse::SourceSpan;
6734
use crate::runtime::db::Poison;
6835
use crate::runtime::temp_store::{EpochStore, RegularTempStore};
6936
use crate::runtime::transact::SessionTx;
7037

38+
#[cfg(feature = "graph-algo")]
7139
pub(crate) mod algos;
7240
pub(crate) mod utilities;
7341

@@ -138,6 +106,7 @@ impl<'a, 'b> FixedRuleInputRelation<'a, 'b> {
138106
pub fn span(&self) -> SourceSpan {
139107
self.arg_manifest.span()
140108
}
109+
#[cfg(feature = "graph-algo")]
141110
pub fn to_directed_graph(
142111
&self,
143112
undirected: bool,
@@ -203,7 +172,7 @@ impl<'a, 'b> FixedRuleInputRelation<'a, 'b> {
203172
}
204173
Ok((graph, indices, inv_indices))
205174
}
206-
175+
#[cfg(feature = "graph-algo")]
207176
pub fn to_directed_weighted_graph(
208177
&self,
209178
undirected: bool,

cozo-core/src/fixed_rule/utilities/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,9 @@
99
pub(crate) mod constant;
1010
pub(crate) mod csv;
1111
pub(crate) mod jlines;
12-
pub(crate) mod random_walk;
1312
pub(crate) mod reorder_sort;
13+
14+
pub(crate) use constant::Constant;
15+
pub(crate) use self::csv::CsvReader;
16+
pub(crate) use jlines::JsonReader;
17+
pub(crate) use reorder_sort::ReorderSort;

cozo-core/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,17 +177,17 @@ impl DbInstance {
177177
payload: &str,
178178
params: BTreeMap<String, JsonValue>,
179179
) -> JsonValue {
180-
#[cfg(not(feature = "wasm"))]
180+
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
181181
let start = Instant::now();
182182

183183
match self.run_script(payload, params) {
184184
Ok(named_rows) => {
185185
let mut j_val = named_rows.into_json();
186-
#[cfg(not(feature = "wasm"))]
186+
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
187187
let took = start.elapsed().as_secs_f64();
188188
let map = j_val.as_object_mut().unwrap();
189189
map.insert("ok".to_string(), json!(true));
190-
#[cfg(not(feature = "wasm"))]
190+
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
191191
map.insert("took".to_string(), json!(took));
192192

193193
j_val

cozo-core/src/parse/query.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,10 @@ pub(crate) fn parse_query(
238238
out_opts.timeout = Some(timeout);
239239
}
240240
Rule::sleep_option => {
241-
#[cfg(feature = "wasm")]
241+
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
242242
bail!(":sleep is not supported under WASM");
243-
#[cfg(not(feature = "wasm"))]
243+
244+
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
244245
{
245246
let pair = pair.into_inner().next().unwrap();
246247
let span = pair.extract_span();

cozo-core/src/runtime/db.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ impl<'s, S: Storage<'s>> Db<S> {
507507
let (q_res, q_cleanups) = self.run_query(&mut tx, p)?;
508508
res = q_res;
509509
cleanups.extend(q_cleanups);
510-
#[cfg(not(feature = "wasm"))]
510+
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
511511
if let Some(secs) = sleep_opt {
512512
thread::sleep(Duration::from_micros((secs * 1000000.) as u64));
513513
}
@@ -867,15 +867,15 @@ impl<'s, S: Storage<'s>> Db<S> {
867867
let id = self.queries_count.fetch_add(1, Ordering::AcqRel);
868868

869869
// time the query
870-
#[cfg(not(feature = "wasm"))]
870+
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
871871
let now = SystemTime::now();
872-
#[cfg(not(feature = "wasm"))]
872+
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
873873
let since_the_epoch = now
874874
.duration_since(UNIX_EPOCH)
875875
.into_diagnostic()?
876876
.as_secs_f64();
877877

878-
#[cfg(feature = "wasm")]
878+
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
879879
let since_the_epoch = js_sys::Date::now();
880880

881881
let handle = RunningQueryHandle {
@@ -1151,11 +1151,11 @@ impl Poison {
11511151
}
11521152
Ok(())
11531153
}
1154-
#[cfg(feature = "nothread")]
1154+
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
11551155
pub(crate) fn set_timeout(&self, _secs: f64) -> Result<()> {
11561156
bail!("Cannot set timeout when threading is disallowed");
11571157
}
1158-
#[cfg(not(feature = "nothread"))]
1158+
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
11591159
pub(crate) fn set_timeout(&self, secs: f64) -> Result<()> {
11601160
let pill = self.clone();
11611161
thread::spawn(move || {

cozo-core/src/storage/mem.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ impl<'s> Storage<'s> for MemStorage {
6767
wtr.remove(k);
6868
}
6969
};
70-
#[cfg(feature = "nothread")]
70+
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
7171
closure();
72-
#[cfg(not(feature = "nothread"))]
72+
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
7373
std::thread::spawn(closure);
7474
Ok(())
7575
}

0 commit comments

Comments
 (0)