Improves documentation

pull/190/head
Tpt 3 years ago
parent 6862a1226c
commit 4efd193708
  1. 110
      Cargo.lock
  2. 6
      lib/Cargo.toml
  3. 5
      lib/README.md
  4. 2
      lib/oxrdf/Cargo.toml
  5. 2
      lib/oxrdf/README.md
  6. 12
      lib/oxrdf/src/blank_node.rs
  7. 46
      lib/oxrdf/src/dataset.rs
  8. 24
      lib/oxrdf/src/graph.rs
  9. 2
      lib/oxrdf/src/lib.rs
  10. 2
      lib/oxrdf/src/literal.rs
  11. 2
      lib/oxrdf/src/parser.rs
  12. 8
      lib/oxrdf/src/triple.rs
  13. 89
      lib/oxrdf/src/vocab.rs
  14. 4
      lib/sparesults/Cargo.toml
  15. 2
      lib/sparesults/README.md
  16. 2
      lib/sparesults/src/lib.rs
  17. 2
      lib/sparesults/src/solution.rs
  18. 4
      lib/spargebra/Cargo.toml
  19. 102
      lib/spargebra/src/algebra.rs
  20. 2
      lib/spargebra/src/lib.rs
  21. 34
      lib/spargebra/src/query.rs
  22. 20
      lib/spargebra/src/update.rs
  23. 2
      lib/src/model.rs
  24. 13
      lib/src/sparql/error.rs
  25. 2
      lib/src/sparql/mod.rs
  26. 2
      lib/src/sparql/model.rs
  27. 32
      lib/src/store.rs
  28. 2
      lib/src/xsd/decimal.rs
  29. 4
      python/docs/model.rst
  30. 16
      python/src/model.rs
  31. 3
      python/src/store.rs
  32. 2
      server/Cargo.toml
  33. 6
      testsuite/src/sparql_evaluator.rs

110
Cargo.lock generated

@ -33,9 +33,9 @@ dependencies = [
[[package]] [[package]]
name = "anyhow" name = "anyhow"
version = "1.0.52" version = "1.0.53"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84450d0b4a8bd1ba4144ce8ce718fbc5d071358b1e5384bace6536b3d1f2d5b3" checksum = "94a45b455c14666b85fc40a019e8ab9eb75e3a124e05494f5397122bc9eb06e0"
[[package]] [[package]]
name = "atty" name = "atty"
@ -177,9 +177,9 @@ dependencies = [
[[package]] [[package]]
name = "clap" name = "clap"
version = "3.0.7" version = "3.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12e8611f9ae4e068fa3e56931fded356ff745e70987ff76924a6e0ab1c8ef2e3" checksum = "7a30c3bf9ff12dfe5dae53f0a96e0febcd18420d1c0e7fad77796d9d5c4b5375"
dependencies = [ dependencies = [
"atty", "atty",
"bitflags", "bitflags",
@ -562,9 +562,9 @@ dependencies = [
[[package]] [[package]]
name = "js-sys" name = "js-sys"
version = "0.3.55" version = "0.3.56"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7cc9ffccd38c451a86bf13657df244e9c3f37493cce8e5e21e940963777acc84" checksum = "a38fc24e30fd564ce974c02bf1d337caddff65be6cc4735a1f7eab22a7440f04"
dependencies = [ dependencies = [
"wasm-bindgen", "wasm-bindgen",
] ]
@ -608,9 +608,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.112" version = "0.2.113"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125" checksum = "eef78b64d87775463c549fbd80e19249ef436ea3bf1de2a1eb7e717ec7fab1e9"
[[package]] [[package]]
name = "libloading" name = "libloading"
@ -712,6 +712,15 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "num_threads"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71a1eb3a36534514077c1e079ada2fb170ef30c47d203aa6916138cf882ecd52"
dependencies = [
"libc",
]
[[package]] [[package]]
name = "once_cell" name = "once_cell"
version = "1.9.0" version = "1.9.0"
@ -800,7 +809,7 @@ dependencies = [
name = "oxigraph_server" name = "oxigraph_server"
version = "0.3.0-dev" version = "0.3.0-dev"
dependencies = [ dependencies = [
"clap 3.0.7", "clap 3.0.10",
"oxhttp", "oxhttp",
"oxigraph", "oxigraph",
"oxiri", "oxiri",
@ -814,7 +823,7 @@ name = "oxigraph_testsuite"
version = "0.3.0-dev" version = "0.3.0-dev"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"clap 3.0.7", "clap 3.0.10",
"criterion", "criterion",
"oxigraph", "oxigraph",
"text-diff", "text-diff",
@ -835,7 +844,7 @@ checksum = "a8a8821a5332e388ab8d6436ab703c5744516c11976e2c08702fbc93fe4b3f51"
[[package]] [[package]]
name = "oxrdf" name = "oxrdf"
version = "0.1.0" version = "0.1.0-dev"
dependencies = [ dependencies = [
"lasso", "lasso",
"oxilangtag", "oxilangtag",
@ -1077,9 +1086,9 @@ dependencies = [
[[package]] [[package]]
name = "quote" name = "quote"
version = "1.0.14" version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47aa80447ce4daf1717500037052af176af5d38cc3e571d9ec1c7353fc10c87d" checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
] ]
@ -1328,9 +1337,9 @@ dependencies = [
[[package]] [[package]]
name = "security-framework" name = "security-framework"
version = "2.4.2" version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "525bc1abfda2e1998d152c45cf13e696f76d0a4972310b22fac1658b05df7c87" checksum = "d09d3c15d814eda1d6a836f2f2b56a6abc1446c8a34351cb3180d3db92ffe4ce"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"core-foundation", "core-foundation",
@ -1341,9 +1350,9 @@ dependencies = [
[[package]] [[package]]
name = "security-framework-sys" name = "security-framework-sys"
version = "2.4.2" version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9dd14d83160b528b7bfd66439110573efcfbe281b17fc2ca9f39f550d619c7e" checksum = "e90dd10c41c6bfc633da6e0c659bd25d31e0791e5974ac42970267d59eba87f7"
dependencies = [ dependencies = [
"core-foundation-sys", "core-foundation-sys",
"libc", "libc",
@ -1357,9 +1366,9 @@ checksum = "568a8e6258aa33c13358f81fd834adb854c6f7c9468520910a9b1e8fac068012"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.133" version = "1.0.134"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97565067517b60e2d1ea8b268e59ce036de907ac523ad83a0475da04e818989a" checksum = "96b3c34c1690edf8174f5b289a336ab03f568a4460d8c6df75f2f3a692b3bc6a"
[[package]] [[package]]
name = "serde_cbor" name = "serde_cbor"
@ -1373,9 +1382,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.133" version = "1.0.134"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed201699328568d8d08208fdd080e3ff594e6c422e438b6705905da01005d537" checksum = "784ed1fbfa13fe191077537b0d70ec8ad1e903cfe04831da608aa36457cb653d"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1384,9 +1393,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_json" name = "serde_json"
version = "1.0.74" version = "1.0.75"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee2bb9cd061c5865d345bb02ca49fcef1391741b672b54a0bf7b679badec3142" checksum = "c059c05b48c5c0067d4b4b2b4f0732dd65feb52daf7e0ea09cd87e7dadc1af79"
dependencies = [ dependencies = [
"itoa 1.0.1", "itoa 1.0.1",
"ryu", "ryu",
@ -1423,9 +1432,9 @@ checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3"
[[package]] [[package]]
name = "siphasher" name = "siphasher"
version = "0.3.7" version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "533494a8f9b724d33625ab53c6c4800f7cc445895924a8ef649222dcb76e938b" checksum = "a86232ab60fa71287d7f2ddae4a7073f6b7aac33631c3015abb556f08c6d0a3e"
[[package]] [[package]]
name = "smallvec" name = "smallvec"
@ -1461,7 +1470,7 @@ dependencies = [
[[package]] [[package]]
name = "sparesults" name = "sparesults"
version = "0.1.0" version = "0.1.0-dev"
dependencies = [ dependencies = [
"json-event-parser", "json-event-parser",
"oxrdf", "oxrdf",
@ -1470,7 +1479,7 @@ dependencies = [
[[package]] [[package]]
name = "spargebra" name = "spargebra"
version = "0.1.0" version = "0.2.0-dev"
dependencies = [ dependencies = [
"oxilangtag", "oxilangtag",
"oxiri", "oxiri",
@ -1499,9 +1508,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.85" version = "1.0.86"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a684ac3dcd8913827e18cd09a68384ee66c1de24157e3c556c9ab16d85695fb7" checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1574,12 +1583,13 @@ dependencies = [
[[package]] [[package]]
name = "time" name = "time"
version = "0.3.5" version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41effe7cfa8af36f439fac33861b66b049edc6f9a32331e2312660529c1c24ad" checksum = "c8d54b9298e05179c335de2b9645d061255bcd5155f843b3e328d2cfe0a5b413"
dependencies = [ dependencies = [
"itoa 0.4.8", "itoa 1.0.1",
"libc", "libc",
"num_threads",
] ]
[[package]] [[package]]
@ -1695,9 +1705,9 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
[[package]] [[package]]
name = "wasm-bindgen" name = "wasm-bindgen"
version = "0.2.78" version = "0.2.79"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce" checksum = "25f1af7423d8588a3d840681122e72e6a24ddbcb3f0ec385cac0d12d24256c06"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"wasm-bindgen-macro", "wasm-bindgen-macro",
@ -1705,9 +1715,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-backend" name = "wasm-bindgen-backend"
version = "0.2.78" version = "0.2.79"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a317bf8f9fba2476b4b2c85ef4c4af8ff39c3c7f0cdfeed4f82c34a880aa837b" checksum = "8b21c0df030f5a177f3cba22e9bc4322695ec43e7257d865302900290bcdedca"
dependencies = [ dependencies = [
"bumpalo", "bumpalo",
"lazy_static", "lazy_static",
@ -1720,9 +1730,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-futures" name = "wasm-bindgen-futures"
version = "0.4.28" version = "0.4.29"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e8d7523cb1f2a4c96c1317ca690031b714a51cc14e05f712446691f413f5d39" checksum = "2eb6ec270a31b1d3c7e266b999739109abce8b6c87e4b31fcfcd788b65267395"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"js-sys", "js-sys",
@ -1732,9 +1742,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-macro" name = "wasm-bindgen-macro"
version = "0.2.78" version = "0.2.79"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9" checksum = "2f4203d69e40a52ee523b2529a773d5ffc1dc0071801c87b3d270b471b80ed01"
dependencies = [ dependencies = [
"quote", "quote",
"wasm-bindgen-macro-support", "wasm-bindgen-macro-support",
@ -1742,9 +1752,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-macro-support" name = "wasm-bindgen-macro-support"
version = "0.2.78" version = "0.2.79"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab" checksum = "bfa8a30d46208db204854cadbb5d4baf5fcf8071ba5bf48190c3e59937962ebc"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1755,15 +1765,15 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-shared" name = "wasm-bindgen-shared"
version = "0.2.78" version = "0.2.79"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc" checksum = "3d958d035c4438e28c70e4321a2911302f10135ce78a9c7834c0cab4123d06a2"
[[package]] [[package]]
name = "wasm-bindgen-test" name = "wasm-bindgen-test"
version = "0.3.28" version = "0.3.29"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96f1aa7971fdf61ef0f353602102dbea75a56e225ed036c1e3740564b91e6b7e" checksum = "45c8d417d87eefa0087e62e3c75ad086be39433449e2961add9a5d9ce5acc2f1"
dependencies = [ dependencies = [
"console_error_panic_hook", "console_error_panic_hook",
"js-sys", "js-sys",
@ -1775,9 +1785,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-test-macro" name = "wasm-bindgen-test-macro"
version = "0.3.28" version = "0.3.29"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6006f79628dfeb96a86d4db51fbf1344cd7fd8408f06fc9aa3c84913a4789688" checksum = "d0e560d44db5e73b69a9757a15512fe7e1ef93ed2061c928871a4025798293dd"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1785,9 +1795,9 @@ dependencies = [
[[package]] [[package]]
name = "web-sys" name = "web-sys"
version = "0.3.55" version = "0.3.56"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38eb105f1c59d9eaa6b5cdc92b859d85b926e82cb2e0945cd0c9259faa6fe9fb" checksum = "c060b319f29dd25724f09a2ba1418f142f539b2be99fbf4d2d5a8f7330afb8eb"
dependencies = [ dependencies = [
"js-sys", "js-sys",
"wasm-bindgen", "wasm-bindgen",

@ -39,9 +39,9 @@ siphasher = "0.3"
lazy_static = "1" lazy_static = "1"
sophia_api = { version = "0.7", optional = true } sophia_api = { version = "0.7", optional = true }
num_cpus = "1" num_cpus = "1"
oxrdf = { version = "0.1", path="oxrdf", features = ["rdf-star"] } oxrdf = { version = "0.1.0-dev", path="oxrdf", features = ["rdf-star"] }
spargebra = { version = "0.1", path="spargebra", features = ["rdf-star"] } spargebra = { version = "0.2.0-dev", path="spargebra", features = ["rdf-star"] }
sparesults = { version = "0.1", path="sparesults", features = ["rdf-star"] } sparesults = { version = "0.1.0-dev", path="sparesults", features = ["rdf-star"] }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies] [target.'cfg(not(target_arch = "wasm32"))'.dependencies]
libc = "0.2" libc = "0.2"

@ -49,6 +49,11 @@ if let QueryResults::Solutions(mut solutions) = store.query("SELECT ?s WHERE {
} }
``` ```
Some parts of this library are available as standalone crates:
* [`oxrdf`](https://crates.io/crates/oxrdf) provides datastructures encoding RDF basic concepts (the `oxigraph::model` module).
* [`spargebra`](https://crates.io/crates/spargebra) provides a SPARQL parser.
* [`sparesults`](https://crates.io/crates/sparesults) provides parsers and serializers for SPARQL result formats.
## License ## License
This project is licensed under either of This project is licensed under either of

@ -1,6 +1,6 @@
[package] [package]
name = "oxrdf" name = "oxrdf"
version = "0.1.0" version = "0.1.0-dev"
authors = ["Tpt <thomas@pellissier-tanon.fr>"] authors = ["Tpt <thomas@pellissier-tanon.fr>"]
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
readme = "README.md" readme = "README.md"

@ -13,7 +13,7 @@ This crate is intended to be a basic building block of other crates like [Oxigra
Support for [RDF-star](https://w3c.github.io/rdf-star/cg-spec/) is available behind the `rdf-star` feature. Support for [RDF-star](https://w3c.github.io/rdf-star/cg-spec/) is available behind the `rdf-star` feature.
Inspired by [RDF/JS](https://rdf.js.org/data-model-spec/) and [Apache Commons RDF](http://commons.apache.org/proper/commons-rdf/). OxRDF is inspired by [RDF/JS](https://rdf.js.org/data-model-spec/) and [Apache Commons RDF](http://commons.apache.org/proper/commons-rdf/).
Usage example: Usage example:

@ -59,7 +59,7 @@ impl BlankNode {
} }
} }
/// Creates a blank node from a unique numerical id /// Creates a blank node from a unique numerical id.
/// ///
/// In most cases, it is much more convenient to create a blank node using [`BlankNode::default()`]. /// In most cases, it is much more convenient to create a blank node using [`BlankNode::default()`].
#[inline] #[inline]
@ -70,7 +70,7 @@ impl BlankNode {
}) })
} }
/// Returns the underlying ID of this blank node /// Returns the underlying ID of this blank node.
#[inline] #[inline]
pub fn as_str(&self) -> &str { pub fn as_str(&self) -> &str {
match &self.0 { match &self.0 {
@ -79,7 +79,7 @@ impl BlankNode {
} }
} }
/// Returns the underlying ID of this blank node /// Returns the underlying ID of this blank node.
#[inline] #[inline]
pub fn into_string(self) -> String { pub fn into_string(self) -> String {
match self.0 { match self.0 {
@ -108,7 +108,7 @@ impl fmt::Display for BlankNode {
} }
impl Default for BlankNode { impl Default for BlankNode {
/// Builds a new RDF [blank node](https://www.w3.org/TR/rdf11-concepts/#dfn-blank-node) with a unique id /// Builds a new RDF [blank node](https://www.w3.org/TR/rdf11-concepts/#dfn-blank-node) with a unique id.
#[inline] #[inline]
fn default() -> Self { fn default() -> Self {
Self::new_from_unique_id(random::<u128>()) Self::new_from_unique_id(random::<u128>())
@ -171,7 +171,7 @@ impl<'a> BlankNodeRef<'a> {
} }
} }
/// Returns the underlying ID of this blank node /// Returns the underlying ID of this blank node.
#[inline] #[inline]
pub fn as_str(self) -> &'a str { pub fn as_str(self) -> &'a str {
match self.0 { match self.0 {
@ -180,7 +180,7 @@ impl<'a> BlankNodeRef<'a> {
} }
} }
/// Returns the internal numerical ID of this blank node if it has been created using [`BlankNode::new_from_unique_id`] /// Returns the internal numerical ID of this blank node if it has been created using [`BlankNode::new_from_unique_id`].
/// ///
/// ``` /// ```
/// use oxrdf::BlankNode; /// use oxrdf::BlankNode;

@ -34,7 +34,7 @@ use std::hash::{Hash, Hasher};
/// An in-memory [RDF dataset](https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-dataset). /// An in-memory [RDF dataset](https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-dataset).
/// ///
/// It can accomodate a fairly large number of quads (in the few millions). /// It can accommodate a fairly large number of quads (in the few millions).
/// Beware: it interns the string and does not do any garbage collection yet: /// Beware: it interns the string and does not do any garbage collection yet:
/// if you insert and remove a lot of different terms, memory will grow without any reduction. /// if you insert and remove a lot of different terms, memory will grow without any reduction.
/// ///
@ -160,7 +160,7 @@ impl Dataset {
} }
} }
/// Returns all the quads contained by the dataset /// Returns all the quads contained by the dataset.
pub fn iter(&self) -> Iter<'_> { pub fn iter(&self) -> Iter<'_> {
let iter = self.spog.iter(); let iter = self.spog.iter();
Iter { Iter {
@ -328,17 +328,17 @@ impl Dataset {
} }
} }
/// Returns the number of quads in this dataset /// Returns the number of quads in this dataset.
pub fn len(&self) -> usize { pub fn len(&self) -> usize {
self.gspo.len() self.gspo.len()
} }
/// Checks if this dataset contains a quad /// Checks if this dataset contains a quad.
pub fn is_empty(&self) -> bool { pub fn is_empty(&self) -> bool {
self.gspo.is_empty() self.gspo.is_empty()
} }
/// Adds a quad to the dataset /// Adds a quad to the dataset.
pub fn insert<'a>(&mut self, quad: impl Into<QuadRef<'a>>) -> bool { pub fn insert<'a>(&mut self, quad: impl Into<QuadRef<'a>>) -> bool {
let quad = self.encode_quad(quad.into()); let quad = self.encode_quad(quad.into());
self.insert_encoded(quad) self.insert_encoded(quad)
@ -362,7 +362,7 @@ impl Dataset {
self.ospg.insert((o, s, p, g)) self.ospg.insert((o, s, p, g))
} }
/// Removes a concrete quad from the dataset /// Removes a concrete quad from the dataset.
pub fn remove<'a>(&mut self, quad: impl Into<QuadRef<'a>>) -> bool { pub fn remove<'a>(&mut self, quad: impl Into<QuadRef<'a>>) -> bool {
if let Some(quad) = self.encoded_quad(quad.into()) { if let Some(quad) = self.encoded_quad(quad.into()) {
self.remove_encoded(quad) self.remove_encoded(quad)
@ -389,7 +389,7 @@ impl Dataset {
self.ospg.remove(&(o, s, p, g)) self.ospg.remove(&(o, s, p, g))
} }
/// Clears the dataset /// Clears the dataset.
pub fn clear(&mut self) { pub fn clear(&mut self) {
self.gspo.clear(); self.gspo.clear();
self.gpos.clear(); self.gpos.clear();
@ -487,7 +487,7 @@ impl Dataset {
} }
/// Applies on the dataset the canonicalization process described in /// Applies on the dataset the canonicalization process described in
/// [Canonical Forms for Isomorphic and Equivalent RDF Graphs: Algorithms for Leaning and Labelling Blank Nodes, Aidan Hogan, 2017](http://aidanhogan.com/docs/rdf-canonicalisation.pdf) /// [Canonical Forms for Isomorphic and Equivalent RDF Graphs: Algorithms for Leaning and Labelling Blank Nodes, Aidan Hogan, 2017](http://aidanhogan.com/docs/rdf-canonicalisation.pdf).
/// ///
/// Usage example ([Dataset isomorphim](https://www.w3.org/TR/rdf11-concepts/#dfn-dataset-isomorphism)): /// Usage example ([Dataset isomorphim](https://www.w3.org/TR/rdf11-concepts/#dfn-dataset-isomorphism)):
/// ``` /// ```
@ -517,9 +517,9 @@ impl Dataset {
/// Warning 1: Blank node ids depends on the current shape of the graph. Adding a new quad might change the ids of a lot of blank nodes. /// Warning 1: Blank node ids depends on the current shape of the graph. Adding a new quad might change the ids of a lot of blank nodes.
/// Hence, this canonization might not be suitable for diffs. /// Hence, this canonization might not be suitable for diffs.
/// ///
/// Warning 2: The canonicalization algorithm is not stable and canonical blank node Ids might change between Oxigraph version. /// Warning 2: The canonicalization algorithm is not stable and canonical blank node ids might change between Oxigraph version.
/// ///
/// Warning 3: This implementation worst-case complexity is in *O(b!)* with b the number of blank nodes in the input dataset. /// Warning 3: This implementation worst-case complexity is in *O(b!)* with *b* the number of blank nodes in the input dataset.
pub fn canonicalize(&mut self) { pub fn canonicalize(&mut self) {
let bnodes = self.blank_nodes(); let bnodes = self.blank_nodes();
let (hash, partition) = let (hash, partition) =
@ -930,7 +930,7 @@ pub struct GraphView<'a> {
} }
impl<'a> GraphView<'a> { impl<'a> GraphView<'a> {
/// Returns all the triples contained by the graph /// Returns all the triples contained by the graph.
pub fn iter(&self) -> GraphViewIter<'a> { pub fn iter(&self) -> GraphViewIter<'a> {
let iter = self.dataset.gspo.range( let iter = self.dataset.gspo.range(
&( &(
@ -998,7 +998,7 @@ impl<'a> GraphView<'a> {
) )
} }
pub fn objects_for_interned_subject_predicate( pub(super) fn objects_for_interned_subject_predicate(
&self, &self,
subject: Option<InternedSubject>, subject: Option<InternedSubject>,
predicate: Option<InternedNamedNode>, predicate: Option<InternedNamedNode>,
@ -1157,7 +1157,7 @@ impl<'a> GraphView<'a> {
self.triples_for_interned_object(self.dataset.encoded_term(object)) self.triples_for_interned_object(self.dataset.encoded_term(object))
} }
pub fn triples_for_interned_object( pub(super) fn triples_for_interned_object(
&self, &self,
object: Option<InternedTerm>, object: Option<InternedTerm>,
) -> impl Iterator<Item = TripleRef<'a>> + 'a { ) -> impl Iterator<Item = TripleRef<'a>> + 'a {
@ -1182,7 +1182,7 @@ impl<'a> GraphView<'a> {
.map(move |(_, o, s, p)| ds.decode_spo((s, p, o))) .map(move |(_, o, s, p)| ds.decode_spo((s, p, o)))
} }
/// Checks if the graph contains the given triple /// Checks if the graph contains the given triple.
pub fn contains<'b>(&self, triple: impl Into<TripleRef<'b>>) -> bool { pub fn contains<'b>(&self, triple: impl Into<TripleRef<'b>>) -> bool {
if let Some(triple) = self.encoded_triple(triple.into()) { if let Some(triple) = self.encoded_triple(triple.into()) {
self.dataset.gspo.contains(&( self.dataset.gspo.contains(&(
@ -1196,12 +1196,12 @@ impl<'a> GraphView<'a> {
} }
} }
/// Returns the number of triples in this graph /// Returns the number of triples in this graph.
pub fn len(&self) -> usize { pub fn len(&self) -> usize {
self.iter().count() self.iter().count()
} }
/// Checks if this graph contains a triple /// Checks if this graph contains a triple.
pub fn is_empty(&self) -> bool { pub fn is_empty(&self) -> bool {
self.iter().next().is_none() self.iter().next().is_none()
} }
@ -1280,7 +1280,7 @@ impl<'a> GraphViewMut<'a> {
} }
} }
/// Adds a triple to the graph /// Adds a triple to the graph.
pub fn insert<'b>(&mut self, triple: impl Into<TripleRef<'b>>) -> bool { pub fn insert<'b>(&mut self, triple: impl Into<TripleRef<'b>>) -> bool {
let triple = self.encode_triple(triple.into()); let triple = self.encode_triple(triple.into());
self.dataset.insert_encoded(( self.dataset.insert_encoded((
@ -1291,7 +1291,7 @@ impl<'a> GraphViewMut<'a> {
)) ))
} }
/// Removes a concrete triple from the graph /// Removes a concrete triple from the graph.
pub fn remove<'b>(&mut self, triple: impl Into<TripleRef<'b>>) -> bool { pub fn remove<'b>(&mut self, triple: impl Into<TripleRef<'b>>) -> bool {
if let Some(triple) = self.read().encoded_triple(triple.into()) { if let Some(triple) = self.read().encoded_triple(triple.into()) {
self.dataset.remove_encoded(( self.dataset.remove_encoded((
@ -1394,17 +1394,17 @@ impl<'a> GraphViewMut<'a> {
.triples_for_interned_object(self.dataset.encoded_term(object)) .triples_for_interned_object(self.dataset.encoded_term(object))
} }
/// Checks if the graph contains the given triple /// Checks if the graph contains the given triple.
pub fn contains<'b>(&self, triple: impl Into<TripleRef<'b>>) -> bool { pub fn contains<'b>(&self, triple: impl Into<TripleRef<'b>>) -> bool {
self.read().contains(triple) self.read().contains(triple)
} }
/// Returns the number of triples in this graph /// Returns the number of triples in this graph.
pub fn len(&self) -> usize { pub fn len(&self) -> usize {
self.read().len() self.read().len()
} }
/// Checks if this graph contains a triple /// Checks if this graph contains a triple.
pub fn is_empty(&self) -> bool { pub fn is_empty(&self) -> bool {
self.read().is_empty() self.read().is_empty()
} }
@ -1444,7 +1444,7 @@ impl<'a> fmt::Display for GraphViewMut<'a> {
} }
} }
/// Iterator returned by [`Dataset::iter`] /// Iterator returned by [`Dataset::iter`].
pub struct Iter<'a> { pub struct Iter<'a> {
dataset: &'a Dataset, dataset: &'a Dataset,
inner: std::collections::btree_set::Iter< inner: std::collections::btree_set::Iter<
@ -1468,7 +1468,7 @@ impl<'a> Iterator for Iter<'a> {
} }
} }
/// Iterator returned by [`GraphView::iter`] /// Iterator returned by [`GraphView::iter`].
pub struct GraphViewIter<'a> { pub struct GraphViewIter<'a> {
dataset: &'a Dataset, dataset: &'a Dataset,
inner: std::collections::btree_set::Range< inner: std::collections::btree_set::Range<

@ -25,7 +25,7 @@ use std::fmt;
/// An in-memory [RDF graph](https://www.w3.org/TR/rdf11-concepts/#dfn-graph). /// An in-memory [RDF graph](https://www.w3.org/TR/rdf11-concepts/#dfn-graph).
/// ///
/// It can accomodate a fairly large number of triples (in the few millions). /// It can accommodate a fairly large number of triples (in the few millions).
/// Beware: it interns the string and does not do any garbage collection yet: /// Beware: it interns the string and does not do any garbage collection yet:
/// if you insert and remove a lot of different terms, memory will grow without any reduction. /// if you insert and remove a lot of different terms, memory will grow without any reduction.
/// ///
@ -51,7 +51,7 @@ pub struct Graph {
} }
impl Graph { impl Graph {
/// Creates a new graph /// Creates a new graph.
pub fn new() -> Self { pub fn new() -> Self {
Self::default() Self::default()
} }
@ -64,7 +64,7 @@ impl Graph {
self.dataset.graph_mut(GraphNameRef::DefaultGraph) self.dataset.graph_mut(GraphNameRef::DefaultGraph)
} }
/// Returns all the triples contained by the graph /// Returns all the triples contained by the graph.
pub fn iter(&self) -> Iter<'_> { pub fn iter(&self) -> Iter<'_> {
Iter { Iter {
inner: self.graph().iter(), inner: self.graph().iter(),
@ -146,38 +146,38 @@ impl Graph {
.triples_for_interned_object(self.dataset.encoded_term(object)) .triples_for_interned_object(self.dataset.encoded_term(object))
} }
/// Checks if the graph contains the given triple /// Checks if the graph contains the given triple.
pub fn contains<'a>(&self, triple: impl Into<TripleRef<'a>>) -> bool { pub fn contains<'a>(&self, triple: impl Into<TripleRef<'a>>) -> bool {
self.graph().contains(triple) self.graph().contains(triple)
} }
/// Returns the number of triples in this graph /// Returns the number of triples in this graph.
pub fn len(&self) -> usize { pub fn len(&self) -> usize {
self.dataset.len() self.dataset.len()
} }
/// Checks if this graph contains a triple /// Checks if this graph contains a triple.
pub fn is_empty(&self) -> bool { pub fn is_empty(&self) -> bool {
self.dataset.is_empty() self.dataset.is_empty()
} }
/// Adds a triple to the graph /// Adds a triple to the graph.
pub fn insert<'a>(&mut self, triple: impl Into<TripleRef<'a>>) -> bool { pub fn insert<'a>(&mut self, triple: impl Into<TripleRef<'a>>) -> bool {
self.graph_mut().insert(triple) self.graph_mut().insert(triple)
} }
/// Removes a concrete triple from the graph /// Removes a concrete triple from the graph.
pub fn remove<'a>(&mut self, triple: impl Into<TripleRef<'a>>) -> bool { pub fn remove<'a>(&mut self, triple: impl Into<TripleRef<'a>>) -> bool {
self.graph_mut().remove(triple) self.graph_mut().remove(triple)
} }
/// Clears the graph /// Clears the graph.
pub fn clear(&mut self) { pub fn clear(&mut self) {
self.dataset.clear() self.dataset.clear()
} }
/// Applies on the graph the canonicalization process described in /// Applies on the graph the canonicalization process described in
/// [Canonical Forms for Isomorphic and Equivalent RDF Graphs: Algorithms for Leaning and Labelling Blank Nodes, Aidan Hogan, 2017](http://aidanhogan.com/docs/rdf-canonicalisation.pdf) /// [Canonical Forms for Isomorphic and Equivalent RDF Graphs: Algorithms for Leaning and Labelling Blank Nodes, Aidan Hogan, 2017](http://aidanhogan.com/docs/rdf-canonicalisation.pdf).
/// ///
/// Usage example ([Graph isomorphim](https://www.w3.org/TR/rdf11-concepts/#dfn-graph-isomorphism)): /// Usage example ([Graph isomorphim](https://www.w3.org/TR/rdf11-concepts/#dfn-graph-isomorphism)):
/// ``` /// ```
@ -207,7 +207,7 @@ impl Graph {
/// ///
/// Warning 2: The canonicalization algorithm is not stable and canonical blank node Ids might change between Oxigraph version. /// Warning 2: The canonicalization algorithm is not stable and canonical blank node Ids might change between Oxigraph version.
/// ///
/// Warning 3: This implementation worst-case complexity is in *O(b!)* with b the number of blank nodes in the input graph. /// Warning 3: This implementation worst-case complexity is in *O(b!)* with *b* the number of blank nodes in the input graph.
pub fn canonicalize(&mut self) { pub fn canonicalize(&mut self) {
self.dataset.canonicalize() self.dataset.canonicalize()
} }
@ -264,7 +264,7 @@ impl fmt::Display for Graph {
} }
} }
/// Iterator returned by [`Graph::iter`] /// Iterator returned by [`Graph::iter`].
pub struct Iter<'a> { pub struct Iter<'a> {
inner: GraphViewIter<'a>, inner: GraphViewIter<'a>,
} }

@ -10,6 +10,8 @@
unused_qualifications unused_qualifications
)] )]
#![doc(test(attr(deny(warnings))))] #![doc(test(attr(deny(warnings))))]
#![doc(html_favicon_url = "https://raw.githubusercontent.com/oxigraph/oxigraph/master/logo.svg")]
#![doc(html_logo_url = "https://raw.githubusercontent.com/oxigraph/oxigraph/master/logo.svg")]
mod blank_node; mod blank_node;
pub mod dataset; pub mod dataset;

@ -140,7 +140,7 @@ impl Literal {
}) })
} }
/// Extract components from this literal /// Extract components from this literal (value, datatype and language tag).
#[inline] #[inline]
pub fn destruct(self) -> (String, Option<NamedNode>, Option<String>) { pub fn destruct(self) -> (String, Option<NamedNode>, Option<String>) {
match self.0 { match self.0 {

@ -374,7 +374,7 @@ fn read_hexa_char(input: &mut Chars<'_>, len: usize) -> Result<char, TermParseEr
char::from_u32(value).ok_or_else(|| TermParseError::msg("Invalid encoded unicode code point")) char::from_u32(value).ok_or_else(|| TermParseError::msg("Invalid encoded unicode code point"))
} }
/// An error raised during term serialization parsing. /// An error raised during term serialization parsing using the [`FromStr`] trait.
#[allow(missing_copy_implementations)] #[allow(missing_copy_implementations)]
#[derive(Debug)] #[derive(Debug)]
pub struct TermParseError { pub struct TermParseError {

@ -151,7 +151,7 @@ impl<'a> From<NamedOrBlankNodeRef<'a>> for NamedOrBlankNode {
} }
} }
/// The owned union of [IRIs](https://www.w3.org/TR/rdf11-concepts/#dfn-iri), [blank nodes](https://www.w3.org/TR/rdf11-concepts/#dfn-blank-node) and [triples](https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-triple). /// The owned union of [IRIs](https://www.w3.org/TR/rdf11-concepts/#dfn-iri), [blank nodes](https://www.w3.org/TR/rdf11-concepts/#dfn-blank-node) and [triples](https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-triple) (if the `rdf-star` feature is enabled).
#[derive(Eq, PartialEq, Debug, Clone, Hash)] #[derive(Eq, PartialEq, Debug, Clone, Hash)]
pub enum Subject { pub enum Subject {
NamedNode(NamedNode), NamedNode(NamedNode),
@ -264,7 +264,7 @@ impl From<NamedOrBlankNodeRef<'_>> for Subject {
} }
} }
/// The borrowed union of [IRIs](https://www.w3.org/TR/rdf11-concepts/#dfn-iri), [blank nodes](https://www.w3.org/TR/rdf11-concepts/#dfn-blank-node) and [triples](https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-triple). /// The borrowed union of [IRIs](https://www.w3.org/TR/rdf11-concepts/#dfn-iri), [blank nodes](https://www.w3.org/TR/rdf11-concepts/#dfn-blank-node) and [triples](https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-triple) (if the `rdf-star` feature is enabled).
#[derive(Eq, PartialEq, Debug, Clone, Copy, Hash)] #[derive(Eq, PartialEq, Debug, Clone, Copy, Hash)]
pub enum SubjectRef<'a> { pub enum SubjectRef<'a> {
NamedNode(NamedNodeRef<'a>), NamedNode(NamedNodeRef<'a>),
@ -381,7 +381,7 @@ impl<'a> From<&'a NamedOrBlankNode> for SubjectRef<'a> {
} }
/// An owned RDF [term](https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-term) /// An owned RDF [term](https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-term)
/// It is the union of [IRIs](https://www.w3.org/TR/rdf11-concepts/#dfn-iri), [blank nodes](https://www.w3.org/TR/rdf11-concepts/#dfn-blank-node), [literals](https://www.w3.org/TR/rdf11-concepts/#dfn-literal) and [triples](https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-triple). /// It is the union of [IRIs](https://www.w3.org/TR/rdf11-concepts/#dfn-iri), [blank nodes](https://www.w3.org/TR/rdf11-concepts/#dfn-blank-node), [literals](https://www.w3.org/TR/rdf11-concepts/#dfn-literal) and [triples](https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-triple) (if the `rdf-star` feature is enabled).
#[derive(Eq, PartialEq, Debug, Clone, Hash)] #[derive(Eq, PartialEq, Debug, Clone, Hash)]
pub enum Term { pub enum Term {
NamedNode(NamedNode), NamedNode(NamedNode),
@ -535,7 +535,7 @@ impl From<SubjectRef<'_>> for Term {
} }
/// A borrowed RDF [term](https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-term) /// A borrowed RDF [term](https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-term)
/// It is the union of [IRIs](https://www.w3.org/TR/rdf11-concepts/#dfn-iri), [blank nodes](https://www.w3.org/TR/rdf11-concepts/#dfn-blank-node), [literals](https://www.w3.org/TR/rdf11-concepts/#dfn-literal) and [triples](https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-triple). /// It is the union of [IRIs](https://www.w3.org/TR/rdf11-concepts/#dfn-iri), [blank nodes](https://www.w3.org/TR/rdf11-concepts/#dfn-blank-node), [literals](https://www.w3.org/TR/rdf11-concepts/#dfn-literal) and [triples](https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-triple) (if the `rdf-star` feature is enabled).
#[derive(Eq, PartialEq, Debug, Clone, Copy, Hash)] #[derive(Eq, PartialEq, Debug, Clone, Copy, Hash)]
pub enum TermRef<'a> { pub enum TermRef<'a> {
NamedNode(NamedNodeRef<'a>), NamedNode(NamedNodeRef<'a>),

@ -1,7 +1,7 @@
//! Provides ready to use [`NamedNodeRef`](super::NamedNodeRef)s for basic RDF vocabularies //! Provides ready to use [`NamedNodeRef`](super::NamedNodeRef)s for basic RDF vocabularies.
pub mod rdf { pub mod rdf {
//! [RDF](https://www.w3.org/TR/rdf11-concepts/) vocabulary //! [RDF](https://www.w3.org/TR/rdf11-concepts/) vocabulary.
use crate::named_node::NamedNodeRef; use crate::named_node::NamedNodeRef;
/// The class of containers of alternatives. /// The class of containers of alternatives.
@ -19,9 +19,10 @@ pub mod rdf {
/// The class of language-tagged string literal values. /// The class of language-tagged string literal values.
pub const LANG_STRING: NamedNodeRef<'_> = pub const LANG_STRING: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"); NamedNodeRef::new_unchecked("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString");
/// The class of RDF Lists. /// The class of RDF lists.
pub const LIST: NamedNodeRef<'_> = pub const LIST: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/1999/02/22-rdf-syntax-ns#List"); NamedNodeRef::new_unchecked("http://www.w3.org/1999/02/22-rdf-syntax-ns#List");
/// The empty list.
pub const NIL: NamedNodeRef<'_> = pub const NIL: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"); NamedNodeRef::new_unchecked("http://www.w3.org/1999/02/22-rdf-syntax-ns#nil");
/// The object of the subject RDF statement. /// The object of the subject RDF statement.
@ -57,7 +58,7 @@ pub mod rdf {
} }
pub mod rdfs { pub mod rdfs {
//! [RDFS](https://www.w3.org/TR/rdf-schema/) vocabulary //! [RDFS](https://www.w3.org/TR/rdf-schema/) vocabulary.
use crate::named_node::NamedNodeRef; use crate::named_node::NamedNodeRef;
/// The class of classes. /// The class of classes.
@ -109,124 +110,124 @@ pub mod rdfs {
} }
pub mod xsd { pub mod xsd {
//! [RDF compatible XSD datatypes](https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-compatible-xsd-types) //! [RDF compatible XSD datatypes](https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-compatible-xsd-types).
use crate::named_node::NamedNodeRef; use crate::named_node::NamedNodeRef;
/// Absolute or relative URIs and IRIs /// Absolute or relative URIs and IRIs.
pub const ANY_URI: NamedNodeRef<'_> = pub const ANY_URI: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#anyURI"); NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#anyURI");
/// Base64-encoded binary data /// Base64-encoded binary data.
pub const BASE_64_BINARY: NamedNodeRef<'_> = pub const BASE_64_BINARY: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#base64Binary"); NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#base64Binary");
/// true, false /// true, false.
pub const BOOLEAN: NamedNodeRef<'_> = pub const BOOLEAN: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#boolean"); NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#boolean");
/// 128…+127 (8 bit) /// 128…+127 (8 bit).
pub const BYTE: NamedNodeRef<'_> = pub const BYTE: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#byte"); NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#byte");
/// Dates (yyyy-mm-dd) with or without timezone /// Dates (yyyy-mm-dd) with or without timezone.
pub const DATE: NamedNodeRef<'_> = pub const DATE: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#date"); NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#date");
/// Duration of time (days, hours, minutes, seconds only) /// Duration of time (days, hours, minutes, seconds only).
pub const DAY_TIME_DURATION: NamedNodeRef<'_> = pub const DAY_TIME_DURATION: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#dayTimeDuration"); NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#dayTimeDuration");
/// Date and time with or without timezone /// Date and time with or without timezone.
pub const DATE_TIME: NamedNodeRef<'_> = pub const DATE_TIME: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#dateTime"); NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#dateTime");
/// Date and time with required timezone /// Date and time with required timezone.
pub const DATE_TIME_STAMP: NamedNodeRef<'_> = pub const DATE_TIME_STAMP: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#dateTimeStamp"); NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#dateTimeStamp");
/// Arbitrary-precision decimal numbers /// Arbitrary-precision decimal numbers.
pub const DECIMAL: NamedNodeRef<'_> = pub const DECIMAL: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#decimal"); NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#decimal");
/// 64-bit floating point numbers incl. ±Inf, ±0, NaN /// 64-bit floating point numbers incl. ±Inf, ±0, NaN.
pub const DOUBLE: NamedNodeRef<'_> = pub const DOUBLE: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#double"); NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#double");
/// Duration of time /// Duration of time.
pub const DURATION: NamedNodeRef<'_> = pub const DURATION: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#duration"); NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#duration");
/// 32-bit floating point numbers incl. ±Inf, ±0, NaN /// 32-bit floating point numbers incl. ±Inf, ±0, NaN.
pub const FLOAT: NamedNodeRef<'_> = pub const FLOAT: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#float"); NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#float");
/// Gregorian calendar day of the month /// Gregorian calendar day of the month.
pub const G_DAY: NamedNodeRef<'_> = pub const G_DAY: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#gDay"); NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#gDay");
/// Gregorian calendar month /// Gregorian calendar month.
pub const G_MONTH: NamedNodeRef<'_> = pub const G_MONTH: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#gMonth"); NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#gMonth");
/// Gregorian calendar month and day /// Gregorian calendar month and day.
pub const G_MONTH_DAY: NamedNodeRef<'_> = pub const G_MONTH_DAY: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#gMonthDay"); NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#gMonthDay");
/// Gregorian calendar year /// Gregorian calendar year.
pub const G_YEAR: NamedNodeRef<'_> = pub const G_YEAR: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#gYear"); NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#gYear");
/// Gregorian calendar year and month /// Gregorian calendar year and month.
pub const G_YEAR_MONTH: NamedNodeRef<'_> = pub const G_YEAR_MONTH: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#gYearMonth"); NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#gYearMonth");
/// Hex-encoded binary data /// Hex-encoded binary data.
pub const HEX_BINARY: NamedNodeRef<'_> = pub const HEX_BINARY: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#hexBinary"); NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#hexBinary");
/// -2147483648…+2147483647 (32 bit) /// -2147483648…+2147483647 (32 bit).
pub const INT: NamedNodeRef<'_> = pub const INT: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#int"); NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#int");
/// Arbitrary-size integer numbers /// Arbitrary-size integer numbers.
pub const INTEGER: NamedNodeRef<'_> = pub const INTEGER: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#integer"); NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#integer");
/// Language tags per [BCP47](http://tools.ietf.org/html/bcp47) /// Language tags per [BCP47](http://tools.ietf.org/html/bcp47).
pub const LANGUAGE: NamedNodeRef<'_> = pub const LANGUAGE: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#language"); NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#language");
/// -9223372036854775808…+9223372036854775807 (64 bit) /// -9223372036854775808…+9223372036854775807 (64 bit).
pub const LONG: NamedNodeRef<'_> = pub const LONG: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#long"); NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#long");
/// XML Names /// XML Names.
pub const NAME: NamedNodeRef<'_> = pub const NAME: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#Name"); NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#Name");
/// XML NCName /// XML NCName.
pub const NC_NAME: NamedNodeRef<'_> = pub const NC_NAME: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#NCName"); NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#NCName");
/// Integer numbers <0 /// Integer numbers <0.
pub const NEGATIVE_INTEGER: NamedNodeRef<'_> = pub const NEGATIVE_INTEGER: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#negativeInteger"); NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#negativeInteger");
/// XML NMTOKENs /// XML NMTOKENs.
pub const NMTOKEN: NamedNodeRef<'_> = pub const NMTOKEN: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#NMTOKEN"); NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#NMTOKEN");
/// Integer numbers ≥0 /// Integer numbers ≥0.
pub const NON_NEGATIVE_INTEGER: NamedNodeRef<'_> = pub const NON_NEGATIVE_INTEGER: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#nonNegativeInteger"); NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#nonNegativeInteger");
/// Integer numbers ≤0 /// Integer numbers ≤0.
pub const NON_POSITIVE_INTEGER: NamedNodeRef<'_> = pub const NON_POSITIVE_INTEGER: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#nonPositiveInteger"); NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#nonPositiveInteger");
/// Whitespace-normalized strings /// Whitespace-normalized strings.
pub const NORMALIZED_STRING: NamedNodeRef<'_> = pub const NORMALIZED_STRING: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#normalizedString"); NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#normalizedString");
/// Integer numbers >0 /// Integer numbers >0.
pub const POSITIVE_INTEGER: NamedNodeRef<'_> = pub const POSITIVE_INTEGER: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#positiveInteger"); NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#positiveInteger");
/// Times (hh:mm:ss.sss…) with or without timezone /// Times (hh:mm:ss.sss…) with or without timezone.
pub const TIME: NamedNodeRef<'_> = pub const TIME: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#time"); NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#time");
/// -32768…+32767 (16 bit) /// -32768…+32767 (16 bit).
pub const SHORT: NamedNodeRef<'_> = pub const SHORT: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#short"); NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#short");
/// Character strings (but not all Unicode character strings) /// Character strings (but not all Unicode character strings).
pub const STRING: NamedNodeRef<'_> = pub const STRING: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#string"); NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#string");
/// Tokenized strings /// Tokenized strings.
pub const TOKEN: NamedNodeRef<'_> = pub const TOKEN: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#token"); NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#token");
/// 0…255 (8 bit) /// 0…255 (8 bit).
pub const UNSIGNED_BYTE: NamedNodeRef<'_> = pub const UNSIGNED_BYTE: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#unsignedByte"); NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#unsignedByte");
/// 0…4294967295 (32 bit) /// 0…4294967295 (32 bit).
pub const UNSIGNED_INT: NamedNodeRef<'_> = pub const UNSIGNED_INT: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#unsignedInt"); NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#unsignedInt");
/// 0…18446744073709551615 (64 bit) /// 0…18446744073709551615 (64 bit).
pub const UNSIGNED_LONG: NamedNodeRef<'_> = pub const UNSIGNED_LONG: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#unsignedLong"); NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#unsignedLong");
/// 0…65535 (16 bit) /// 0…65535 (16 bit).
pub const UNSIGNED_SHORT: NamedNodeRef<'_> = pub const UNSIGNED_SHORT: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#unsignedShort"); NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#unsignedShort");
/// Duration of time (months and years only) /// Duration of time (months and years only).
pub const YEAR_MONTH_DURATION: NamedNodeRef<'_> = pub const YEAR_MONTH_DURATION: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#yearMonthDuration"); NamedNodeRef::new_unchecked("http://www.w3.org/2001/XMLSchema#yearMonthDuration");
} }

@ -1,6 +1,6 @@
[package] [package]
name = "sparesults" name = "sparesults"
version = "0.1.0" version = "0.1.0-dev"
authors = ["Tpt <thomas@pellissier-tanon.fr>"] authors = ["Tpt <thomas@pellissier-tanon.fr>"]
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
readme = "README.md" readme = "README.md"
@ -18,7 +18,7 @@ rdf-star = ["oxrdf/rdf-star"]
[dependencies] [dependencies]
json-event-parser = "0.1" json-event-parser = "0.1"
oxrdf = { version = "0.1", path="../oxrdf" } oxrdf = { version = "0.1.0-dev", path="../oxrdf" }
quick-xml = "0.22" quick-xml = "0.22"
[package.metadata.docs.rs] [package.metadata.docs.rs]

@ -11,7 +11,7 @@ Sparesults is a set of parsers and serializers for [SPARQL](https://www.w3.org/T
It supports [SPARQL Query Results XML Format (Second Edition)](http://www.w3.org/TR/rdf-sparql-XMLres/), [SPARQL 1.1 Query Results JSON Format](https://www.w3.org/TR/sparql11-results-json/) and [SPARQL 1.1 Query Results CSV and TSV Formats](https://www.w3.org/TR/2013/REC-sparql11-results-csv-tsv-20130321/). It supports [SPARQL Query Results XML Format (Second Edition)](http://www.w3.org/TR/rdf-sparql-XMLres/), [SPARQL 1.1 Query Results JSON Format](https://www.w3.org/TR/sparql11-results-json/) and [SPARQL 1.1 Query Results CSV and TSV Formats](https://www.w3.org/TR/2013/REC-sparql11-results-csv-tsv-20130321/).
Support for [SPARQL-star](https://w3c.github.io/rdf-star/cg-spec/#sparql-star) is also available behind the `rdf-star` feature. Support for [SPARQL-star](https://w3c.github.io/rdf-star/cg-spec/#query-result-formats) is also available behind the `rdf-star` feature.
This crate is intended to be a building piece for SPARQL client and server implementations in Rust like [Oxigraph](https://oxigraph.org). This crate is intended to be a building piece for SPARQL client and server implementations in Rust like [Oxigraph](https://oxigraph.org).

@ -10,6 +10,8 @@
unused_qualifications unused_qualifications
)] )]
#![doc(test(attr(deny(warnings))))] #![doc(test(attr(deny(warnings))))]
#![doc(html_favicon_url = "https://raw.githubusercontent.com/oxigraph/oxigraph/master/logo.svg")]
#![doc(html_logo_url = "https://raw.githubusercontent.com/oxigraph/oxigraph/master/logo.svg")]
mod csv; mod csv;
mod error; mod error;

@ -23,7 +23,7 @@ pub struct QuerySolution {
} }
impl QuerySolution { impl QuerySolution {
/// Returns a value for a given position in the tuple ([`usize`](std::usize)) or a given variable name ([`&str`](std::str) or [`Variable`]). /// Returns a value for a given position in the tuple ([`usize`](std::usize)) or a given variable name ([`&str`](std::str), [`Variable`] or [`VariableRef`]).
/// ///
/// ``` /// ```
/// use sparesults::QuerySolution; /// use sparesults::QuerySolution;

@ -1,6 +1,6 @@
[package] [package]
name = "spargebra" name = "spargebra"
version = "0.1.0" version = "0.2.0-dev"
authors = ["Tpt <thomas@pellissier-tanon.fr>"] authors = ["Tpt <thomas@pellissier-tanon.fr>"]
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
readme = "README.md" readme = "README.md"
@ -21,7 +21,7 @@ peg = "0.8"
rand = "0.8" rand = "0.8"
oxiri = "0.2" oxiri = "0.2"
oxilangtag = "0.1" oxilangtag = "0.1"
oxrdf = { version = "0.1", path="../oxrdf" } oxrdf = { version = "0.1.0-dev", path="../oxrdf" }
[package.metadata.docs.rs] [package.metadata.docs.rs]
all-features = true all-features = true

@ -1,10 +1,10 @@
//! [SPARQL 1.1 Query Algebra](https://www.w3.org/TR/sparql11-query/#sparqlQuery) representation //! [SPARQL 1.1 Query Algebra](https://www.w3.org/TR/sparql11-query/#sparqlQuery) representation.
use crate::term::*; use crate::term::*;
use oxrdf::LiteralRef; use oxrdf::LiteralRef;
use std::fmt; use std::fmt;
/// A [property path expression](https://www.w3.org/TR/sparql11-query/#defn_PropertyPathExpr) /// A [property path expression](https://www.w3.org/TR/sparql11-query/#defn_PropertyPathExpr).
#[derive(Eq, PartialEq, Debug, Clone, Hash)] #[derive(Eq, PartialEq, Debug, Clone, Hash)]
pub enum PropertyPathExpression { pub enum PropertyPathExpression {
NamedNode(NamedNode), NamedNode(NamedNode),
@ -97,51 +97,51 @@ impl From<NamedNode> for PropertyPathExpression {
} }
} }
/// An [expression](https://www.w3.org/TR/sparql11-query/#expressions) /// An [expression](https://www.w3.org/TR/sparql11-query/#expressions).
#[derive(Eq, PartialEq, Debug, Clone, Hash)] #[derive(Eq, PartialEq, Debug, Clone, Hash)]
pub enum Expression { pub enum Expression {
NamedNode(NamedNode), NamedNode(NamedNode),
Literal(Literal), Literal(Literal),
Variable(Variable), Variable(Variable),
/// [Logical-or](https://www.w3.org/TR/sparql11-query/#func-logical-or) /// [Logical-or](https://www.w3.org/TR/sparql11-query/#func-logical-or).
Or(Box<Self>, Box<Self>), Or(Box<Self>, Box<Self>),
/// [Logical-and](https://www.w3.org/TR/sparql11-query/#func-logical-and) /// [Logical-and](https://www.w3.org/TR/sparql11-query/#func-logical-and).
And(Box<Self>, Box<Self>), And(Box<Self>, Box<Self>),
/// [RDFterm-equal](https://www.w3.org/TR/sparql11-query/#func-RDFterm-equal) and all the XSD equalities /// [RDFterm-equal](https://www.w3.org/TR/sparql11-query/#func-RDFterm-equal) and all the XSD equalities.
Equal(Box<Self>, Box<Self>), Equal(Box<Self>, Box<Self>),
/// [sameTerm](https://www.w3.org/TR/sparql11-query/#func-sameTerm) /// [sameTerm](https://www.w3.org/TR/sparql11-query/#func-sameTerm).
SameTerm(Box<Self>, Box<Self>), SameTerm(Box<Self>, Box<Self>),
/// [op:numeric-greater-than](https://www.w3.org/TR/xpath-functions/#func-numeric-greater-than) and other XSD greater than operators /// [op:numeric-greater-than](https://www.w3.org/TR/xpath-functions/#func-numeric-greater-than) and other XSD greater than operators.
Greater(Box<Self>, Box<Self>), Greater(Box<Self>, Box<Self>),
GreaterOrEqual(Box<Self>, Box<Self>), GreaterOrEqual(Box<Self>, Box<Self>),
/// [op:numeric-less-than](https://www.w3.org/TR/xpath-functions/#func-numeric-less-than) and other XSD greater than operators /// [op:numeric-less-than](https://www.w3.org/TR/xpath-functions/#func-numeric-less-than) and other XSD greater than operators.
Less(Box<Self>, Box<Self>), Less(Box<Self>, Box<Self>),
LessOrEqual(Box<Self>, Box<Self>), LessOrEqual(Box<Self>, Box<Self>),
/// [IN](https://www.w3.org/TR/sparql11-query/#func-in) /// [IN](https://www.w3.org/TR/sparql11-query/#func-in)
In(Box<Self>, Vec<Self>), In(Box<Self>, Vec<Self>),
/// [op:numeric-add](https://www.w3.org/TR/xpath-functions/#func-numeric-add) and other XSD additions /// [op:numeric-add](https://www.w3.org/TR/xpath-functions/#func-numeric-add) and other XSD additions.
Add(Box<Self>, Box<Self>), Add(Box<Self>, Box<Self>),
/// [op:numeric-subtract](https://www.w3.org/TR/xpath-functions/#func-numeric-subtract) and other XSD subtractions /// [op:numeric-subtract](https://www.w3.org/TR/xpath-functions/#func-numeric-subtract) and other XSD subtractions.
Subtract(Box<Self>, Box<Self>), Subtract(Box<Self>, Box<Self>),
/// [op:numeric-multiply](https://www.w3.org/TR/xpath-functions/#func-numeric-multiply) and other XSD multiplications /// [op:numeric-multiply](https://www.w3.org/TR/xpath-functions/#func-numeric-multiply) and other XSD multiplications.
Multiply(Box<Self>, Box<Self>), Multiply(Box<Self>, Box<Self>),
/// [op:numeric-divide](https://www.w3.org/TR/xpath-functions/#func-numeric-divide) and other XSD divides /// [op:numeric-divide](https://www.w3.org/TR/xpath-functions/#func-numeric-divide) and other XSD divides.
Divide(Box<Self>, Box<Self>), Divide(Box<Self>, Box<Self>),
/// [op:numeric-unary-plus](https://www.w3.org/TR/xpath-functions/#func-numeric-unary-plus) and other XSD unary plus /// [op:numeric-unary-plus](https://www.w3.org/TR/xpath-functions/#func-numeric-unary-plus) and other XSD unary plus.
UnaryPlus(Box<Self>), UnaryPlus(Box<Self>),
/// [op:numeric-unary-minus](https://www.w3.org/TR/xpath-functions/#func-numeric-unary-minus) and other XSD unary minus /// [op:numeric-unary-minus](https://www.w3.org/TR/xpath-functions/#func-numeric-unary-minus) and other XSD unary minus.
UnaryMinus(Box<Self>), UnaryMinus(Box<Self>),
/// [fn:not](https://www.w3.org/TR/xpath-functions/#func-not) /// [fn:not](https://www.w3.org/TR/xpath-functions/#func-not).
Not(Box<Self>), Not(Box<Self>),
/// [EXISTS](https://www.w3.org/TR/sparql11-query/#func-filter-exists) /// [EXISTS](https://www.w3.org/TR/sparql11-query/#func-filter-exists).
Exists(Box<GraphPattern>), Exists(Box<GraphPattern>),
/// [BOUND](https://www.w3.org/TR/sparql11-query/#func-bound) /// [BOUND](https://www.w3.org/TR/sparql11-query/#func-bound).
Bound(Variable), Bound(Variable),
/// [IF](https://www.w3.org/TR/sparql11-query/#func-if) /// [IF](https://www.w3.org/TR/sparql11-query/#func-if).
If(Box<Self>, Box<Self>, Box<Self>), If(Box<Self>, Box<Self>, Box<Self>),
/// [COALESCE](https://www.w3.org/TR/sparql11-query/#func-coalesce) /// [COALESCE](https://www.w3.org/TR/sparql11-query/#func-coalesce).
Coalesce(Vec<Self>), Coalesce(Vec<Self>),
/// A regular function call /// A regular function call.
FunctionCall(Function, Vec<Self>), FunctionCall(Function, Vec<Self>),
} }
@ -317,7 +317,7 @@ fn write_arg_list(
write!(f, ")") write!(f, ")")
} }
/// A function name /// A function name.
#[derive(Eq, PartialEq, Debug, Clone, Hash)] #[derive(Eq, PartialEq, Debug, Clone, Hash)]
pub enum Function { pub enum Function {
Str, Str,
@ -508,73 +508,73 @@ impl fmt::Display for Function {
} }
} }
/// A SPARQL query [graph pattern](https://www.w3.org/TR/sparql11-query/#sparqlQuery) /// A SPARQL query [graph pattern](https://www.w3.org/TR/sparql11-query/#sparqlQuery).
#[derive(Eq, PartialEq, Debug, Clone, Hash)] #[derive(Eq, PartialEq, Debug, Clone, Hash)]
pub enum GraphPattern { pub enum GraphPattern {
/// A [basic graph pattern](https://www.w3.org/TR/sparql11-query/#defn_BasicGraphPattern) /// A [basic graph pattern](https://www.w3.org/TR/sparql11-query/#defn_BasicGraphPattern).
Bgp { patterns: Vec<TriplePattern> }, Bgp { patterns: Vec<TriplePattern> },
/// A [property path pattern](https://www.w3.org/TR/sparql11-query/#defn_evalPP_predicate) /// A [property path pattern](https://www.w3.org/TR/sparql11-query/#defn_evalPP_predicate).
Path { Path {
subject: TermPattern, subject: TermPattern,
path: PropertyPathExpression, path: PropertyPathExpression,
object: TermPattern, object: TermPattern,
}, },
/// [Join](https://www.w3.org/TR/sparql11-query/#defn_algJoin) /// [Join](https://www.w3.org/TR/sparql11-query/#defn_algJoin).
Join { left: Box<Self>, right: Box<Self> }, Join { left: Box<Self>, right: Box<Self> },
/// [LeftJoin](https://www.w3.org/TR/sparql11-query/#defn_algLeftJoin) /// [LeftJoin](https://www.w3.org/TR/sparql11-query/#defn_algLeftJoin).
LeftJoin { LeftJoin {
left: Box<Self>, left: Box<Self>,
right: Box<Self>, right: Box<Self>,
expression: Option<Expression>, expression: Option<Expression>,
}, },
/// [Filter](https://www.w3.org/TR/sparql11-query/#defn_algFilter) /// [Filter](https://www.w3.org/TR/sparql11-query/#defn_algFilter).
Filter { expr: Expression, inner: Box<Self> }, Filter { expr: Expression, inner: Box<Self> },
/// [Union](https://www.w3.org/TR/sparql11-query/#defn_algUnion) /// [Union](https://www.w3.org/TR/sparql11-query/#defn_algUnion).
Union { left: Box<Self>, right: Box<Self> }, Union { left: Box<Self>, right: Box<Self> },
Graph { Graph {
name: NamedNodePattern, name: NamedNodePattern,
inner: Box<Self>, inner: Box<Self>,
}, },
/// [Extend](https://www.w3.org/TR/sparql11-query/#defn_extend) /// [Extend](https://www.w3.org/TR/sparql11-query/#defn_extend).
Extend { Extend {
inner: Box<Self>, inner: Box<Self>,
variable: Variable, variable: Variable,
expression: Expression, expression: Expression,
}, },
/// [Minus](https://www.w3.org/TR/sparql11-query/#defn_algMinus) /// [Minus](https://www.w3.org/TR/sparql11-query/#defn_algMinus).
Minus { left: Box<Self>, right: Box<Self> }, Minus { left: Box<Self>, right: Box<Self> },
/// A table used to provide inline values /// A table used to provide inline values
Values { Values {
variables: Vec<Variable>, variables: Vec<Variable>,
bindings: Vec<Vec<Option<GroundTerm>>>, bindings: Vec<Vec<Option<GroundTerm>>>,
}, },
/// [OrderBy](https://www.w3.org/TR/sparql11-query/#defn_algOrdered) /// [OrderBy](https://www.w3.org/TR/sparql11-query/#defn_algOrdered).
OrderBy { OrderBy {
inner: Box<Self>, inner: Box<Self>,
expression: Vec<OrderExpression>, expression: Vec<OrderExpression>,
}, },
/// [Project](https://www.w3.org/TR/sparql11-query/#defn_algProjection) /// [Project](https://www.w3.org/TR/sparql11-query/#defn_algProjection).
Project { Project {
inner: Box<Self>, inner: Box<Self>,
variables: Vec<Variable>, variables: Vec<Variable>,
}, },
/// [Distinct](https://www.w3.org/TR/sparql11-query/#defn_algDistinct) /// [Distinct](https://www.w3.org/TR/sparql11-query/#defn_algDistinct).
Distinct { inner: Box<Self> }, Distinct { inner: Box<Self> },
/// [Reduced](https://www.w3.org/TR/sparql11-query/#defn_algReduced) /// [Reduced](https://www.w3.org/TR/sparql11-query/#defn_algReduced).
Reduced { inner: Box<Self> }, Reduced { inner: Box<Self> },
/// [Slice](https://www.w3.org/TR/sparql11-query/#defn_algSlice) /// [Slice](https://www.w3.org/TR/sparql11-query/#defn_algSlice).
Slice { Slice {
inner: Box<Self>, inner: Box<Self>,
start: usize, start: usize,
length: Option<usize>, length: Option<usize>,
}, },
/// [Group](https://www.w3.org/TR/sparql11-federated-query/#aggregateAlgebra) /// [Group](https://www.w3.org/TR/sparql11-federated-query/#aggregateAlgebra).
Group { Group {
inner: Box<Self>, inner: Box<Self>,
variables: Vec<Variable>, variables: Vec<Variable>,
aggregates: Vec<(Variable, AggregateExpression)>, aggregates: Vec<(Variable, AggregateExpression)>,
}, },
/// [Service](https://www.w3.org/TR/sparql11-federated-query/#defn_evalService) /// [Service](https://www.w3.org/TR/sparql11-federated-query/#defn_evalService).
Service { Service {
name: NamedNodePattern, name: NamedNodePattern,
inner: Box<Self>, inner: Box<Self>,
@ -904,7 +904,7 @@ impl Default for GraphPattern {
} }
impl GraphPattern { impl GraphPattern {
/// Calls `callback` on each [in-scope variable](https://www.w3.org/TR/sparql11-query/#variableScope) occurrence /// Calls `callback` on each [in-scope variable](https://www.w3.org/TR/sparql11-query/#variableScope) occurrence.
pub fn on_in_scope_variable<'a>(&'a self, mut callback: impl FnMut(&'a Variable)) { pub fn on_in_scope_variable<'a>(&'a self, mut callback: impl FnMut(&'a Variable)) {
self.lookup_in_scope_variables(&mut callback) self.lookup_in_scope_variables(&mut callback)
} }
@ -1088,46 +1088,46 @@ impl<'a> fmt::Display for SparqlGraphRootPattern<'a> {
} }
} }
/// A set function used in aggregates (c.f. [`GraphPattern::Group`]) /// A set function used in aggregates (c.f. [`GraphPattern::Group`]).
#[derive(Eq, PartialEq, Debug, Clone, Hash)] #[derive(Eq, PartialEq, Debug, Clone, Hash)]
pub enum AggregateExpression { pub enum AggregateExpression {
/// [Count](https://www.w3.org/TR/sparql11-query/#defn_aggCount) /// [Count](https://www.w3.org/TR/sparql11-query/#defn_aggCount).
Count { Count {
expr: Option<Box<Expression>>, expr: Option<Box<Expression>>,
distinct: bool, distinct: bool,
}, },
/// [Sum](https://www.w3.org/TR/sparql11-query/#defn_aggSum) /// [Sum](https://www.w3.org/TR/sparql11-query/#defn_aggSum).
Sum { Sum {
expr: Box<Expression>, expr: Box<Expression>,
distinct: bool, distinct: bool,
}, },
/// [Avg](https://www.w3.org/TR/sparql11-query/#defn_aggAvg) /// [Avg](https://www.w3.org/TR/sparql11-query/#defn_aggAvg).
Avg { Avg {
expr: Box<Expression>, expr: Box<Expression>,
distinct: bool, distinct: bool,
}, },
/// [Min](https://www.w3.org/TR/sparql11-query/#defn_aggMin) /// [Min](https://www.w3.org/TR/sparql11-query/#defn_aggMin).
Min { Min {
expr: Box<Expression>, expr: Box<Expression>,
distinct: bool, distinct: bool,
}, },
/// [Max](https://www.w3.org/TR/sparql11-query/#defn_aggMax) /// [Max](https://www.w3.org/TR/sparql11-query/#defn_aggMax).
Max { Max {
expr: Box<Expression>, expr: Box<Expression>,
distinct: bool, distinct: bool,
}, },
/// [GroupConcat](https://www.w3.org/TR/sparql11-query/#defn_aggGroupConcat) /// [GroupConcat](https://www.w3.org/TR/sparql11-query/#defn_aggGroupConcat).
GroupConcat { GroupConcat {
expr: Box<Expression>, expr: Box<Expression>,
distinct: bool, distinct: bool,
separator: Option<String>, separator: Option<String>,
}, },
/// [Sample](https://www.w3.org/TR/sparql11-query/#defn_aggSample) /// [Sample](https://www.w3.org/TR/sparql11-query/#defn_aggSample).
Sample { Sample {
expr: Box<Expression>, expr: Box<Expression>,
distinct: bool, distinct: bool,
}, },
/// Custom function /// Custom function.
Custom { Custom {
name: NamedNode, name: NamedNode,
expr: Box<Expression>, expr: Box<Expression>,
@ -1315,7 +1315,7 @@ impl fmt::Display for AggregateExpression {
} }
} }
/// An ordering comparator used by [`GraphPattern::OrderBy`] /// An ordering comparator used by [`GraphPattern::OrderBy`].
#[derive(Eq, PartialEq, Debug, Clone, Hash)] #[derive(Eq, PartialEq, Debug, Clone, Hash)]
pub enum OrderExpression { pub enum OrderExpression {
/// Ascending order /// Ascending order
@ -1351,7 +1351,7 @@ impl fmt::Display for OrderExpression {
} }
} }
/// A SPARQL query [dataset specification](https://www.w3.org/TR/sparql11-query/#specifyingDataset) /// A SPARQL query [dataset specification](https://www.w3.org/TR/sparql11-query/#specifyingDataset).
#[derive(Eq, PartialEq, Debug, Clone, Hash)] #[derive(Eq, PartialEq, Debug, Clone, Hash)]
pub struct QueryDataset { pub struct QueryDataset {
pub default: Vec<NamedNode>, pub default: Vec<NamedNode>,
@ -1394,7 +1394,7 @@ impl fmt::Display for QueryDataset {
} }
} }
/// A target RDF graph for update operations /// A target RDF graph for update operations.
/// ///
/// Could be a specific graph, all named graphs or the complete dataset. /// Could be a specific graph, all named graphs or the complete dataset.
#[derive(Eq, PartialEq, Debug, Clone, Hash)] #[derive(Eq, PartialEq, Debug, Clone, Hash)]

@ -10,6 +10,8 @@
unused_qualifications unused_qualifications
)] )]
#![doc(test(attr(deny(warnings))))] #![doc(test(attr(deny(warnings))))]
#![doc(html_favicon_url = "https://raw.githubusercontent.com/oxigraph/oxigraph/master/logo.svg")]
#![doc(html_logo_url = "https://raw.githubusercontent.com/oxigraph/oxigraph/master/logo.svg")]
pub mod algebra; pub mod algebra;
mod parser; mod parser;

@ -18,42 +18,42 @@ use std::str::FromStr;
/// ``` /// ```
#[derive(Eq, PartialEq, Debug, Clone, Hash)] #[derive(Eq, PartialEq, Debug, Clone, Hash)]
pub enum Query { pub enum Query {
/// [SELECT](https://www.w3.org/TR/sparql11-query/#select) /// [SELECT](https://www.w3.org/TR/sparql11-query/#select).
Select { Select {
/// The [query dataset specification](https://www.w3.org/TR/sparql11-query/#specifyingDataset) /// The [query dataset specification](https://www.w3.org/TR/sparql11-query/#specifyingDataset).
dataset: Option<QueryDataset>, dataset: Option<QueryDataset>,
/// The query selection graph pattern /// The query selection graph pattern.
pattern: GraphPattern, pattern: GraphPattern,
/// The query base IRI /// The query base IRI.
base_iri: Option<Iri<String>>, base_iri: Option<Iri<String>>,
}, },
/// [CONSTRUCT](https://www.w3.org/TR/sparql11-query/#construct) /// [CONSTRUCT](https://www.w3.org/TR/sparql11-query/#construct).
Construct { Construct {
/// The query construction template /// The query construction template.
template: Vec<TriplePattern>, template: Vec<TriplePattern>,
/// The [query dataset specification](https://www.w3.org/TR/sparql11-query/#specifyingDataset) /// The [query dataset specification](https://www.w3.org/TR/sparql11-query/#specifyingDataset).
dataset: Option<QueryDataset>, dataset: Option<QueryDataset>,
/// The query selection graph pattern /// The query selection graph pattern.
pattern: GraphPattern, pattern: GraphPattern,
/// The query base IRI /// The query base IRI.
base_iri: Option<Iri<String>>, base_iri: Option<Iri<String>>,
}, },
/// [DESCRIBE](https://www.w3.org/TR/sparql11-query/#describe) /// [DESCRIBE](https://www.w3.org/TR/sparql11-query/#describe).
Describe { Describe {
/// The [query dataset specification](https://www.w3.org/TR/sparql11-query/#specifyingDataset) /// The [query dataset specification](https://www.w3.org/TR/sparql11-query/#specifyingDataset).
dataset: Option<QueryDataset>, dataset: Option<QueryDataset>,
/// The query selection graph pattern /// The query selection graph pattern.
pattern: GraphPattern, pattern: GraphPattern,
/// The query base IRI /// The query base IRI.
base_iri: Option<Iri<String>>, base_iri: Option<Iri<String>>,
}, },
/// [ASK](https://www.w3.org/TR/sparql11-query/#ask) /// [ASK](https://www.w3.org/TR/sparql11-query/#ask).
Ask { Ask {
/// The [query dataset specification](https://www.w3.org/TR/sparql11-query/#specifyingDataset) /// The [query dataset specification](https://www.w3.org/TR/sparql11-query/#specifyingDataset).
dataset: Option<QueryDataset>, dataset: Option<QueryDataset>,
/// The query selection graph pattern /// The query selection graph pattern.
pattern: GraphPattern, pattern: GraphPattern,
/// The query base IRI /// The query base IRI.
base_iri: Option<Iri<String>>, base_iri: Option<Iri<String>>,
}, },
} }

@ -18,9 +18,9 @@ use std::str::FromStr;
/// ``` /// ```
#[derive(Eq, PartialEq, Debug, Clone, Hash)] #[derive(Eq, PartialEq, Debug, Clone, Hash)]
pub struct Update { pub struct Update {
/// The update base IRI /// The update base IRI.
pub base_iri: Option<Iri<String>>, pub base_iri: Option<Iri<String>>,
/// The [update operations](https://www.w3.org/TR/sparql11-update/#formalModelGraphUpdate) /// The [update operations](https://www.w3.org/TR/sparql11-update/#formalModelGraphUpdate).
pub operations: Vec<GraphUpdateOperation>, pub operations: Vec<GraphUpdateOperation>,
} }
@ -92,31 +92,31 @@ impl<'a> TryFrom<&'a String> for Update {
} }
} }
/// The [graph update operations](https://www.w3.org/TR/sparql11-update/#formalModelGraphUpdate) /// The [graph update operations](https://www.w3.org/TR/sparql11-update/#formalModelGraphUpdate).
#[derive(Eq, PartialEq, Debug, Clone, Hash)] #[derive(Eq, PartialEq, Debug, Clone, Hash)]
pub enum GraphUpdateOperation { pub enum GraphUpdateOperation {
/// [insert data](https://www.w3.org/TR/sparql11-update/#defn_insertDataOperation) /// [insert data](https://www.w3.org/TR/sparql11-update/#defn_insertDataOperation).
InsertData { data: Vec<Quad> }, InsertData { data: Vec<Quad> },
/// [delete data](https://www.w3.org/TR/sparql11-update/#defn_deleteDataOperation) /// [delete data](https://www.w3.org/TR/sparql11-update/#defn_deleteDataOperation).
DeleteData { data: Vec<GroundQuad> }, DeleteData { data: Vec<GroundQuad> },
/// [delete insert](https://www.w3.org/TR/sparql11-update/#defn_deleteInsertOperation) /// [delete insert](https://www.w3.org/TR/sparql11-update/#defn_deleteInsertOperation).
DeleteInsert { DeleteInsert {
delete: Vec<GroundQuadPattern>, delete: Vec<GroundQuadPattern>,
insert: Vec<QuadPattern>, insert: Vec<QuadPattern>,
using: Option<QueryDataset>, using: Option<QueryDataset>,
pattern: Box<GraphPattern>, pattern: Box<GraphPattern>,
}, },
/// [load](https://www.w3.org/TR/sparql11-update/#defn_loadOperation) /// [load](https://www.w3.org/TR/sparql11-update/#defn_loadOperation).
Load { Load {
silent: bool, silent: bool,
source: NamedNode, source: NamedNode,
destination: GraphName, destination: GraphName,
}, },
/// [clear](https://www.w3.org/TR/sparql11-update/#defn_clearOperation) /// [clear](https://www.w3.org/TR/sparql11-update/#defn_clearOperation).
Clear { silent: bool, graph: GraphTarget }, Clear { silent: bool, graph: GraphTarget },
/// [create](https://www.w3.org/TR/sparql11-update/#defn_createOperation) /// [create](https://www.w3.org/TR/sparql11-update/#defn_createOperation).
Create { silent: bool, graph: NamedNode }, Create { silent: bool, graph: NamedNode },
/// [drop](https://www.w3.org/TR/sparql11-update/#defn_dropOperation) /// [drop](https://www.w3.org/TR/sparql11-update/#defn_dropOperation).
Drop { silent: bool, graph: GraphTarget }, Drop { silent: bool, graph: GraphTarget },
} }

@ -1,4 +1,4 @@
//! Implements data structures for [RDF 1.1 Concepts](https://www.w3.org/TR/rdf11-concepts/) using [Oxrdf](https://crates.io/crates/oxrdf). //! Implements data structures for [RDF 1.1 Concepts](https://www.w3.org/TR/rdf11-concepts/) using [OxRDF](https://crates.io/crates/oxrdf).
use crate::xsd::*; use crate::xsd::*;
use oxrdf::vocab::xsd; use oxrdf::vocab::xsd;

@ -9,20 +9,21 @@ use std::io;
#[derive(Debug)] #[derive(Debug)]
#[non_exhaustive] #[non_exhaustive]
pub enum EvaluationError { pub enum EvaluationError {
/// An error in SPARQL parsing /// An error in SPARQL parsing.
Parsing(spargebra::ParseError), Parsing(spargebra::ParseError),
/// An error from the storage /// An error from the storage.
Storage(StorageError), Storage(StorageError),
/// An error while parsing an external RDF file /// An error while parsing an external RDF file.
GraphParsing(ParseError), GraphParsing(ParseError),
/// An error while parsing an external result file (likely from a federated query) /// An error while parsing an external result file (likely from a federated query).
ResultsParsing(sparesults::ParseError), ResultsParsing(sparesults::ParseError),
/// An error returned during store IOs or during results write /// An error returned during store IOs or during results write.
Io(io::Error), Io(io::Error),
/// An error returned during the query evaluation itself /// An error returned during the query evaluation itself (not supported custom function...).
Query(QueryError), Query(QueryError),
} }
/// An error returned during the query evaluation itself (not supported custom function...).
#[derive(Debug)] #[derive(Debug)]
pub struct QueryError { pub struct QueryError {
inner: QueryErrorKind, inner: QueryErrorKind,

@ -16,7 +16,7 @@ mod update;
use crate::model::{NamedNode, Term}; use crate::model::{NamedNode, Term};
pub use crate::sparql::algebra::{Query, Update}; pub use crate::sparql::algebra::{Query, Update};
use crate::sparql::dataset::DatasetView; use crate::sparql::dataset::DatasetView;
pub use crate::sparql::error::EvaluationError; pub use crate::sparql::error::{EvaluationError, QueryError};
use crate::sparql::eval::SimpleEvaluator; use crate::sparql::eval::SimpleEvaluator;
pub use crate::sparql::model::{QueryResults, QuerySolution, QuerySolutionIter, QueryTripleIter}; pub use crate::sparql::model::{QueryResults, QuerySolution, QuerySolutionIter, QueryTripleIter};
use crate::sparql::plan_builder::PlanBuilder; use crate::sparql::plan_builder::PlanBuilder;

@ -100,7 +100,7 @@ impl QueryResults {
/// let graph = "<http://example.com> <http://example.com> <http://example.com> .\n".as_bytes(); /// let graph = "<http://example.com> <http://example.com> <http://example.com> .\n".as_bytes();
/// ///
/// let store = Store::new()?; /// let store = Store::new()?;
/// store.load_graph(Cursor::new(graph), GraphFormat::NTriples, &GraphName::DefaultGraph, None)?; /// store.load_graph(Cursor::new(graph), GraphFormat::NTriples, GraphNameRef::DefaultGraph, None)?;
/// ///
/// let mut results = Vec::new(); /// let mut results = Vec::new();
/// store.query("CONSTRUCT WHERE { ?s ?p ?o }")?.write_graph(&mut results, GraphFormat::NTriples)?; /// store.query("CONSTRUCT WHERE { ?s ?p ?o }")?.write_graph(&mut results, GraphFormat::NTriples)?;

@ -313,9 +313,6 @@ impl Store {
/// Executes a [SPARQL 1.1 update](https://www.w3.org/TR/sparql11-update/). /// Executes a [SPARQL 1.1 update](https://www.w3.org/TR/sparql11-update/).
/// ///
/// The store does not track the existence of empty named graphs.
/// This method has no ACID guarantees.
///
/// Usage example: /// Usage example:
/// ``` /// ```
/// use oxigraph::store::Store; /// use oxigraph::store::Store;
@ -380,7 +377,7 @@ impl Store {
/// ///
/// // insertion /// // insertion
/// let file = b"<http://example.com> <http://example.com> <http://example.com> ."; /// let file = b"<http://example.com> <http://example.com> <http://example.com> .";
/// store.load_graph(file.as_ref(), GraphFormat::NTriples, &GraphName::DefaultGraph, None)?; /// store.load_graph(file.as_ref(), GraphFormat::NTriples, GraphNameRef::DefaultGraph, None)?;
/// ///
/// // we inspect the store contents /// // we inspect the store contents
/// let ex = NamedNodeRef::new("http://example.com")?; /// let ex = NamedNodeRef::new("http://example.com")?;
@ -467,7 +464,8 @@ impl Store {
/// let quad = QuadRef::new(ex, ex, ex, GraphNameRef::DefaultGraph); /// let quad = QuadRef::new(ex, ex, ex, GraphNameRef::DefaultGraph);
/// ///
/// let store = Store::new()?; /// let store = Store::new()?;
/// store.insert(quad)?; /// assert!(store.insert(quad)?);
/// assert!(!store.insert(quad)?);
/// ///
/// assert!(store.contains(quad)?); /// assert!(store.contains(quad)?);
/// # Result::<_, Box<dyn std::error::Error>>::Ok(()) /// # Result::<_, Box<dyn std::error::Error>>::Ok(())
@ -502,7 +500,8 @@ impl Store {
/// ///
/// let store = Store::new()?; /// let store = Store::new()?;
/// store.insert(quad)?; /// store.insert(quad)?;
/// store.remove(quad)?; /// assert!(store.remove(quad)?);
/// assert!(!store.remove(quad)?);
/// ///
/// assert!(!store.contains(quad)?); /// assert!(!store.contains(quad)?);
/// # Result::<_, Box<dyn std::error::Error>>::Ok(()) /// # Result::<_, Box<dyn std::error::Error>>::Ok(())
@ -518,15 +517,15 @@ impl Store {
/// ``` /// ```
/// use oxigraph::store::Store; /// use oxigraph::store::Store;
/// use oxigraph::io::GraphFormat; /// use oxigraph::io::GraphFormat;
/// use oxigraph::model::GraphName; /// use oxigraph::model::GraphNameRef;
/// ///
/// let file = "<http://example.com> <http://example.com> <http://example.com> .\n".as_bytes(); /// let file = "<http://example.com> <http://example.com> <http://example.com> .\n".as_bytes();
/// ///
/// let store = Store::new()?; /// let store = Store::new()?;
/// store.load_graph(file, GraphFormat::NTriples, &GraphName::DefaultGraph, None)?; /// store.load_graph(file, GraphFormat::NTriples, GraphNameRef::DefaultGraph, None)?;
/// ///
/// let mut buffer = Vec::new(); /// let mut buffer = Vec::new();
/// store.dump_graph(&mut buffer, GraphFormat::NTriples, &GraphName::DefaultGraph)?; /// store.dump_graph(&mut buffer, GraphFormat::NTriples, GraphNameRef::DefaultGraph)?;
/// assert_eq!(file, buffer.as_slice()); /// assert_eq!(file, buffer.as_slice());
/// # std::io::Result::Ok(()) /// # std::io::Result::Ok(())
/// ``` /// ```
@ -681,7 +680,7 @@ impl Store {
/// store.insert(quad)?; /// store.insert(quad)?;
/// assert_eq!(1, store.len()?); /// assert_eq!(1, store.len()?);
/// ///
/// store.remove_named_graph(ex)?; /// assert!(store.remove_named_graph(ex)?);
/// assert!(store.is_empty()?); /// assert!(store.is_empty()?);
/// assert_eq!(0, store.named_graphs().count()); /// assert_eq!(0, store.named_graphs().count());
/// # Result::<_, Box<dyn std::error::Error>>::Ok(()) /// # Result::<_, Box<dyn std::error::Error>>::Ok(())
@ -762,7 +761,7 @@ impl Store {
/// If the parsing fails in the middle of the file, only a part of it may be written to the store. /// If the parsing fails in the middle of the file, only a part of it may be written to the store.
/// Results might get weird if you delete data during the loading process. /// Results might get weird if you delete data during the loading process.
/// ///
/// Warning: This method is optimized for speed. It uses multiple threads and multiple GBs of RAM on large files. /// Warning: This method is optimized for speed. It uses multiple threads and GBs of RAM on large files.
/// ///
/// Usage example: /// Usage example:
/// ``` /// ```
@ -805,7 +804,7 @@ impl Store {
/// If the parsing fails in the middle of the file, only a part of it may be written to the store. /// If the parsing fails in the middle of the file, only a part of it may be written to the store.
/// Results might get weird if you delete data during the loading process. /// Results might get weird if you delete data during the loading process.
/// ///
/// Warning: This method is optimized for speed. It uses multiple threads and multiple GBs of RAM on large files. /// Warning: This method is optimized for speed. It uses multiple threads and GBs of RAM on large files.
/// ///
/// Usage example: /// Usage example:
/// ``` /// ```
@ -817,7 +816,7 @@ impl Store {
/// ///
/// // insertion /// // insertion
/// let file = b"<http://example.com> <http://example.com> <http://example.com> ."; /// let file = b"<http://example.com> <http://example.com> <http://example.com> .";
/// store.bulk_load_graph(file.as_ref(), GraphFormat::NTriples, &GraphName::DefaultGraph, None)?; /// store.bulk_load_graph(file.as_ref(), GraphFormat::NTriples, GraphNameRef::DefaultGraph, None)?;
/// ///
/// // we inspect the store contents /// // we inspect the store contents
/// let ex = NamedNodeRef::new("http://example.com")?; /// let ex = NamedNodeRef::new("http://example.com")?;
@ -853,7 +852,7 @@ impl Store {
/// If the process fails in the middle of the file, only a part of the data may be written to the store. /// If the process fails in the middle of the file, only a part of the data may be written to the store.
/// Results might get weird if you delete data during the loading process. /// Results might get weird if you delete data during the loading process.
/// ///
/// Warning: This method is optimized for speed. It uses multiple threads and multiple GBs of RAM on large files. /// Warning: This method is optimized for speed. It uses multiple threads and GBs of RAM on large files.
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
pub fn bulk_extend(&self, quads: impl IntoIterator<Item = Quad>) -> Result<(), StorageError> { pub fn bulk_extend(&self, quads: impl IntoIterator<Item = Quad>) -> Result<(), StorageError> {
bulk_load::<StorageError, _, _>(&self.storage, quads.into_iter().map(Ok)) bulk_load::<StorageError, _, _>(&self.storage, quads.into_iter().map(Ok))
@ -1007,9 +1006,6 @@ impl<'a> Transaction<'a> {
/// Executes a [SPARQL 1.1 update](https://www.w3.org/TR/sparql11-update/). /// Executes a [SPARQL 1.1 update](https://www.w3.org/TR/sparql11-update/).
/// ///
/// The store does not track the existence of empty named graphs.
/// This method has no ACID guarantees.
///
/// Usage example: /// Usage example:
/// ``` /// ```
/// use oxigraph::store::Store; /// use oxigraph::store::Store;
@ -1061,7 +1057,7 @@ impl<'a> Transaction<'a> {
/// // insertion /// // insertion
/// let file = b"<http://example.com> <http://example.com> <http://example.com> ."; /// let file = b"<http://example.com> <http://example.com> <http://example.com> .";
/// store.transaction(|mut transaction| { /// store.transaction(|mut transaction| {
/// transaction.load_graph(file.as_ref(), GraphFormat::NTriples, &GraphName::DefaultGraph, None) /// transaction.load_graph(file.as_ref(), GraphFormat::NTriples, GraphNameRef::DefaultGraph, None)
/// })?; /// })?;
/// ///
/// // we inspect the store contents /// // we inspect the store contents

@ -438,7 +438,7 @@ impl fmt::Display for DecimalOverflowError {
impl Error for DecimalOverflowError {} impl Error for DecimalOverflowError {}
impl fmt::Display for Decimal { impl fmt::Display for Decimal {
/// Formats the decimal following its canonical representation /// Formats the decimal following its canonical representation.
#[allow(clippy::cast_possible_truncation)] #[allow(clippy::cast_possible_truncation)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if self.value == 0 { if self.value == 0 {

@ -22,8 +22,8 @@ Oxigraph provides python classes to represents basic RDF concepts:
:members: :members:
`Triple <https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-triple>`_ `Triples <https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-triple>`_
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
.. autoclass:: pyoxigraph.Triple .. autoclass:: pyoxigraph.Triple
:members: :members:

@ -517,11 +517,11 @@ impl IntoPy<PyObject> for PyTerm {
/// An RDF `triple <https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-triple>`_. /// An RDF `triple <https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-triple>`_.
/// ///
/// :param subject: the triple subject. /// :param subject: the triple subject.
/// :type subject: NamedNode or BlankNode /// :type subject: NamedNode or BlankNode or Triple
/// :param predicate: the triple predicate. /// :param predicate: the triple predicate.
/// :type predicate: NamedNode /// :type predicate: NamedNode
/// :param object: the triple object. /// :param object: the triple object.
/// :type object: NamedNode or BlankNode or Literal /// :type object: NamedNode or BlankNode or Literal or Triple
/// ///
/// The :py:func:`str` function provides a serialization compatible with NTriples, Turtle and SPARQL: /// The :py:func:`str` function provides a serialization compatible with NTriples, Turtle and SPARQL:
/// ///
@ -576,7 +576,7 @@ impl PyTriple {
} }
/// :return: the triple subject. /// :return: the triple subject.
/// :rtype: NamedNode or BlankNode /// :rtype: NamedNode or BlankNode or Triple
/// ///
/// >>> Triple(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1')).subject /// >>> Triple(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1')).subject
/// <NamedNode value=http://example.com> /// <NamedNode value=http://example.com>
@ -596,7 +596,7 @@ impl PyTriple {
} }
/// :return: the triple object. /// :return: the triple object.
/// :rtype: NamedNode or BlankNode or Literal /// :rtype: NamedNode or BlankNode or Literal or Triple
/// ///
/// >>> Triple(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1')).object /// >>> Triple(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1')).object
/// <Literal value=1 datatype=<NamedNode value=http://www.w3.org/2001/XMLSchema#string>> /// <Literal value=1 datatype=<NamedNode value=http://www.w3.org/2001/XMLSchema#string>>
@ -689,11 +689,11 @@ impl IntoPy<PyObject> for PyGraphName {
/// in a `RDF dataset <https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-dataset>`_. /// in a `RDF dataset <https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-dataset>`_.
/// ///
/// :param subject: the quad subject. /// :param subject: the quad subject.
/// :type subject: NamedNode or BlankNode /// :type subject: NamedNode or BlankNode or Triple
/// :param predicate: the quad predicate. /// :param predicate: the quad predicate.
/// :type predicate: NamedNode /// :type predicate: NamedNode
/// :param object: the quad object. /// :param object: the quad object.
/// :type object: NamedNode or BlankNode or Literal /// :type object: NamedNode or BlankNode or Literal or Triple
/// :param graph: the quad graph name. If not present, the default graph is assumed. /// :param graph: the quad graph name. If not present, the default graph is assumed.
/// :type graph: NamedNode or BlankNode or DefaultGraph or None, optional /// :type graph: NamedNode or BlankNode or DefaultGraph or None, optional
/// ///
@ -752,7 +752,7 @@ impl PyQuad {
} }
/// :return: the quad subject. /// :return: the quad subject.
/// :rtype: NamedNode or BlankNode /// :rtype: NamedNode or BlankNode or Triple
/// ///
/// >>> Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1'), NamedNode('http://example.com/g')).subject /// >>> Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1'), NamedNode('http://example.com/g')).subject
/// <NamedNode value=http://example.com> /// <NamedNode value=http://example.com>
@ -772,7 +772,7 @@ impl PyQuad {
} }
/// :return: the quad object. /// :return: the quad object.
/// :rtype: NamedNode or BlankNode or Literal /// :rtype: NamedNode or BlankNode or Literal or Triple
/// ///
/// >>> Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1'), NamedNode('http://example.com/g')).object /// >>> Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1'), NamedNode('http://example.com/g')).object
/// <Literal value=1 datatype=<NamedNode value=http://www.w3.org/2001/XMLSchema#string>> /// <Literal value=1 datatype=<NamedNode value=http://www.w3.org/2001/XMLSchema#string>>

@ -205,9 +205,6 @@ impl PyStore {
/// :raises SyntaxError: if the provided update is invalid. /// :raises SyntaxError: if the provided update is invalid.
/// :raises IOError: if an I/O error happens while reading the store. /// :raises IOError: if an I/O error happens while reading the store.
/// ///
/// The store does not track the existence of empty named graphs.
/// This method has no ACID guarantees.
///
/// ``INSERT DATA`` update: /// ``INSERT DATA`` update:
/// ///
/// >>> store = Store() /// >>> store = Store()

@ -15,7 +15,7 @@ edition = "2021"
oxhttp = "0.1" oxhttp = "0.1"
clap = { version = "3", features = ["derive"] } clap = { version = "3", features = ["derive"] }
oxigraph = { version = "0.3.0-dev", path = "../lib", features = ["http_client"] } oxigraph = { version = "0.3.0-dev", path = "../lib", features = ["http_client"] }
sparesults = { version = "0.1", path="../lib/sparesults", features = ["rdf-star"] } sparesults = { version = "0.1.0-dev", path="../lib/sparesults", features = ["rdf-star"] }
rand = "0.8" rand = "0.8"
url = "2" url = "2"
oxiri = "0.2" oxiri = "0.2"

@ -256,7 +256,7 @@ fn evaluate_negative_update_syntax_test(test: &Test) -> Result<()> {
fn evaluate_update_evaluation_test(test: &Test) -> Result<()> { fn evaluate_update_evaluation_test(test: &Test) -> Result<()> {
let store = Store::new()?; let store = Store::new()?;
if let Some(data) = &test.data { if let Some(data) = &test.data {
load_to_store(data, &store, &GraphName::DefaultGraph)?; load_to_store(data, &store, GraphNameRef::DefaultGraph)?;
} }
for (name, value) in &test.graph_data { for (name, value) in &test.graph_data {
load_to_store(value, &store, name)?; load_to_store(value, &store, name)?;
@ -264,7 +264,7 @@ fn evaluate_update_evaluation_test(test: &Test) -> Result<()> {
let result_store = Store::new()?; let result_store = Store::new()?;
if let Some(data) = &test.result { if let Some(data) = &test.result {
load_to_store(data, &result_store, &GraphName::DefaultGraph)?; load_to_store(data, &result_store, GraphNameRef::DefaultGraph)?;
} }
for (name, value) in &test.result_graph_data { for (name, value) in &test.result_graph_data {
load_to_store(value, &result_store, name)?; load_to_store(value, &result_store, name)?;
@ -343,7 +343,7 @@ impl StaticServiceHandler {
.map(|(name, data)| { .map(|(name, data)| {
let name = NamedNode::new(name)?; let name = NamedNode::new(name)?;
let store = Store::new()?; let store = Store::new()?;
load_to_store(data, &store, &GraphName::DefaultGraph)?; load_to_store(data, &store, GraphNameRef::DefaultGraph)?;
Ok((name, store)) Ok((name, store))
}) })
.collect::<Result<_>>()?, .collect::<Result<_>>()?,

Loading…
Cancel
Save