Renames WithStoreError to StrEncodingAware

pull/46/head
Tpt 4 years ago
parent b90fbdc7fe
commit 60a5ae8e64
  1. 4
      lib/src/sparql/dataset.rs
  2. 12
      lib/src/sparql/mod.rs
  3. 2
      lib/src/store/binary_encoder.rs
  4. 6
      lib/src/store/memory.rs
  5. 2
      lib/src/store/mod.rs
  6. 12
      lib/src/store/numeric_encoder.rs
  7. 8
      lib/src/store/rocksdb.rs
  8. 6
      lib/src/store/sled.rs

@ -1,7 +1,7 @@
use crate::sparql::algebra::DatasetSpec;
use crate::sparql::EvaluationError;
use crate::store::numeric_encoder::{
EncodedQuad, EncodedTerm, ReadEncoder, StrContainer, StrId, StrLookup, WithStoreError,
EncodedQuad, EncodedTerm, ReadEncoder, StrContainer, StrEncodingAware, StrId, StrLookup,
};
use crate::store::ReadableEncodedStore;
use lasso::{Rodeo, Spur};
@ -48,7 +48,7 @@ impl<S: ReadableEncodedStore> DatasetView<S> {
}
}
impl<S: ReadableEncodedStore> WithStoreError for DatasetView<S> {
impl<S: ReadableEncodedStore> StrEncodingAware for DatasetView<S> {
type Error = EvaluationError;
type StrId = DatasetStrId<S::StrId>;
}

@ -33,7 +33,7 @@ pub use crate::sparql::error::EvaluationError;
pub use crate::sparql::model::Variable;
pub use crate::sparql::parser::ParseError;
pub use crate::sparql::parser::Query;
use crate::store::numeric_encoder::WithStoreError;
use crate::store::numeric_encoder::StrEncodingAware;
use std::error::Error;
/// A prepared [SPARQL query](https://www.w3.org/TR/sparql11-query/)
@ -50,21 +50,21 @@ pub(crate) struct SimplePreparedQuery<S: ReadableEncodedStore + 'static>(
#[derive(Clone)]
enum SimplePreparedQueryAction<S: ReadableEncodedStore + 'static> {
Select {
plan: Rc<PlanNode<<DatasetView<S> as WithStoreError>::StrId>>,
plan: Rc<PlanNode<<DatasetView<S> as StrEncodingAware>::StrId>>,
variables: Rc<Vec<Variable>>,
evaluator: SimpleEvaluator<DatasetView<S>>,
},
Ask {
plan: Rc<PlanNode<<DatasetView<S> as WithStoreError>::StrId>>,
plan: Rc<PlanNode<<DatasetView<S> as StrEncodingAware>::StrId>>,
evaluator: SimpleEvaluator<DatasetView<S>>,
},
Construct {
plan: Rc<PlanNode<<DatasetView<S> as WithStoreError>::StrId>>,
construct: Rc<Vec<TripleTemplate<<DatasetView<S> as WithStoreError>::StrId>>>,
plan: Rc<PlanNode<<DatasetView<S> as StrEncodingAware>::StrId>>,
construct: Rc<Vec<TripleTemplate<<DatasetView<S> as StrEncodingAware>::StrId>>>,
evaluator: SimpleEvaluator<DatasetView<S>>,
},
Describe {
plan: Rc<PlanNode<<DatasetView<S> as WithStoreError>::StrId>>,
plan: Rc<PlanNode<<DatasetView<S> as StrEncodingAware>::StrId>>,
evaluator: SimpleEvaluator<DatasetView<S>>,
},
}

@ -673,7 +673,7 @@ mod test {
}
}
impl WithStoreError for MemoryStrStore {
impl StrEncodingAware for MemoryStrStore {
type Error = Infallible;
type StrId = StrHash;
}

@ -5,7 +5,7 @@ use crate::io::{DatasetFormat, DatasetParser, GraphFormat, GraphParser};
use crate::model::*;
use crate::sparql::{EvaluationError, Query, QueryOptions, QueryResult, SimplePreparedQuery};
use crate::store::numeric_encoder::{
Decoder, ReadEncoder, StrContainer, StrId, StrLookup, WithStoreError, WriteEncoder,
Decoder, ReadEncoder, StrContainer, StrEncodingAware, StrId, StrLookup, WriteEncoder,
};
use crate::store::{
dump_dataset, dump_graph, get_encoded_quad_pattern, load_dataset, load_graph,
@ -803,7 +803,7 @@ impl MemoryStore {
}
}
impl WithStoreError for MemoryStore {
impl StrEncodingAware for MemoryStore {
type Error = Infallible;
type StrId = LargeSpur;
}
@ -853,7 +853,7 @@ impl<'a> WritableEncodedStore for &'a MemoryStore {
}
}
impl WithStoreError for MemoryStoreIndexes {
impl StrEncodingAware for MemoryStoreIndexes {
type Error = Infallible;
type StrId = LargeSpur;
}

@ -46,7 +46,7 @@ pub(crate) trait ReadableEncodedStore: StrLookup {
) -> Self::QuadsIter;
}
pub(crate) trait WritableEncodedStore: WithStoreError {
pub(crate) trait WritableEncodedStore: StrEncodingAware {
fn insert_encoded(&mut self, quad: &EncodedQuad<Self::StrId>) -> Result<(), Self::Error>;
fn remove_encoded(&mut self, quad: &EncodedQuad<Self::StrId>) -> Result<(), Self::Error>;

@ -554,29 +554,29 @@ impl<I: StrId> EncodedQuad<I> {
}
}
pub(crate) trait WithStoreError {
pub(crate) trait StrEncodingAware {
//TODO: rename
type Error: Error + Into<EvaluationError> + 'static;
type StrId: StrId + 'static;
}
impl<'a, T: WithStoreError> WithStoreError for &'a T {
impl<'a, T: StrEncodingAware> StrEncodingAware for &'a T {
type Error = T::Error;
type StrId = T::StrId;
}
pub(crate) trait StrLookup: WithStoreError {
pub(crate) trait StrLookup: StrEncodingAware {
fn get_str(&self, id: Self::StrId) -> Result<Option<String>, Self::Error>;
fn get_str_id(&self, value: &str) -> Result<Option<Self::StrId>, Self::Error>;
}
pub(crate) trait StrContainer: WithStoreError {
pub(crate) trait StrContainer: StrEncodingAware {
fn insert_str(&mut self, value: &str) -> Result<Self::StrId, Self::Error>;
}
/// Tries to encode a term based on the existing strings (does not insert anything)
pub(crate) trait ReadEncoder: WithStoreError {
pub(crate) trait ReadEncoder: StrEncodingAware {
fn get_encoded_named_node(
&self,
named_node: NamedNodeRef<'_>,
@ -819,7 +819,7 @@ impl<S: StrLookup> ReadEncoder for S {
}
/// Encodes a term and insert strings if needed
pub(crate) trait WriteEncoder: WithStoreError {
pub(crate) trait WriteEncoder: StrEncodingAware {
fn encode_named_node(
&mut self,
named_node: NamedNodeRef<'_>,

@ -6,7 +6,7 @@ use crate::model::*;
use crate::sparql::{EvaluationError, Query, QueryOptions, QueryResult, SimplePreparedQuery};
use crate::store::binary_encoder::*;
use crate::store::numeric_encoder::{
Decoder, ReadEncoder, StrContainer, StrLookup, WithStoreError, WriteEncoder,
Decoder, ReadEncoder, StrContainer, StrEncodingAware, StrLookup, WriteEncoder,
};
use crate::store::{
dump_dataset, dump_graph, get_encoded_quad_pattern, load_dataset, load_graph,
@ -624,7 +624,7 @@ impl fmt::Display for RocksDbStore {
}
}
impl WithStoreError for RocksDbStore {
impl StrEncodingAware for RocksDbStore {
type Error = io::Error;
type StrId = StrHash;
}
@ -756,7 +756,7 @@ impl AutoBatchWriter<'_> {
}
}
impl WithStoreError for AutoBatchWriter<'_> {
impl StrEncodingAware for AutoBatchWriter<'_> {
type Error = io::Error;
type StrId = StrHash;
}
@ -935,7 +935,7 @@ impl RocksDbTransaction<'_> {
}
}
impl WithStoreError for RocksDbTransaction<'_> {
impl StrEncodingAware for RocksDbTransaction<'_> {
type Error = io::Error;
type StrId = StrHash;
}

@ -6,7 +6,7 @@ use crate::model::*;
use crate::sparql::{EvaluationError, Query, QueryOptions, QueryResult, SimplePreparedQuery};
use crate::store::binary_encoder::*;
use crate::store::numeric_encoder::{
Decoder, ReadEncoder, StrContainer, StrLookup, WithStoreError, WriteEncoder,
Decoder, ReadEncoder, StrContainer, StrEncodingAware, StrLookup, WriteEncoder,
};
use crate::store::{
dump_dataset, dump_graph, get_encoded_quad_pattern, load_dataset, load_graph,
@ -597,7 +597,7 @@ impl fmt::Display for SledStore {
}
}
impl WithStoreError for SledStore {
impl StrEncodingAware for SledStore {
type Error = io::Error;
type StrId = StrHash;
}
@ -876,7 +876,7 @@ impl SledTransaction<'_> {
}
}
impl<'a> WithStoreError for &'a SledTransaction<'a> {
impl<'a> StrEncodingAware for &'a SledTransaction<'a> {
type Error = SledUnabortableTransactionError;
type StrId = StrHash;
}

Loading…
Cancel
Save