|
|
@ -45,13 +45,13 @@ impl QueryResults { |
|
|
|
/// This method fails if it is called on the `Graph` results
|
|
|
|
/// This method fails if it is called on the `Graph` results
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
/// use oxigraph::MemoryStore;
|
|
|
|
/// use oxigraph::SledStore;
|
|
|
|
/// use oxigraph::model::*;
|
|
|
|
/// use oxigraph::model::*;
|
|
|
|
/// use oxigraph::sparql::QueryResultsFormat;
|
|
|
|
/// use oxigraph::sparql::QueryResultsFormat;
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// let store = MemoryStore::new();
|
|
|
|
/// let store = SledStore::new()?;
|
|
|
|
/// let ex = NamedNode::new("http://example.com")?;
|
|
|
|
/// let ex = NamedNodeRef::new("http://example.com")?;
|
|
|
|
/// store.insert(Quad::new(ex.clone(), ex.clone(), ex.clone(), None));
|
|
|
|
/// store.insert(QuadRef::new(ex, ex, ex, GraphNameRef::DefaultGraph))?;
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// let mut results = Vec::new();
|
|
|
|
/// let mut results = Vec::new();
|
|
|
|
/// store.query("SELECT ?s WHERE { ?s ?p ?o }")?.write(&mut results, QueryResultsFormat::Json)?;
|
|
|
|
/// store.query("SELECT ?s WHERE { ?s ?p ?o }")?.write(&mut results, QueryResultsFormat::Json)?;
|
|
|
@ -76,14 +76,14 @@ impl QueryResults { |
|
|
|
/// This method fails if it is called on the `Solution` or `Boolean` results
|
|
|
|
/// This method fails if it is called on the `Solution` or `Boolean` results
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
/// use oxigraph::MemoryStore;
|
|
|
|
/// use oxigraph::SledStore;
|
|
|
|
/// use oxigraph::io::GraphFormat;
|
|
|
|
/// use oxigraph::io::GraphFormat;
|
|
|
|
/// use oxigraph::model::*;
|
|
|
|
/// use oxigraph::model::*;
|
|
|
|
/// use std::io::Cursor;
|
|
|
|
/// use std::io::Cursor;
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// 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 = MemoryStore::new();
|
|
|
|
/// let store = SledStore::new()?;
|
|
|
|
/// store.load_graph(Cursor::new(graph), GraphFormat::NTriples, &GraphName::DefaultGraph, None)?;
|
|
|
|
/// store.load_graph(Cursor::new(graph), GraphFormat::NTriples, &GraphName::DefaultGraph, None)?;
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// let mut results = Vec::new();
|
|
|
|
/// let mut results = Vec::new();
|
|
|
@ -217,10 +217,10 @@ impl QueryResultsFormat { |
|
|
|
/// An iterator over [`QuerySolution`]s
|
|
|
|
/// An iterator over [`QuerySolution`]s
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
/// use oxigraph::MemoryStore;
|
|
|
|
/// use oxigraph::SledStore;
|
|
|
|
/// use oxigraph::sparql::QueryResults;
|
|
|
|
/// use oxigraph::sparql::QueryResults;
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// let store = MemoryStore::new();
|
|
|
|
/// let store = SledStore::new()?;
|
|
|
|
/// if let QueryResults::Solutions(solutions) = store.query("SELECT ?s WHERE { ?s ?p ?o }")? {
|
|
|
|
/// if let QueryResults::Solutions(solutions) = store.query("SELECT ?s WHERE { ?s ?p ?o }")? {
|
|
|
|
/// for solution in solutions {
|
|
|
|
/// for solution in solutions {
|
|
|
|
/// println!("{:?}", solution?.get("s"));
|
|
|
|
/// println!("{:?}", solution?.get("s"));
|
|
|
@ -244,10 +244,10 @@ impl QuerySolutionIter { |
|
|
|
/// The variables used in the solutions
|
|
|
|
/// The variables used in the solutions
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
/// use oxigraph::MemoryStore;
|
|
|
|
/// use oxigraph::SledStore;
|
|
|
|
/// use oxigraph::sparql::{QueryResults, Variable};
|
|
|
|
/// use oxigraph::sparql::{QueryResults, Variable};
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// let store = MemoryStore::new();
|
|
|
|
/// let store = SledStore::new()?;
|
|
|
|
/// if let QueryResults::Solutions(solutions) = store.query("SELECT ?s ?o WHERE { ?s ?p ?o }")? {
|
|
|
|
/// if let QueryResults::Solutions(solutions) = store.query("SELECT ?s ?o WHERE { ?s ?p ?o }")? {
|
|
|
|
/// assert_eq!(solutions.variables(), &[Variable::new("s")?, Variable::new("o")?]);
|
|
|
|
/// assert_eq!(solutions.variables(), &[Variable::new("s")?, Variable::new("o")?]);
|
|
|
|
/// }
|
|
|
|
/// }
|
|
|
@ -360,10 +360,10 @@ impl VariableSolutionIndex for Variable { |
|
|
|
/// An iterator over the triples that compose a graph solution
|
|
|
|
/// An iterator over the triples that compose a graph solution
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
/// use oxigraph::MemoryStore;
|
|
|
|
/// use oxigraph::SledStore;
|
|
|
|
/// use oxigraph::sparql::QueryResults;
|
|
|
|
/// use oxigraph::sparql::QueryResults;
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// let store = MemoryStore::new();
|
|
|
|
/// let store = SledStore::new()?;
|
|
|
|
/// if let QueryResults::Graph(triples) = store.query("CONSTRUCT WHERE { ?s ?p ?o }")? {
|
|
|
|
/// if let QueryResults::Graph(triples) = store.query("CONSTRUCT WHERE { ?s ?p ?o }")? {
|
|
|
|
/// for triple in triples {
|
|
|
|
/// for triple in triples {
|
|
|
|
/// println!("{}", triple?);
|
|
|
|
/// println!("{}", triple?);
|
|
|
|