Oxigraph is a work in progress graph database implementing the [SPARQL](https://www.w3.org/TR/sparql11-overview/) standard.
Oxigraph is a work in progress graph database implementing the [SPARQL](https://www.w3.org/TR/sparql11-overview/) standard.
There is no released version yet.
There is no released version yet.
The storage format is not stable yet and may be brocken at any time.
Its goal is to provide a compliant, safe and fast graph database based on the [RocksDB](https://rocksdb.org/) key-value store.
Its goal is to provide a compliant, safe and fast graph database based on the [RocksDB](https://rocksdb.org/) and [Sled](https://sled.rs/) key-value stores.
It is written in Rust.
It is written in Rust.
It also provides a set of utility functions for reading, writing and processing RDF files.
It is split into multiple parts:
It is split into multiple parts:
* The `lib` directory contains the database written as a Rust library.
* The `lib` directory contains the database written as a Rust library.
* The `python` directory contains bindings to use Oxigraph in Python. See [its README](https://github.com/oxigraph/oxigraph/blob/master/python/README.md) for the Python bindings documentation.
* The `python` directory contains bindings to use Oxigraph in Python. See [its README](https://github.com/oxigraph/oxigraph/blob/master/python/README.md) for the Python bindings documentation.
* The `js` directory contains bindings to use Oxigraph in JavaScript with the help of WebAssembly. See [its README](https://github.com/oxigraph/oxigraph/blob/master/js/README.md) for the JS bindings documentation.
* The `js` directory contains bindings to use Oxigraph in JavaScript with the help of WebAssembly. See [its README](https://github.com/oxigraph/oxigraph/blob/master/js/README.md) for the JS bindings documentation.
* The `server` directory contains a stand-alone binary of a web server implementing the [SPARQL 1.1 Protocol](https://www.w3.org/TR/sparql11-protocol/).
* The `server` directory contains a stand-alone binary of a web server implementing the [SPARQL 1.1 Protocol](https://www.w3.org/TR/sparql11-protocol/). It uses the [RocksDB](https://rocksdb.org/) key-value store.
* The `wikibase` directory contains a stand-alone binary of a web server able to synchronize with a [Wikibase instance](https://wikiba.se/).
* The `wikibase` directory contains a stand-alone binary of a web server able to synchronize with a [Wikibase instance](https://wikiba.se/).
Are currently implemented:
Are currently implemented:
* [SPARQL 1.1 Query](https://www.w3.org/TR/sparql11-query/) except `FROM` and `FROM NAMED`.
* [SPARQL 1.1 Query](https://www.w3.org/TR/sparql11-query/) except `FROM` and `FROM NAMED`.
* [Turtle](https://www.w3.org/TR/turtle/), [TriG](https://www.w3.org/TR/trig/), [N-Triples](https://www.w3.org/TR/n-triples/), [N-Quads](https://www.w3.org/TR/n-quads/) and [RDF XML](https://www.w3.org/TR/rdf-syntax-grammar/) RDF serialization formats for both data ingestion and retrieval using the [Rio library](https://github.com/oxigraph/rio).
* [Turtle](https://www.w3.org/TR/turtle/), [TriG](https://www.w3.org/TR/trig/), [N-Triples](https://www.w3.org/TR/n-triples/), [N-Quads](https://www.w3.org/TR/n-quads/) and [RDF XML](https://www.w3.org/TR/rdf-syntax-grammar/) RDF serialization formats for both data ingestion and retrieval using the [Rio library](https://github.com/oxigraph/rio).
* [SPARQL Query Results XML Format](http://www.w3.org/TR/rdf-sparql-XMLres/) and [SPARQL Query Results JSON Format](https://www.w3.org/TR/sparql11-results-json/).
* [SPARQL Query Results XML Format](http://www.w3.org/TR/rdf-sparql-XMLres/) and [SPARQL Query Results JSON Format](https://www.w3.org/TR/sparql11-results-json/).
//! Its goal is to provide a compliant, safe and fast graph database.
//! Its goal is to provide a compliant, safe and fast graph database.
//!
//!
//! It currently provides three `Store` implementation providing [SPARQL 1.1 query](https://www.w3.org/TR/sparql11-query/) capability:
//! It currently provides three store implementations providing [SPARQL 1.1 query](https://www.w3.org/TR/sparql11-query/) capability:
//! * `MemoryStore`: a simple in memory implementation.
//! * [`MemoryStore`](store/memory/struct.MemoryStore.html): a simple in memory implementation.
//! * `RocksDbStore`: a file system implementation based on the [RocksDB](https://rocksdb.org/) key-value store.
//! * [`RocksDbStore`](store/rocksdb/struct.RocksDbStore.html): a file system implementation based on the [RocksDB](https://rocksdb.org/) key-value store.
//! It requires the `"rocksdb"` feature to be activated.
//! It requires the `"rocksdb"` feature to be activated.
//! It also requires the [clang](https://clang.llvm.org/) compiler to be installed.
//! The `"rocksdb"` requires the [clang](https://clang.llvm.org/) compiler to be installed.
//! * `SledStore`: another file system implementation based on the [Sled](https://sled.rs/) key-value store.
//! * [`SledStore`](store/sled/struct.SledStore.html): another file system implementation based on the [Sled](https://sled.rs/) key-value store.
//! It requires the `"sled"` feature to be activated.
//! It requires the `"sled"` feature to be activated.
//! Sled is much faster to build than RockDB and does not require a C++ compiler.
//! Sled is much faster to build than RockDB and does not require a C++ compiler.
//! However, Sled is still in developpment, less tested and data load seems much slower than RocksDB.
//! However, Sled is still in developpment, less tested and data load seems much slower than RocksDB.
//!
//!
//! Usage example with the `MemoryStore`:
//! It also provides a set of utility functions for reading, writing and processing RDF files.
//!
//! Usage example with the [`MemoryStore`](store/memory/struct.MemoryStore.html):
/// Use a given `ServiceHandler` to execute SPARQL SERVICE calls
/// Use a given [`ServiceHandler`](trait.ServiceHandler.html) to execute [SPARQL 1.1 Federated Query](https://www.w3.org/TR/sparql11-federated-query/) SERVICE calls.
/// Returns a value for a given position in the tuple (`usize`) or a given variable name (`&str` or `Variable`)
/// Returns a value for a given position in the tuple ([`usize`](https://doc.rust-lang.org/std/primitive.usize.html)) or a given variable name ([`&str`](https://doc.rust-lang.org/std/primitive.str.html) or [`Variable`](struct.Variable.html))
///
///
/// ```ignore
/// ```ignore
/// let foo = solution.get("foo"); // Get the value of the variable ?foo if it exists
/// let foo = solution.get("foo"); // Get the value of the variable ?foo if it exists
/// Errors related to parameter validation like the base IRI use the `INVALID_INPUT` error kind.
/// Warning: This functions saves the triples during the parsing.
/// Errors related to a bad syntax in the loaded file use the `INVALID_DATA` error kind.
/// If the parsing fails in the middle of the file, the triples read before stay in the store.
/// Use a (memory greedy) [transaction](#method.transaction) if you do not want that.
///
/// Errors related to parameter validation like the base IRI use the [`InvalidInput`](https://doc.rust-lang.org/std/io/enum.ErrorKind.html#variant.InvalidInput) error kind.
/// Errors related to a bad syntax in the loaded file use the [`InvalidData`](https://doc.rust-lang.org/std/io/enum.ErrorKind.html#variant.InvalidData) error kind.
/// Errors related to parameter validation like the base IRI use the `INVALID_INPUT` error kind.
/// Warning: This functions saves the quads during the parsing.
/// Errors related to a bad syntax in the loaded file use the `INVALID_DATA` error kind.
/// If the parsing fails in the middle of the file, the quads read before stay in the store.
/// Use a (memory greedy) [transaction](#method.transaction) if you do not want that.
///
/// Errors related to parameter validation like the base IRI use the [`InvalidInput`](https://doc.rust-lang.org/std/io/enum.ErrorKind.html#variant.InvalidInput) error kind.
/// Errors related to a bad syntax in the loaded file use the [`InvalidData`](https://doc.rust-lang.org/std/io/enum.ErrorKind.html#variant.InvalidData) error kind.
pubfnload_dataset(
pubfnload_dataset(
&self,
&self,
reader: implBufRead,
reader: implBufRead,
@ -376,8 +384,8 @@ impl MemoryStore {
/// # std::io::Result::Ok(())
/// # std::io::Result::Ok(())
/// ```
/// ```
///
///
/// Errors related to parameter validation like the base IRI use the `INVALID_INPUT` error kind.
/// Errors related to parameter validation like the base IRI use the [`InvalidInput`](https://doc.rust-lang.org/std/io/enum.ErrorKind.html#variant.InvalidInput) error kind.
/// Errors related to a bad syntax in the loaded file use the `INVALID_DATA` error kind.
/// Errors related to a bad syntax in the loaded file use the [`InvalidData`](https://doc.rust-lang.org/std/io/enum.ErrorKind.html#variant.InvalidData) error kind.
pubfndump_graph<'a>(
pubfndump_graph<'a>(
&self,
&self,
writer: implWrite,
writer: implWrite,
@ -410,8 +418,8 @@ impl MemoryStore {
/// # std::io::Result::Ok(())
/// # std::io::Result::Ok(())
/// ```
/// ```
///
///
/// Errors related to parameter validation like the base IRI use the `INVALID_INPUT` error kind.
/// Errors related to parameter validation like the base IRI use the [`InvalidInput`](https://doc.rust-lang.org/std/io/enum.ErrorKind.html#variant.InvalidInput) error kind.
/// Errors related to a bad syntax in the loaded file use the `INVALID_DATA` error kind.
/// Errors related to a bad syntax in the loaded file use the [`InvalidData`](https://doc.rust-lang.org/std/io/enum.ErrorKind.html#variant.InvalidData) error kind.
/// Loads a graph file (i.e. triples) into the store
/// Loads a graph file (i.e. triples) into the store
///
///
/// Warning: This functions saves the triples in batch. If the parsing fails in the middle of the file,
/// Warning: This functions saves the triples in batch. If the parsing fails in the middle of the file,
/// only a part of it may be written. Use a (memory greedy) transaction if you do not want that.
/// only a part of it may be written. Use a (memory greedy) [transaction](#method.transaction) if you do not want that.
///
///
/// See `MemoryStore` for a usage example.
/// See [`MemoryStore`](../memory/struct.MemoryStore.html#method.load_graph) for a usage example.
///
///
/// Errors related to parameter validation like the base IRI use the `INVALID_INPUT` error kind.
/// Errors related to parameter validation like the base IRI use the [`InvalidInput`](https://doc.rust-lang.org/std/io/enum.ErrorKind.html#variant.InvalidInput) error kind.
/// Errors related to a bad syntax in the loaded file use the `INVALID_DATA` error kind.
/// Errors related to a bad syntax in the loaded file use the [`InvalidData`](https://doc.rust-lang.org/std/io/enum.ErrorKind.html#variant.InvalidData) error kind.
/// Errors related to data loading into the store use the other error kinds.
/// Errors related to data loading into the store use the other error kinds.
pubfnload_graph<'a>(
pubfnload_graph<'a>(
&self,
&self,
@ -215,12 +217,12 @@ impl RocksDbStore {
/// Loads a dataset file (i.e. quads) into the store.
/// Loads a dataset file (i.e. quads) into the store.
///
///
/// Warning: This functions saves the quads in batch. If the parsing fails in the middle of the file,
/// Warning: This functions saves the quads in batch. If the parsing fails in the middle of the file,
/// only a part of it may be written. Use a (memory greedy) transaction if you do not want that.
/// only a part of it may be written. Use a (memory greedy) [transaction](#method.transaction) if you do not want that.
///
///
/// See `MemoryStore` for a usage example.
/// See [`MemoryStore`](../memory/struct.MemoryStore.html#method.load_dataset) for a usage example.
///
///
/// Errors related to parameter validation like the base IRI use the `INVALID_INPUT` error kind.
/// Errors related to parameter validation like the base IRI use the [`InvalidInput`](https://doc.rust-lang.org/std/io/enum.ErrorKind.html#variant.InvalidInput) error kind.
/// Errors related to a bad syntax in the loaded file use the `INVALID_DATA` error kind.
/// Errors related to a bad syntax in the loaded file use the [`InvalidData`](https://doc.rust-lang.org/std/io/enum.ErrorKind.html#variant.InvalidData) error kind.
/// Errors related to data loading into the store use the other error kinds.
/// Errors related to data loading into the store use the other error kinds.
pubfnload_dataset(
pubfnload_dataset(
&self,
&self,
@ -234,6 +236,7 @@ impl RocksDbStore {
}
}
/// Adds a quad to this store.
/// Adds a quad to this store.
/// This operation is atomic and could not leave the store in a bad state.
/// Loads a graph file (i.e. triples) into the store during the transaction.
/// Loads a graph file (i.e. triples) into the store during the transaction.
///
///
/// Warning: Because the load happens during a transaction,
/// Warning: Because the load happens during a transaction,
/// the full file content might be temporarily stored in main memory.
/// the full file content is temporarily stored in main memory.
/// Do not use for big files.
/// Do not use for big files.
///
///
/// See `MemoryTransaction` for a usage example.
/// See [`MemoryTransaction`](../memory/struct.MemoryTransaction.html#method.load_graph) for a usage example.
///
/// If the file parsing fails in the middle of the file, the triples read before are still
/// considered by the transaction. Rollback the transaction by making the transaction closure
/// return an error if you don't want that.
///
///
/// Errors related to parameter validation like the base IRI use the `INVALID_INPUT` error kind.
/// Errors related to parameter validation like the base IRI use the [`InvalidInput`](https://doc.rust-lang.org/std/io/enum.ErrorKind.html#variant.InvalidInput) error kind.
/// Errors related to a bad syntax in the loaded file use the `INVALID_DATA` error kind.
/// Errors related to a bad syntax in the loaded file use the [`InvalidData`](https://doc.rust-lang.org/std/io/enum.ErrorKind.html#variant.InvalidData) error kind.
/// Loads a dataset file (i.e. quads) into the store. into the store during the transaction.
/// Loads a dataset file (i.e. quads) into the store. into the store during the transaction.
///
///
/// Warning: Because the load happens during a transaction,
/// Warning: Because the load happens during a transaction,
/// the full file content might be temporarily stored in main memory.
/// the full file content is temporarily stored in main memory.
/// Do not use for big files.
/// Do not use for big files.
///
///
/// See `MemoryTransaction` for a usage example.
/// See [`MemoryTransaction`](../memory/struct.MemoryTransaction.html#method.load_dataset) for a usage example.
///
/// If the file parsing fails in the middle of the file, the quads read before are still
/// considered by the transaction. Rollback the transaction by making the transaction closure
/// return an error if you don't want that.
///
///
/// Errors related to parameter validation like the base IRI use the `INVALID_INPUT` error kind.
/// Errors related to parameter validation like the base IRI use the [`InvalidInput`](https://doc.rust-lang.org/std/io/enum.ErrorKind.html#variant.InvalidInput) error kind.
/// Errors related to a bad syntax in the loaded file use the `INVALID_DATA` error kind.
/// Errors related to a bad syntax in the loaded file use the [`InvalidData`](https://doc.rust-lang.org/std/io/enum.ErrorKind.html#variant.InvalidData) error kind.
/// Retrieves quads with a filter on each quad component
/// Retrieves quads with a filter on each quad component
///
///
/// See `MemoryStore` for a usage example.
/// See [`MemoryStore`](../memory/struct.MemoryStore.html#method.quads_for_pattern) for a usage example.
pubfnquads_for_pattern(
pubfnquads_for_pattern(
&self,
&self,
subject: Option<NamedOrBlankNodeRef<'_>>,
subject: Option<NamedOrBlankNodeRef<'_>>,
@ -160,10 +160,10 @@ impl SledStore {
self.quads.is_empty()
self.quads.is_empty()
}
}
/// Executes a transaction.
/// Executes an ACID transaction.
///
///
/// The transaction is executed if the given closure returns `Ok`.
/// The transaction is executed if the given closure returns `Ok`.
/// Nothing is done if the closure returns `Err`.
/// The transaction is rollbacked if the closure returns `Err`.
///
///
/// Usage example:
/// Usage example:
/// ```
/// ```
@ -197,13 +197,16 @@ impl SledStore {
/// Loads a graph file (i.e. triples) into the store
/// Loads a graph file (i.e. triples) into the store
///
///
/// Warning: This functions saves the triples in batch. If the parsing fails in the middle of the file,
/// Warning: This functions saves the triples in a not atomic way. If the parsing fails in the middle of the file,
/// only a part of it may be written. Use a (memory greedy) transaction if you do not want that.
/// only a part of it may be written to the store.
/// Also, this method is optimized for performances and is not atomic.
/// It might leave the store in a bad state if a crash happens during a triple insertion.
/// Use a (memory greedy) [transaction](#method.transaction) if you do not want that.
///
///
/// See `MemoryStore` for a usage example.
/// See [`MemoryStore`](../memory/struct.MemoryStore.html#method.load_graph) for a usage example.
///
///
/// Errors related to parameter validation like the base IRI use the `INVALID_INPUT` error kind.
/// Errors related to parameter validation like the base IRI use the [`InvalidInput`](https://doc.rust-lang.org/std/io/enum.ErrorKind.html#variant.InvalidInput) error kind.
/// Errors related to a bad syntax in the loaded file use the `INVALID_DATA` error kind.
/// Errors related to a bad syntax in the loaded file use the [`InvalidData`](https://doc.rust-lang.org/std/io/enum.ErrorKind.html#variant.InvalidData) error kind.
/// Errors related to data loading into the store use the other error kinds.
/// Errors related to data loading into the store use the other error kinds.
pubfnload_graph<'a>(
pubfnload_graph<'a>(
&self,
&self,
@ -219,13 +222,16 @@ impl SledStore {
/// Loads a dataset file (i.e. quads) into the store.
/// Loads a dataset file (i.e. quads) into the store.
///
///
/// Warning: This functions saves the quads in batch. If the parsing fails in the middle of the file,
/// Warning: This functions saves the triples in a not atomic way. If the parsing fails in the middle of the file,
/// only a part of it may be written. Use a (memory greedy) transaction if you do not want that.
/// only a part of it may be written to the store.
/// Also, this method is optimized for performances and is not atomic.
/// It might leave the store in a bad state if a crash happens during a quad insertion.
/// Use a (memory greedy) [transaction](#method.transaction) if you do not want that.
///
///
/// See `MemoryStore` for a usage example.
/// See [`MemoryStore`](../memory/struct.MemoryStore.html#method.load_dataset) for a usage example.
///
///
/// Errors related to parameter validation like the base IRI use the `INVALID_INPUT` error kind.
/// Errors related to parameter validation like the base IRI use the [`InvalidInput`](https://doc.rust-lang.org/std/io/enum.ErrorKind.html#variant.InvalidInput) error kind.
/// Errors related to a bad syntax in the loaded file use the `INVALID_DATA` error kind.
/// Errors related to a bad syntax in the loaded file use the [`InvalidData`](https://doc.rust-lang.org/std/io/enum.ErrorKind.html#variant.InvalidData) error kind.
/// Errors related to data loading into the store use the other error kinds.
/// Errors related to data loading into the store use the other error kinds.
pubfnload_dataset(
pubfnload_dataset(
&self,
&self,
@ -239,6 +245,10 @@ impl SledStore {
}
}
/// Adds a quad to this store.
/// Adds a quad to this store.
///
/// This method is optimized for performances and is not atomic.
/// It might leave the store in a bad state if a crash happens during the insertion.
/// Use a (memory greedy) [transaction](#method.transaction) if you do not want that.
@ -584,7 +598,7 @@ impl<'a> WritableEncodedStore for &'a SledStore {
}
}
}
}
/// Allows inserting and deleting quads during a transaction with the `SeldStore`.
/// Allows inserting and deleting quads during an ACID transaction with the [`SledStore`](struct.SledStore.html).
pubstructSledTransaction<'a>{
pubstructSledTransaction<'a>{
quads: &'aTransactionalTree,
quads: &'aTransactionalTree,
id2str: &'aTransactionalTree,
id2str: &'aTransactionalTree,
@ -597,10 +611,14 @@ impl SledTransaction<'_> {
/// the full file content might be temporarily stored in main memory.
/// the full file content might be temporarily stored in main memory.
/// Do not use for big files.
/// Do not use for big files.
///
///
/// See `MemoryTransaction` for a usage example.
/// See [`MemoryTransaction`](../memory/struct.MemoryTransaction.html#method.load_graph) for a usage example.
///
///
/// Errors related to parameter validation like the base IRI use the `INVALID_INPUT` error kind.
/// If the file parsing fails in the middle of the file, the triples read before are still
/// Errors related to a bad syntax in the loaded file use the `INVALID_DATA` error kind.
/// considered by the transaction. Rollback the transaction by making the transaction closure
/// return an error if you don't want that.
///
/// Errors related to parameter validation like the base IRI use the [`InvalidInput`](https://doc.rust-lang.org/std/io/enum.ErrorKind.html#variant.InvalidInput) error kind.
/// Errors related to a bad syntax in the loaded file use the [`InvalidData`](https://doc.rust-lang.org/std/io/enum.ErrorKind.html#variant.InvalidData) error kind.
pubfnload_graph<'a>(
pubfnload_graph<'a>(
&self,
&self,
reader: implBufRead,
reader: implBufRead,
@ -619,10 +637,14 @@ impl SledTransaction<'_> {
/// the full file content might be temporarily stored in main memory.
/// the full file content might be temporarily stored in main memory.
/// Do not use for big files.
/// Do not use for big files.
///
///
/// See `MemoryTransaction` for a usage example.
/// See [`MemoryTransaction`](../memory/struct.MemoryTransaction.html#method.load_dataset) for a usage example.
///
/// If the file parsing fails in the middle of the file, the quads read before are still
/// considered by the transaction. Rollback the transaction by making the transaction closure
/// return an error if you don't want that.
///
///
/// Errors related to parameter validation like the base IRI use the `INVALID_INPUT` error kind.
/// Errors related to parameter validation like the base IRI use the [`InvalidInput`](https://doc.rust-lang.org/std/io/enum.ErrorKind.html#variant.InvalidInput) error kind.
/// Errors related to a bad syntax in the loaded file use the `INVALID_DATA` error kind.
/// Errors related to a bad syntax in the loaded file use the [`InvalidData`](https://doc.rust-lang.org/std/io/enum.ErrorKind.html#variant.InvalidData) error kind.
pubfnload_dataset(
pubfnload_dataset(
&self,
&self,
reader: implBufRead,
reader: implBufRead,
@ -903,7 +925,7 @@ impl<T> From<SledConflictableTransactionError<T>> for ConflictableTransactionErr
}
}
}
}
/// A prepared [SPARQL query](https://www.w3.org/TR/sparql11-query/) for the `SledStore`.
/// A prepared [SPARQL query](https://www.w3.org/TR/sparql11-query/) for the [`SledStore`](struct.SledStore.html).