Uses SledStore when evaluating testsuites

pull/171/head
Tpt 4 years ago
parent 0aa209b6ea
commit 7668f032f4
  1. 2
      testsuite/Cargo.toml
  2. 4
      testsuite/src/files.rs
  3. 31
      testsuite/src/sparql_evaluator.rs

@ -14,7 +14,7 @@ publish = false
[dependencies] [dependencies]
anyhow = "1" anyhow = "1"
chrono = "0.4" chrono = "0.4"
oxigraph = { version = "0.2", path="../lib" } oxigraph = { version = "0.2", path="../lib", features=["sled"] }
text-diff = "0.4" text-diff = "0.4"
[dev-dependencies] [dev-dependencies]

@ -1,7 +1,7 @@
use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result};
use oxigraph::io::{DatasetFormat, GraphFormat}; use oxigraph::io::{DatasetFormat, GraphFormat};
use oxigraph::model::{Dataset, Graph, GraphNameRef}; use oxigraph::model::{Dataset, Graph, GraphNameRef};
use oxigraph::MemoryStore; use oxigraph::SledStore;
use std::fs::File; use std::fs::File;
use std::io::{BufRead, BufReader, Read}; use std::io::{BufRead, BufReader, Read};
use std::path::PathBuf; use std::path::PathBuf;
@ -41,7 +41,7 @@ pub fn read_file_to_string(url: &str) -> Result<String> {
pub fn load_to_store<'a>( pub fn load_to_store<'a>(
url: &str, url: &str,
store: &MemoryStore, store: &SledStore,
to_graph_name: impl Into<GraphNameRef<'a>>, to_graph_name: impl Into<GraphNameRef<'a>>,
) -> Result<()> { ) -> Result<()> {
if url.ends_with(".nt") { if url.ends_with(".nt") {

@ -7,7 +7,7 @@ use chrono::Utc;
use oxigraph::model::vocab::*; use oxigraph::model::vocab::*;
use oxigraph::model::*; use oxigraph::model::*;
use oxigraph::sparql::*; use oxigraph::sparql::*;
use oxigraph::MemoryStore; use oxigraph::SledStore;
use std::collections::HashMap; use std::collections::HashMap;
use std::str::FromStr; use std::str::FromStr;
use std::sync::Arc; use std::sync::Arc;
@ -70,7 +70,7 @@ fn evaluate_sparql_test(test: &Test) -> Result<()> {
} else if test.kind } else if test.kind
== "http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#QueryEvaluationTest" == "http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#QueryEvaluationTest"
{ {
let store = MemoryStore::new(); let store = SledStore::new()?;
if let Some(data) = &test.data { if let Some(data) = &test.data {
load_to_store(data, &store, GraphNameRef::DefaultGraph)?; load_to_store(data, &store, GraphNameRef::DefaultGraph)?;
} }
@ -190,7 +190,7 @@ fn evaluate_sparql_test(test: &Test) -> Result<()> {
} else if test.kind } else if test.kind
== "http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#UpdateEvaluationTest" == "http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#UpdateEvaluationTest"
{ {
let store = MemoryStore::new(); let store = SledStore::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, &GraphName::DefaultGraph)?;
} }
@ -198,7 +198,7 @@ fn evaluate_sparql_test(test: &Test) -> Result<()> {
load_to_store(value, &store, name)?; load_to_store(value, &store, name)?;
} }
let result_store = MemoryStore::new(); let result_store = SledStore::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, &GraphName::DefaultGraph)?;
} }
@ -223,9 +223,10 @@ fn evaluate_sparql_test(test: &Test) -> Result<()> {
error error
)), )),
Ok(()) => { Ok(()) => {
let mut store_dataset: Dataset = store.iter().collect(); let mut store_dataset: Dataset = store.iter().collect::<Result<_, _>>()?;
store_dataset.canonicalize(); store_dataset.canonicalize();
let mut result_store_dataset: Dataset = result_store.iter().collect(); let mut result_store_dataset: Dataset =
result_store.iter().collect::<Result<_, _>>()?;
result_store_dataset.canonicalize(); result_store_dataset.canonicalize();
if store_dataset == result_store_dataset { if store_dataset == result_store_dataset {
Ok(()) Ok(())
@ -269,7 +270,7 @@ fn load_sparql_query_result(url: &str) -> Result<StaticQueryResults> {
#[derive(Clone)] #[derive(Clone)]
struct StaticServiceHandler { struct StaticServiceHandler {
services: Arc<HashMap<NamedNode, MemoryStore>>, services: Arc<HashMap<NamedNode, SledStore>>,
} }
impl StaticServiceHandler { impl StaticServiceHandler {
@ -280,7 +281,7 @@ impl StaticServiceHandler {
.iter() .iter()
.map(|(name, data)| { .map(|(name, data)| {
let name = NamedNode::new(name)?; let name = NamedNode::new(name)?;
let store = MemoryStore::new(); let store = SledStore::new()?;
load_to_store(&data, &store, &GraphName::DefaultGraph)?; load_to_store(&data, &store, &GraphName::DefaultGraph)?;
Ok((name, store)) Ok((name, store))
}) })
@ -466,13 +467,13 @@ impl StaticQueryResults {
fn from_graph(graph: Graph) -> StaticQueryResults { fn from_graph(graph: Graph) -> StaticQueryResults {
// Hack to normalize literals // Hack to normalize literals
let mut graph: Graph = graph let store = SledStore::new().unwrap();
.iter() for t in graph.iter() {
.map(|t| t.into_owned().in_graph(GraphName::DefaultGraph)) store
.collect::<MemoryStore>() .insert(t.in_graph(GraphNameRef::DefaultGraph))
.into_iter() .unwrap();
.map(Triple::from) }
.collect(); let mut graph: Graph = store.iter().map(|q| Triple::from(q.unwrap())).collect();
if let Some(result_set) = graph.subject_for_predicate_object(rdf::TYPE, rs::RESULT_SET) { if let Some(result_set) = graph.subject_for_predicate_object(rdf::TYPE, rs::RESULT_SET) {
if let Some(bool) = graph.object_for_subject_predicate(result_set, rs::BOOLEAN) { if let Some(bool) = graph.object_for_subject_predicate(result_set, rs::BOOLEAN) {

Loading…
Cancel
Save