Small code cleanup

pull/41/head
Tpt 4 years ago
parent 8c02fd7513
commit 5039da163b
  1. 2
      lib/src/error.rs
  2. 11
      lib/src/lib.rs
  3. 2
      lib/src/model/blank_node.rs
  4. 2
      lib/src/model/graph.rs
  5. 12
      lib/src/model/literal.rs
  6. 2
      lib/src/model/mod.rs
  7. 6
      lib/src/model/named_node.rs
  8. 6
      lib/src/model/triple.rs
  9. 2
      lib/src/sparql/plan_builder.rs
  10. 2
      lib/src/store/mod.rs
  11. 4
      lib/src/store/rocksdb.rs

@ -10,7 +10,7 @@ use std::string::FromUtf8Error;
/// The Oxigraph error type.
///
/// The `wrap` method allows to make this type wrap any implementation of `std::error::Error`.
/// The `wrap` method allows us to make this type wrap any implementation of `std::error::Error`.
/// This type also avoids heap allocations for the most common cases of Oxigraph errors.
#[derive(Debug)]
pub struct Error {

@ -6,11 +6,11 @@
//! * `MemoryStore`: a simple in memory implementation.
//! * `RocksDbStore`: a file system implementation based on the [RocksDB](https://rocksdb.org/) key-value store.
//! It requires the `"rocksdb"` feature to be activated.
//! It also requires the clang](https://clang.llvm.org/) compiler to be installed.
//! It also 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.
//! It requires the `"sled"` feature to be activated.
//! Sled is much faster to build than RockDB and does not require a C++ compiler.
//! However Sled is still in heavy 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`:
//!
@ -90,7 +90,6 @@
clippy::print_stdout,
clippy::pub_enum_variant_names,
//TODO clippy::redundant_closure_for_method_calls,
clippy::replace_consts,
clippy::result_map_unwrap_or_else,
// clippy::shadow_reuse,
// clippy::shadow_same,
@ -115,11 +114,11 @@ mod syntax;
pub use error::Error;
pub type Result<T> = ::std::result::Result<T, Error>;
pub use crate::store::MemoryStore;
pub use crate::store::memory::MemoryStore;
#[cfg(feature = "rocksdb")]
pub use crate::store::RocksDbStore;
pub use crate::store::rocksdb::RocksDbStore;
#[cfg(feature = "sled")]
pub use crate::store::SledStore;
pub use crate::store::sled::SledStore;
pub use crate::syntax::DatasetSyntax;
pub use crate::syntax::FileSyntax;
pub use crate::syntax::GraphSyntax;

@ -4,7 +4,7 @@ use std::fmt;
use std::io::Write;
use std::str;
/// A RDF [blank node](https://www.w3.org/TR/rdf11-concepts/#dfn-blank-node).
/// An RDF [blank node](https://www.w3.org/TR/rdf11-concepts/#dfn-blank-node).
///
/// This implementation enforces that the blank node id is a uniquely generated ID to easily ensure
/// that it is not possible for two blank nodes to share an id.

@ -130,7 +130,7 @@ impl SimpleGraph {
/// Checks if the current graph is [isomorphic](https://www.w3.org/TR/rdf11-concepts/#dfn-graph-isomorphism) with another one
///
/// Warning: This algorithm as a worst case complexity in n!
/// Warning: This algorithm worst case complexity is in O(n!)
pub fn is_isomorphic(&self, other: &SimpleGraph) -> bool {
are_graphs_isomorphic(self, other)
}

@ -8,7 +8,7 @@ use std::borrow::Cow;
use std::fmt;
use std::option::Option;
/// A RDF [literal](https://www.w3.org/TR/rdf11-concepts/#dfn-literal)
/// An RDF [literal](https://www.w3.org/TR/rdf11-concepts/#dfn-literal)
///
/// The default string formatter is returning a N-Triples, Turtle and SPARQL compatible representation:
/// ```
@ -43,12 +43,12 @@ enum LiteralContent {
}
impl Literal {
/// Builds a RDF [simple literal](https://www.w3.org/TR/rdf11-concepts/#dfn-simple-literal)
/// Builds an RDF [simple literal](https://www.w3.org/TR/rdf11-concepts/#dfn-simple-literal)
pub fn new_simple_literal(value: impl Into<String>) -> Self {
Literal(LiteralContent::String(value.into()))
}
/// Builds a RDF [literal](https://www.w3.org/TR/rdf11-concepts/#dfn-literal) with a [datatype](https://www.w3.org/TR/rdf11-concepts/#dfn-datatype-iri)
/// Builds an RDF [literal](https://www.w3.org/TR/rdf11-concepts/#dfn-literal) with a [datatype](https://www.w3.org/TR/rdf11-concepts/#dfn-datatype-iri)
pub fn new_typed_literal(value: impl Into<String>, datatype: impl Into<NamedNode>) -> Self {
let value = value.into();
let datatype = datatype.into();
@ -59,7 +59,7 @@ impl Literal {
})
}
/// Builds a RDF [language-tagged string](https://www.w3.org/TR/rdf11-concepts/#dfn-language-tagged-string)
/// Builds an RDF [language-tagged string](https://www.w3.org/TR/rdf11-concepts/#dfn-language-tagged-string)
pub fn new_language_tagged_literal(
value: impl Into<String>,
language: impl Into<String>,
@ -72,7 +72,7 @@ impl Literal {
}))
}
/// Builds a RDF [language-tagged string](https://www.w3.org/TR/rdf11-concepts/#dfn-language-tagged-string)
/// Builds an RDF [language-tagged string](https://www.w3.org/TR/rdf11-concepts/#dfn-language-tagged-string)
///
/// It is the responsibility of the caller to check that `language`
/// is valid [BCP47](https://tools.ietf.org/html/bcp47) language tag,
@ -122,7 +122,7 @@ impl Literal {
}
}
/// Checks if it could be considered as an RDF 1.0 [plain literal](https://www.w3.org/TR/rdf-concepts/#dfn-plain-literal).
/// Checks if this lieteral could be seen as an RDF 1.0 [plain literal](https://www.w3.org/TR/rdf-concepts/#dfn-plain-literal).
///
/// It returns true if the literal is a [language-tagged string](https://www.w3.org/TR/rdf11-concepts/#dfn-language-tagged-string)
/// or has the datatype [xsd:string](http://www.w3.org/2001/XMLSchema#string).

@ -1,6 +1,6 @@
//! Implements data structures for [RDF 1.1 Concepts](https://www.w3.org/TR/rdf11-concepts/).
//!
//! Inspired by [RDFjs](http://rdf.js.org/) and [Apache Commons RDF](http://commons.apache.org/proper/commons-rdf/)
//! Inspired by [RDF/JS](https://rdf.js.org/data-model-spec/) and [Apache Commons RDF](http://commons.apache.org/proper/commons-rdf/)
mod blank_node;
mod graph;

@ -2,7 +2,7 @@ use oxiri::{Iri, IriParseError};
use rio_api::model as rio;
use std::fmt;
/// A RDF [IRI](https://www.w3.org/TR/rdf11-concepts/#dfn-iri)
/// An RDF [IRI](https://www.w3.org/TR/rdf11-concepts/#dfn-iri)
///
/// The default string formatter is returning a N-Triples, Turtle and SPARQL compatible representation:
/// ```
@ -19,7 +19,7 @@ pub struct NamedNode {
}
impl NamedNode {
/// Builds and validate a RDF [IRI](https://www.w3.org/TR/rdf11-concepts/#dfn-iri)
/// Builds and validate an RDF [IRI](https://www.w3.org/TR/rdf11-concepts/#dfn-iri)
pub fn parse(iri: impl Into<String>) -> Result<Self, IriParseError> {
Ok(Self::new_from_iri(Iri::parse(iri.into())?))
}
@ -28,7 +28,7 @@ impl NamedNode {
Self::new_unchecked(iri.into_inner())
}
/// Builds a RDF [IRI](https://www.w3.org/TR/rdf11-concepts/#dfn-iri) from a string.
/// Builds an RDF [IRI](https://www.w3.org/TR/rdf11-concepts/#dfn-iri) from a string.
///
/// It is the caller's responsibility to ensure that `iri` is a valid IRI.
///

@ -57,7 +57,7 @@ impl<'a> From<&'a NamedOrBlankNode> for rio::NamedOrBlankNode<'a> {
}
}
/// A RDF [term](https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-term)
/// An 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) and [literals](https://www.w3.org/TR/rdf11-concepts/#dfn-literal).
#[derive(Eq, PartialEq, Ord, PartialOrd, Debug, Clone, Hash)]
pub enum Term {
@ -148,7 +148,7 @@ pub struct Triple {
}
impl Triple {
/// Builds a RDF [triple](https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-triple)
/// Builds an RDF [triple](https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-triple)
pub fn new(
subject: impl Into<NamedOrBlankNode>,
predicate: impl Into<NamedNode>,
@ -228,7 +228,7 @@ pub struct Quad {
}
impl Quad {
/// Builds a RDF [triple](https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-triple) in a [RDF dataset](https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-dataset)
/// Builds an RDF [triple](https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-triple) in a [RDF dataset](https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-dataset)
pub fn new(
subject: impl Into<NamedOrBlankNode>,
predicate: impl Into<NamedNode>,

@ -981,7 +981,7 @@ fn bnode_key(blank_nodes: &mut Vec<BlankNode>, blank_node: &BlankNode) -> usize
match slice_key(blank_nodes, blank_node) {
Some(key) => key,
None => {
blank_nodes.push(blank_node.clone());
blank_nodes.push(*blank_node);
blank_nodes.len() - 1
}
}

@ -1,7 +1,7 @@
//! RDF quads storage implementations.
//!
//! They encode a [RDF dataset](https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-dataset)
//! and allow to query and update it using SPARQL.
//! and allow querying and updating them using SPARQL.
pub mod memory;
pub(crate) mod numeric_encoder;

@ -159,7 +159,7 @@ impl RocksDbStore {
/// Executes a transaction.
///
/// The transaction is executed if the given closure returns `Ok`.
/// Nothing is done if the clusre returns `Err`.
/// Nothing is done if the closure returns `Err`.
///
/// See `MemoryStore` for a usage example.
pub fn transaction<'a>(
@ -691,7 +691,7 @@ impl RocksDbInnerTransaction<'_> {
#[allow(clippy::option_expect_used)]
fn get_cf<'a>(db: &'a DB, name: &str) -> &'a ColumnFamily {
db.cf_handle(name)
.expect("A column family that should exists in RocksDB does not exists")
.expect("A column family that should exist in RocksDB does not exist")
}
fn encode_term(t: EncodedTerm) -> Vec<u8> {

Loading…
Cancel
Save