diff --git a/.gitignore b/.gitignore index 4a6505cb..2558c1ef 100644 --- a/.gitignore +++ b/.gitignore @@ -37,4 +37,5 @@ release* Cross.toml /tools *.cozo_auth -.cozo_repl_history \ No newline at end of file +.cozo_repl_history +/venv/ \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 5d717d50..885e99ce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -677,7 +677,7 @@ checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" [[package]] name = "cozo" -version = "0.5.1" +version = "0.6.0" dependencies = [ "approx", "base64 0.21.0", @@ -730,7 +730,7 @@ dependencies = [ [[package]] name = "cozo-bin" -version = "0.5.1" +version = "0.6.0" dependencies = [ "async-stream", "axum", @@ -759,7 +759,7 @@ dependencies = [ [[package]] name = "cozo-lib-wasm" -version = "0.5.1" +version = "0.6.0" dependencies = [ "console_error_panic_hook", "cozo", @@ -770,7 +770,7 @@ dependencies = [ [[package]] name = "cozo-node" -version = "0.5.1" +version = "0.6.0" dependencies = [ "cozo", "crossbeam", @@ -781,7 +781,7 @@ dependencies = [ [[package]] name = "cozo-swift" -version = "0.5.1" +version = "0.6.0" dependencies = [ "cozo", "swift-bridge", @@ -790,7 +790,7 @@ dependencies = [ [[package]] name = "cozo_c" -version = "0.5.1" +version = "0.6.0" dependencies = [ "cbindgen", "cozo", @@ -799,7 +799,7 @@ dependencies = [ [[package]] name = "cozo_java" -version = "0.5.1" +version = "0.6.0" dependencies = [ "cozo", "jni", @@ -808,7 +808,7 @@ dependencies = [ [[package]] name = "cozo_py" -version = "0.5.1" +version = "0.6.0" dependencies = [ "cozo", "miette", @@ -817,7 +817,7 @@ dependencies = [ [[package]] name = "cozorocks" -version = "0.1.5" +version = "0.1.6" dependencies = [ "cc", "cxx", diff --git a/VERSION b/VERSION index 5d4294b9..09a3acfa 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5.1 \ No newline at end of file +0.6.0 \ No newline at end of file diff --git a/cozo-bin/Cargo.toml b/cozo-bin/Cargo.toml index e3212ac6..8e97c2fb 100644 --- a/cozo-bin/Cargo.toml +++ b/cozo-bin/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cozo-bin" -version = "0.5.1" +version = "0.6.0" edition = "2021" license = "MPL-2.0" description = "Standalone Cozo database" @@ -42,7 +42,7 @@ storage-tikv = ["cozo/storage-tikv"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -cozo = { version = "0.5.1", path = "../cozo-core", default-features = false } +cozo = { version = "0.6.0", path = "../cozo-core", default-features = false } clap = { version = "4.0.26", features = ["derive"] } env_logger = "0.10.0" log = "0.4.17" diff --git a/cozo-core/Cargo.toml b/cozo-core/Cargo.toml index 8dd0a527..c1a135f2 100644 --- a/cozo-core/Cargo.toml +++ b/cozo-core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cozo" -version = "0.5.1" +version = "0.6.0" edition = "2021" description = "A general-purpose, transactional, relational database that uses Datalog and focuses on graph data and algorithms" authors = ["Ziyang Hu"] @@ -118,7 +118,7 @@ document-features = "0.2.6" rayon = { version = "1.5.3", optional = true } minreq = { version = "2.6.0", features = ["https-rustls"], optional = true } tikv-jemallocator-global = { version = "0.5.0", optional = true } -cozorocks = { path = "../cozorocks", version = "0.1.5", optional = true } +cozorocks = { path = "../cozorocks", version = "0.1.6", optional = true } sled = { version = "0.34.7", optional = true } tikv-client = { version = "0.1.0", optional = true } tokio = { version = "1.21.2", optional = true } diff --git a/cozo-core/src/data/value.rs b/cozo-core/src/data/value.rs index 129c6006..e46a001e 100644 --- a/cozo-core/src/data/value.rs +++ b/cozo-core/src/data/value.rs @@ -158,26 +158,23 @@ pub enum DataValue { Bot, } +/// Vector of floating numbers #[derive(Debug, Clone, serde_derive::Serialize, serde_derive::Deserialize)] pub enum Vector { + /// 32-bit float array F32(Array1), + /// 64-bit float array F64(Array1), } impl Vector { + /// Get the length of the vector pub fn len(&self) -> usize { match self { Vector::F32(v) => v.len(), Vector::F64(v) => v.len(), } } - pub fn is_compatible(&self, other: &Self) -> bool { - match (self, other) { - (Vector::F32(_), Vector::F32(_)) => true, - (Vector::F64(_), Vector::F64(_)) => true, - _ => false, - } - } pub(crate) fn el_type(&self) -> VecElementType { match self { Vector::F32(_) => VecElementType::F32, diff --git a/cozo-core/src/lib.rs b/cozo-core/src/lib.rs index 1a9c56a8..b3a237c6 100644 --- a/cozo-core/src/lib.rs +++ b/cozo-core/src/lib.rs @@ -68,6 +68,7 @@ pub use storage::{Storage, StoreTx}; pub use crate::data::expr::Expr; use crate::data::json::JsonValue; pub use crate::data::symb::Symbol; +pub use crate::data::value::Vector; pub use crate::fixed_rule::SimpleFixedRule; pub use crate::parse::SourceSpan; pub use crate::runtime::callback::CallbackOp; diff --git a/cozo-lib-c/Cargo.toml b/cozo-lib-c/Cargo.toml index 2c7725de..945a66c4 100644 --- a/cozo-lib-c/Cargo.toml +++ b/cozo-lib-c/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cozo_c" -version = "0.5.1" +version = "0.6.0" edition = "2021" license = "MPL-2.0" homepage = "https://www.cozodb.org" @@ -38,7 +38,7 @@ io-uring = ["cozo/io-uring"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -cozo = { version = "0.5.1", path = "../cozo-core", default_features = false } +cozo = { version = "0.6.0", path = "../cozo-core", default_features = false } lazy_static = "1.4.0" [build-dependencies] diff --git a/cozo-lib-java/Cargo.toml b/cozo-lib-java/Cargo.toml index edfcbd5f..eb17c7c4 100644 --- a/cozo-lib-java/Cargo.toml +++ b/cozo-lib-java/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cozo_java" -version = "0.5.1" +version = "0.6.0" edition = "2021" license = "MPL-2.0" homepage = "https://www.cozodb.org" @@ -40,5 +40,5 @@ io-uring = ["cozo/io-uring"] [dependencies] jni = "0.21.0" # , features = ["compact"] -cozo = { version = "0.5.1", path = "../cozo-core", default_features = false, features = ["compact"] } +cozo = { version = "0.6.0", path = "../cozo-core", default_features = false, features = ["compact"] } lazy_static = "1.4.0" diff --git a/cozo-lib-nodejs/Cargo.toml b/cozo-lib-nodejs/Cargo.toml index 73e335a3..e3689f44 100644 --- a/cozo-lib-nodejs/Cargo.toml +++ b/cozo-lib-nodejs/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cozo-node" -version = "0.5.1" +version = "0.6.0" description = "Cozo database for NodeJS" authors = ["Ziyang Hu"] license = "MPL-2.0" @@ -40,7 +40,7 @@ io-uring = ["cozo/io-uring"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -cozo = { version = "0.5.1", path = "../cozo-core", default-features = false } +cozo = { version = "0.6.0", path = "../cozo-core", default-features = false } lazy_static = "1.4.0" crossbeam = "0.8.2" miette = "5.5.0" diff --git a/cozo-lib-nodejs/package.json b/cozo-lib-nodejs/package.json index 5f61b57d..5f601f3a 100644 --- a/cozo-lib-nodejs/package.json +++ b/cozo-lib-nodejs/package.json @@ -1,6 +1,6 @@ { "name": "cozo-node", - "version": "0.5.1", + "version": "0.6.0", "description": "Cozo database for NodeJS", "main": "index", "files": [ diff --git a/cozo-lib-nodejs/src/lib.rs b/cozo-lib-nodejs/src/lib.rs index 80f34114..bc621cb8 100644 --- a/cozo-lib-nodejs/src/lib.rs +++ b/cozo-lib-nodejs/src/lib.rs @@ -126,6 +126,24 @@ fn value2js<'a>(cx: &mut impl Context<'a>, val: &DataValue) -> JsResult<'a, JsVa target_l.as_value(cx) } DataValue::Bot => cx.undefined().as_value(cx), + DataValue::Vec(v) => { + let target_l = cx.empty_array(); + match v { + Vector::F32(a) => { + for (i, el) in a.iter().enumerate() { + let el = cx.number(*el as f64); + target_l.set(cx, i as u32, el)?; + } + } + Vector::F64(a) => { + for (i, el) in a.iter().enumerate() { + let el = cx.number(*el); + target_l.set(cx, i as u32, el)?; + } + } + } + target_l.as_value(cx) + } }) } diff --git a/cozo-lib-python/Cargo.toml b/cozo-lib-python/Cargo.toml index 01106206..18967780 100644 --- a/cozo-lib-python/Cargo.toml +++ b/cozo-lib-python/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cozo_py" -version = "0.5.1" +version = "0.6.0" edition = "2021" description = "Cozo database for python" authors = ["Ziyang Hu"] @@ -41,6 +41,6 @@ io-uring = ["cozo/io-uring"] [dependencies] -cozo = { version = "0.5.1", path = "../cozo-core", default-features = false } +cozo = { version = "0.6.0", path = "../cozo-core", default-features = false } pyo3 = { version = "0.18.0", features = ["extension-module", "abi3", "abi3-py37"] } miette = "5.5.0" \ No newline at end of file diff --git a/cozo-lib-python/src/lib.rs b/cozo-lib-python/src/lib.rs index 9c407b90..95bdbdb8 100644 --- a/cozo-lib-python/src/lib.rs +++ b/cozo-lib-python/src/lib.rs @@ -119,6 +119,18 @@ fn value_to_py(val: DataValue, py: Python<'_>) -> PyObject { [vld.timestamp.0 .0.into_py(py), vld.is_assert.0.into_py(py)].into_py(py) } DataValue::Bot => py.None(), + DataValue::Vec(v) => { + match v { + Vector::F32(a) => { + let vs: Vec<_> = a.into_iter().map(|v| v.into_py(py)).collect(); + vs.into_py(py) + } + Vector::F64(a) => { + let vs: Vec<_> = a.into_iter().map(|v| v.into_py(py)).collect(); + vs.into_py(py) + } + } + } } } diff --git a/cozo-lib-swift/Cargo.toml b/cozo-lib-swift/Cargo.toml index b6793696..068712f4 100644 --- a/cozo-lib-swift/Cargo.toml +++ b/cozo-lib-swift/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cozo-swift" -version = "0.5.1" +version = "0.6.0" edition = "2021" description = "Cozo database for Swift" authors = ["Ziyang Hu"] @@ -40,5 +40,5 @@ io-uring = ["cozo/io-uring"] swift-bridge-build = "0.1.41" [dependencies] -cozo = { version = "0.5.1", path = "../cozo-core", default-features = false } +cozo = { version = "0.6.0", path = "../cozo-core", default-features = false } swift-bridge = "0.1.41" diff --git a/cozo-lib-swift/CozoSwiftBridge.podspec b/cozo-lib-swift/CozoSwiftBridge.podspec index 96ce7e01..b95aa136 100644 --- a/cozo-lib-swift/CozoSwiftBridge.podspec +++ b/cozo-lib-swift/CozoSwiftBridge.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = "CozoSwiftBridge" - spec.version = "0.5.1" + spec.version = "0.6.0" spec.summary = "CozoDB for Swift" spec.description = "This library allows you to use CozoDB embedded in your Swift application" spec.homepage = "https://github.com/cozodb/cozo/" diff --git a/cozo-lib-swift/README-zh.md b/cozo-lib-swift/README-zh.md index c5b1df29..22b50111 100644 --- a/cozo-lib-swift/README-zh.md +++ b/cozo-lib-swift/README-zh.md @@ -16,7 +16,7 @@ target 'YourApp' do use_frameworks! - pod 'CozoSwiftBridge', '~> 0.5.1' + pod 'CozoSwiftBridge', '~> 0.6.0' end ``` diff --git a/cozo-lib-swift/README.md b/cozo-lib-swift/README.md index 54da60f4..e6f27a3b 100644 --- a/cozo-lib-swift/README.md +++ b/cozo-lib-swift/README.md @@ -19,7 +19,7 @@ see the Building section below. target 'YourApp' do use_frameworks! - pod 'CozoSwiftBridge', '~> 0.5.1' + pod 'CozoSwiftBridge', '~> 0.6.0' end ``` diff --git a/cozo-lib-wasm/Cargo.toml b/cozo-lib-wasm/Cargo.toml index 70f74a56..3e6a70e2 100644 --- a/cozo-lib-wasm/Cargo.toml +++ b/cozo-lib-wasm/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cozo-lib-wasm" -version = "0.5.1" +version = "0.6.0" edition = "2021" description = "Cozo database for WASM" authors = ["Ziyang Hu"] @@ -17,7 +17,7 @@ default = ["console_error_panic_hook"] [dependencies] wasm-bindgen = "0.2.63" -cozo = { version = "0.5.1", path = "../cozo-core", default-features = false, features = ["wasm"] } +cozo = { version = "0.6.0", path = "../cozo-core", default-features = false, features = ["wasm"] } # The `console_error_panic_hook` crate provides better debugging of panics by # logging them with `console.error`. This is great for development, but requires diff --git a/cozorocks/Cargo.toml b/cozorocks/Cargo.toml index da658a8e..f32aa095 100644 --- a/cozorocks/Cargo.toml +++ b/cozorocks/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cozorocks" -version = "0.1.5" +version = "0.1.6" edition = "2021" license = "MPL-2.0" authors = ["Ziyang Hu"]