[][src]Struct oxigraph::store::sled::SledStore

pub struct SledStore { /* fields omitted */ }

Store based on the Sled key-value database. It encodes a RDF dataset and allows to query it using SPARQL.

To use it, the "sled" feature needs to be activated.

Warning: Sled is not stable yet and might break its storage format.

Usage example:

use oxigraph::SledStore;
use oxigraph::sparql::QueryResults;
use oxigraph::model::*;

let store = SledStore::open("example.db")?;

// insertion
let ex = NamedNode::new("http://example.com")?;
let quad = Quad::new(ex.clone(), ex.clone(), ex.clone(), None);
store.insert(&quad)?;

// quad filter
let results: Result<Vec<Quad>,_> = store.quads_for_pattern(None, None, None, None).collect();
assert_eq!(vec![quad], results?);

// SPARQL query
if let QueryResults::Solutions(mut solutions) = store.query("SELECT ?s WHERE { ?s ?p ?o }")? {
    assert_eq!(solutions.next().unwrap()?.get("s"), Some(&ex.into()));
};

Implementations

impl SledStore[src]

pub fn new() -> Result<Self, Error>[src]

Creates a temporary SledStore that will be deleted after drop.

pub fn open(path: impl AsRef<Path>) -> Result<Self, Error>[src]

Opens a SledStore and creates it if it does not exist yet.

pub fn query(
    &self,
    query: impl TryInto<Query, Error = impl Into<EvaluationError>>
) -> Result<QueryResults, EvaluationError>
[src]

Executes a SPARQL 1.1 query.

See MemoryStore for a usage example.

pub fn query_opt(
    &self,
    query: impl TryInto<Query, Error = impl Into<EvaluationError>>,
    options: QueryOptions
) -> Result<QueryResults, EvaluationError>
[src]

Executes a SPARQL 1.1 query with some options.

pub fn quads_for_pattern(
    &self,
    subject: Option<NamedOrBlankNodeRef<'_>>,
    predicate: Option<NamedNodeRef<'_>>,
    object: Option<TermRef<'_>>,
    graph_name: Option<GraphNameRef<'_>>
) -> SledQuadIter

Notable traits for SledQuadIter

impl Iterator for SledQuadIter type Item = Result<Quad, Error>;
[src]

Retrieves quads with a filter on each quad component

See MemoryStore for a usage example.

pub fn iter(&self) -> SledQuadIter

Notable traits for SledQuadIter

impl Iterator for SledQuadIter type Item = Result<Quad, Error>;
[src]

Returns all the quads contained in the store

pub fn contains<'a>(&self, quad: impl Into<QuadRef<'a>>) -> Result<bool, Error>[src]

Checks if this store contains a given quad

pub fn len(&self) -> usize[src]

Returns the number of quads in the store

Warning: this function executes a full scan

pub fn is_empty(&self) -> bool[src]

Returns if the store is empty

pub fn update(
    &self,
    update: impl TryInto<Update, Error = impl Into<EvaluationError>>
) -> Result<(), EvaluationError>
[src]

Executes a SPARQL 1.1 update.

The store does not track the existence of empty named graphs. This method has no ACID guarantees.

See MemoryStore for a usage example.

pub fn update_opt(
    &self,
    update: impl TryInto<Update, Error = impl Into<EvaluationError>>,
    options: UpdateOptions
) -> Result<(), EvaluationError>
[src]

Executes a SPARQL 1.1 update with some options.

pub fn transaction<T, E>(
    &self,
    f: impl Fn(SledTransaction<'_>) -> Result<T, SledConflictableTransactionError<E>>
) -> Result<T, SledTransactionError<E>>
[src]

Executes an ACID transaction.

The transaction is executed if the given closure returns Ok. The transaction is rollbacked if the closure returns Err.

Usage example:

use oxigraph::SledStore;
use oxigraph::model::*;
use oxigraph::store::sled::SledConflictableTransactionError;
use std::convert::Infallible;

let store = SledStore::new()?;

let ex = NamedNode::new("http://example.com")?;
let quad = Quad::new(ex.clone(), ex.clone(), ex.clone(), None);

// transaction
store.transaction(|transaction| {
    transaction.insert(&quad)?;
    Ok(()) as Result<(),SledConflictableTransactionError<Infallible>>
})?;

// quad filter
assert!(store.contains(&quad)?);

pub fn load_graph<'a>(
    &self,
    reader: impl BufRead,
    format: GraphFormat,
    to_graph_name: impl Into<GraphNameRef<'a>>,
    base_iri: Option<&str>
) -> Result<(), Error>
[src]

Loads a graph file (i.e. triples) into the store

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 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 if you do not want that.

See MemoryStore for a usage example.

Errors related to parameter validation like the base IRI use the InvalidInput error kind. Errors related to a bad syntax in the loaded file use the InvalidData or UnexpectedEof error kinds. Errors related to data loading into the store use the other error kinds.

pub fn load_dataset(
    &self,
    reader: impl BufRead,
    format: DatasetFormat,
    base_iri: Option<&str>
) -> Result<(), Error>
[src]

Loads a dataset file (i.e. quads) into the store.

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 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 if you do not want that.

See MemoryStore for a usage example.

Errors related to parameter validation like the base IRI use the InvalidInput error kind. Errors related to a bad syntax in the loaded file use the InvalidData or UnexpectedEof error kinds. Errors related to data loading into the store use the other error kinds.

pub fn insert<'a>(&self, quad: impl Into<QuadRef<'a>>) -> Result<(), Error>[src]

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 if you do not want that.

pub fn remove<'a>(&self, quad: impl Into<QuadRef<'a>>) -> Result<(), Error>[src]

Removes a quad from 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 removal. Use a (memory greedy) transaction if you do not want that.

pub fn dump_graph<'a>(
    &self,
    writer: impl Write,
    format: GraphFormat,
    from_graph_name: impl Into<GraphNameRef<'a>>
) -> Result<(), Error>
[src]

Dumps a store graph into a file.

See MemoryStore for a usage example.

pub fn dump_dataset(
    &self,
    writer: impl Write,
    format: DatasetFormat
) -> Result<(), Error>
[src]

Dumps the store into a file.

See MemoryStore for a usage example.

pub fn named_graphs(&self) -> SledGraphNameIter[src]

Returns all the store named graphs

See MemoryStore for a usage example.

pub fn contains_named_graph<'a>(
    &self,
    graph_name: impl Into<NamedOrBlankNodeRef<'a>>
) -> Result<bool, Error>
[src]

Checks if the store contains a given graph

See MemoryStore for a usage example.

pub fn insert_named_graph<'a>(
    &self,
    graph_name: impl Into<NamedOrBlankNodeRef<'a>>
) -> Result<(), Error>
[src]

Inserts a graph into this store

See MemoryStore for a usage example.

pub fn clear_graph<'a>(
    &self,
    graph_name: impl Into<GraphNameRef<'a>>
) -> Result<(), Error>
[src]

Clears a graph from this store.

See MemoryStore for a usage example.

pub fn remove_named_graph<'a>(
    &self,
    graph_name: impl Into<NamedOrBlankNodeRef<'a>>
) -> Result<(), Error>
[src]

Removes a graph from this store.

See MemoryStore for a usage example.

pub fn clear(&self) -> Result<(), Error>[src]

Clears the store.

See MemoryStore for a usage example.

Trait Implementations

impl Clone for SledStore[src]

impl CollectibleDataset for SledStore[src]

impl Dataset for SledStore[src]

type Quad = ByValue<([Term; 3], Option<Term>)>

Determine the type of Quads that the methods of this dataset will yield (see streaming_mode Read more

type Error = Error

The error type that this dataset may raise.

impl Display for SledStore[src]

impl MutableDataset for SledStore[src]

type MutationError = Error

The error type that this dataset may raise during mutations.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Conv for T

impl<T> Conv for T

impl<T> FmtForward for T

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pipe for T where
    T: ?Sized

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Tap for T

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> TryConv for T

impl<T> TryConv for T

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,