diff --git a/src/bin/cozo_http.rs b/src/bin/cozo_http.rs index 626af8c9..25c0e36a 100644 --- a/src/bin/cozo_http.rs +++ b/src/bin/cozo_http.rs @@ -1,10 +1,12 @@ +use std::fmt::{Debug, Display, Formatter}; +use std::path::Path; + use actix_cors::Cors; -use actix_web::{post, web, App, HttpResponse, HttpServer, Responder}; +use actix_web::{App, HttpResponse, HttpServer, post, Responder, web}; use clap::Parser; + use cozo::Db; use cozorocks::DbBuilder; -use std::fmt::{Debug, Display, Formatter}; -use std::path::Path; type Result = std::result::Result; @@ -33,7 +35,7 @@ impl From for RespError { } #[derive(Parser, Debug)] -#[clap(version, about, long_about=None)] +#[clap(version, about, long_about = None)] struct Args { /// Path to the directory to store the database #[clap(value_parser)] @@ -114,7 +116,7 @@ async fn main() -> std::io::Result<()> { .service(transact) .service(transact_attr) }) - .bind(addr)? - .run() - .await + .bind(addr)? + .run() + .await } diff --git a/src/data/attr.rs b/src/data/attr.rs index 89950090..d9db1c7e 100644 --- a/src/data/attr.rs +++ b/src/data/attr.rs @@ -1,16 +1,18 @@ -use crate::data::encode::EncodedVec; -use crate::data::id::{AttrId, EntityId, TxId}; -use crate::data::keyword::Keyword; -use crate::data::triple::StoreOp; -use crate::data::tx_triple::TempIdCtx; -use crate::data::value::Value; +use std::fmt::{Display, Formatter}; + use anyhow::Result; use rmp_serde::Serializer; use serde::Serialize; use serde_derive::{Deserialize, Serialize}; use serde_json::json; use smallvec::SmallVec; -use std::fmt::{Display, Formatter}; + +use crate::data::encode::EncodedVec; +use crate::data::id::{AttrId, EntityId, TxId}; +use crate::data::keyword::Keyword; +use crate::data::triple::StoreOp; +use crate::data::value::Value; +use crate::preprocess::triple::TempIdCtx; #[derive(Debug, thiserror::Error)] pub enum AttributeError { @@ -117,7 +119,7 @@ impl TryFrom<&'_ str> for AttributeTyping { return Err(AttributeError::Conversion( s.to_string(), "AttributeTyping".to_string(), - )) + )); } }) } @@ -246,7 +248,7 @@ impl TryFrom<&'_ str> for AttributeIndex { return Err(AttributeError::Conversion( s.to_string(), "AttributeIndex".to_string(), - )) + )); } }) } @@ -307,7 +309,7 @@ impl Attribute { ) -> Result> { if self.val_type.is_ref_type() { if let Value::String(s) = value { - return Ok(Value::EnId(ctx.str2tempid(&s, false))) + return Ok(Value::EnId(ctx.str2tempid(&s, false))); } } self.val_type.coerce_value(value) diff --git a/src/data/compare.rs b/src/data/compare.rs index d9f69637..07065e59 100644 --- a/src/data/compare.rs +++ b/src/data/compare.rs @@ -1,8 +1,9 @@ +use std::cmp::Ordering; + use crate::data::encode::{ decode_ae_key, decode_attr_key_by_id, decode_ea_key, decode_sentinel_attr_val, decode_vae_key, decode_value_from_key, StorageTag, }; -use std::cmp::Ordering; pub(crate) fn rusty_cmp(a: &[u8], b: &[u8]) -> i8 { match compare_key(a, b) { diff --git a/src/data/encode.rs b/src/data/encode.rs index 15bed223..0cd6499c 100644 --- a/src/data/encode.rs +++ b/src/data/encode.rs @@ -1,15 +1,17 @@ +use std::fmt::{Debug, Formatter}; +use std::ops::{Deref, DerefMut}; + +use anyhow::Result; +use rmp_serde::Serializer; +use serde::Serialize; +use smallvec::SmallVec; + use crate::data::attr::Attribute; use crate::data::id::{AttrId, EntityId, TxId, Validity}; use crate::data::keyword::Keyword; use crate::data::triple::StoreOp; use crate::data::value::Value; use crate::runtime::transact::TxLog; -use anyhow::Result; -use rmp_serde::Serializer; -use serde::Serialize; -use smallvec::SmallVec; -use std::fmt::{Debug, Formatter}; -use std::ops::{Deref, DerefMut}; #[repr(u8)] #[derive(Ord, PartialOrd, Eq, PartialEq, Debug)] diff --git a/src/data/id.rs b/src/data/id.rs index d7650563..84d2349b 100644 --- a/src/data/id.rs +++ b/src/data/id.rs @@ -1,9 +1,11 @@ -use crate::data::triple::StoreOp; -use chrono::{DateTime, TimeZone, Utc}; -use serde_derive::{Deserialize, Serialize}; use std::fmt::{Debug, Formatter}; use std::time::{SystemTime, UNIX_EPOCH}; +use chrono::{DateTime, TimeZone, Utc}; +use serde_derive::{Deserialize, Serialize}; + +use crate::data::triple::StoreOp; + #[derive(Clone, Copy, PartialEq, Eq, Ord, PartialOrd, Deserialize, Serialize, Hash)] pub struct Validity(pub i64); @@ -70,7 +72,7 @@ impl Debug for Validity { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { if *self == Validity::MIN { write!(f, "MIN") - } else if *self == Validity::NO_HISTORY{ + } else if *self == Validity::NO_HISTORY { write!(f, "NO_HISTORY") } else if *self == Validity::MAX { write!(f, "MAX") diff --git a/src/data/json.rs b/src/data/json.rs index f5ef1e2f..55e42aea 100644 --- a/src/data/json.rs +++ b/src/data/json.rs @@ -1,9 +1,10 @@ +use serde_json::json; +pub(crate) use serde_json::Value as JsonValue; + use crate::data::attr::{Attribute, AttributeCardinality, AttributeIndex, AttributeTyping}; use crate::data::id::{AttrId, EntityId, TxId}; use crate::data::keyword::{Keyword, KeywordError}; use crate::data::value::Value; -use serde_json::json; -pub(crate) use serde_json::Value as JsonValue; #[derive(Debug, thiserror::Error)] pub enum JsonError { @@ -35,6 +36,7 @@ impl<'a> From<&'a JsonValue> for Value<'a> { } } } + impl From> for JsonValue { fn from(v: Value<'_>) -> Self { match v { diff --git a/src/data/keyword.rs b/src/data/keyword.rs index 3c8dbff8..a6563551 100644 --- a/src/data/keyword.rs +++ b/src/data/keyword.rs @@ -1,8 +1,9 @@ -use serde_derive::{Deserialize, Serialize}; -use smartstring::{LazyCompact, SmartString}; use std::fmt::{Debug, Display, Formatter}; use std::str::Utf8Error; +use serde_derive::{Deserialize, Serialize}; +use smartstring::{LazyCompact, SmartString}; + #[derive(Debug, thiserror::Error)] pub enum KeywordError { #[error("cannot convert to keyword: {0}")] diff --git a/src/data/mod.rs b/src/data/mod.rs index 357be16c..160aa3f5 100644 --- a/src/data/mod.rs +++ b/src/data/mod.rs @@ -6,6 +6,4 @@ pub(crate) mod json; pub(crate) mod keyword; pub(crate) mod triple; pub(crate) mod value; -pub(crate) mod tx_attr; -pub(crate) mod tx_triple; diff --git a/src/data/triple.rs b/src/data/triple.rs index 004f08ca..0636a32a 100644 --- a/src/data/triple.rs +++ b/src/data/triple.rs @@ -1,6 +1,7 @@ -use serde_derive::{Deserialize, Serialize}; use std::fmt::{Display, Formatter}; +use serde_derive::{Deserialize, Serialize}; + #[derive(Debug, thiserror::Error)] pub enum StoreOpError { #[error("unexpected value for StoreOp: {0}")] diff --git a/src/data/value.rs b/src/data/value.rs index 11fb6ade..015f8438 100644 --- a/src/data/value.rs +++ b/src/data/value.rs @@ -1,19 +1,22 @@ -use crate::data::encode::{decode_value, EncodedVec}; -use crate::data::id::{EntityId, TxId}; -use crate::data::keyword::Keyword; -use crate::data::triple::StoreOp; +use std::borrow::Cow; +use std::cmp::Reverse; +use std::fmt::Debug; + use anyhow::Result; -use cozorocks::PinSlice; use ordered_float::OrderedFloat; use rmp_serde::Serializer; use serde::Serialize; use serde_derive::{Deserialize, Serialize}; use smallvec::SmallVec; -use std::borrow::Cow; -use std::cmp::Reverse; -use std::fmt::Debug; use uuid::Uuid; +use cozorocks::PinSlice; + +use crate::data::encode::{decode_value, EncodedVec}; +use crate::data::id::{EntityId, TxId}; +use crate::data::keyword::Keyword; +use crate::data::triple::StoreOp; + #[derive(Debug, thiserror::Error)] pub enum ValueError { #[error("type mismatch: expected {0}, got {1}")] @@ -119,11 +122,12 @@ impl PinSliceValue { #[cfg(test)] mod tests { - use crate::data::keyword::Keyword; - use crate::data::value::Value; use std::collections::{BTreeMap, HashMap}; use std::mem::size_of; + use crate::data::keyword::Keyword; + use crate::data::value::Value; + #[test] fn show_size() { dbg!(size_of::()); diff --git a/src/lib.rs b/src/lib.rs index 94b7b975..7eb0c22c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,10 @@ #[cfg(not(target_env = "msvc"))] use tikv_jemallocator::Jemalloc; +pub use data::encode::EncodedVec; +pub use preprocess::attr::AttrTxItem; +pub use runtime::db::Db; + #[cfg(not(target_env = "msvc"))] #[global_allocator] static GLOBAL: Jemalloc = Jemalloc; @@ -9,7 +13,5 @@ pub(crate) mod data; pub(crate) mod runtime; pub(crate) mod transact; pub(crate) mod utils; +pub(crate) mod preprocess; -pub use data::encode::EncodedVec; -pub use data::tx_attr::AttrTxItem; -pub use runtime::db::Db; diff --git a/src/data/tx_attr.rs b/src/preprocess/attr.rs similarity index 96% rename from src/data/tx_attr.rs rename to src/preprocess/attr.rs index 5ae5ce35..6ddf6ac2 100644 --- a/src/data/tx_attr.rs +++ b/src/preprocess/attr.rs @@ -1,8 +1,9 @@ -use crate::data::attr::Attribute; -use crate::data::triple::StoreOp; use anyhow::Result; use itertools::Itertools; +use crate::data::attr::Attribute; +use crate::data::triple::StoreOp; + #[derive(Debug)] pub struct AttrTxItem { pub(crate) op: StoreOp, @@ -29,7 +30,7 @@ impl AttrTxItem { req.clone(), "'attrs' cannot be empty".to_string(), ) - .into()); + .into()); } let res = items.iter().map(AttrTxItem::try_from).try_collect()?; Ok((res, comment)) @@ -54,7 +55,7 @@ impl TryFrom<&'_ serde_json::Value> for AttrTxItem { value.clone(), "object must have exactly one field".to_string(), ) - .into()); + .into()); } let (k, v) = map.into_iter().next().unwrap(); let op = match k as &str { @@ -63,7 +64,7 @@ impl TryFrom<&'_ serde_json::Value> for AttrTxItem { _ => { return Err( AttrTxItemError::Decoding(value.clone(), format!("unknown op {}", k)).into(), - ) + ); } }; diff --git a/src/preprocess/mod.rs b/src/preprocess/mod.rs new file mode 100644 index 00000000..e2ad1d62 --- /dev/null +++ b/src/preprocess/mod.rs @@ -0,0 +1,2 @@ +pub(crate) mod attr; +pub(crate) mod triple; diff --git a/src/data/tx_triple.rs b/src/preprocess/triple.rs similarity index 98% rename from src/data/tx_triple.rs rename to src/preprocess/triple.rs index 2e747d04..6a72fcb6 100644 --- a/src/data/tx_triple.rs +++ b/src/preprocess/triple.rs @@ -1,13 +1,15 @@ +use std::collections::btree_map::Entry; +use std::collections::BTreeMap; +use std::fmt::{Display, Formatter}; + +use anyhow::Result; +use serde_json::Map; + use crate::data::attr::{Attribute, AttributeIndex, AttributeTyping}; use crate::data::id::{AttrId, EntityId, Validity}; use crate::data::keyword::Keyword; use crate::data::value::Value; use crate::runtime::transact::SessionTx; -use anyhow::Result; -use serde_json::Map; -use std::collections::btree_map::Entry; -use std::collections::BTreeMap; -use std::fmt::{Display, Formatter}; #[derive(Debug)] pub(crate) struct Triple<'a> { @@ -176,7 +178,7 @@ impl SessionTx { serde_json::Value::Object(item.clone()), "expect any of the keys 'put', 'retract', 'erase', 'ensure'".to_string(), ) - .into()); + .into()); } }; let since = match item.get("since") { @@ -226,7 +228,7 @@ impl SessionTx { action, "using temp id instead of perm id".to_string(), ) - .into()); + .into()); } let v = if let serde_json::Value::Object(inner) = value { @@ -261,13 +263,13 @@ impl SessionTx { action, "component shorthand cannot be used".to_string(), ) - .into()); + .into()); } let (eid, has_unique_attr) = self.parse_tx_request_obj(comp, true, action, since, temp_id_ctx, collected)?; if !has_unique_attr && parent_attr.val_type != AttributeTyping::Component { return Err(TxError::InvalidAction(action, - "component shorthand must contain at least one unique/identity field for non-component refs".to_string()).into()); + "component shorthand must contain at least one unique/identity field for non-component refs".to_string()).into()); } Ok(Value::EnId(eid)) } @@ -286,7 +288,7 @@ impl SessionTx { action, "singlet only allowed for 'retract'".to_string(), ) - .into()); + .into()); } let eid = eid.as_u64().ok_or_else(|| { TxError::Decoding(eid.clone(), "cannot parse as entity id".to_string()) @@ -314,7 +316,7 @@ impl SessionTx { action, "doublet only allowed for 'retract'".to_string(), ) - .into()); + .into()); } let kw: Keyword = attr.try_into()?; let attr = self.attr_by_kw(&kw)?.ok_or(TxError::AttrNotFound(kw))?; @@ -396,7 +398,7 @@ impl SessionTx { id.0, "conflicting id for identity value".into(), ) - .into()); + .into()); } id } else if eid.is_string() { @@ -404,7 +406,7 @@ impl SessionTx { existing_id.0, "specifying temp_id string together with unique constraint".into(), ) - .into()); + .into()); } else { existing_id } @@ -476,7 +478,7 @@ impl SessionTx { existing_eid.0, "conflicting entity id given".to_string(), ) - .into()); + .into()); } } eid = Some(existing_eid) @@ -499,7 +501,7 @@ impl SessionTx { given_id.0, "temp id given where perm id is required".to_string(), ) - .into()); + .into()); } if let Some(prev_id) = eid { if prev_id != given_id { @@ -507,7 +509,7 @@ impl SessionTx { given_id.0, "conflicting entity id given".to_string(), ) - .into()); + .into()); } } eid = Some(given_id); @@ -518,7 +520,7 @@ impl SessionTx { eid_inner.0, "conflicting entity id given".to_string(), ) - .into()); + .into()); } let temp_id_str = temp_id.as_str().ok_or_else(|| { TxError::Decoding( @@ -541,7 +543,7 @@ impl SessionTx { action, "upsert requires identity attribute present".to_string(), ) - .into()); + .into()); } for (attr, v) in pairs { self.parse_tx_request_inner(eid, &attr, v, action, since, temp_id_ctx, collected)?; @@ -557,7 +559,7 @@ impl SessionTx { action, "cannot use non-unique fields to specify entity".to_string(), ) - .into()); + .into()); } } } @@ -572,7 +574,7 @@ fn assert_absence_of_keys(m: &Map, keys: &[&str]) -> serde_json::Value::Object(m.clone()), format!("object must not contain key {}", k), ) - .into()); + .into()); } } Ok(()) diff --git a/src/runtime/db.rs b/src/runtime/db.rs index 61a4e6ad..9ed5e851 100644 --- a/src/runtime/db.rs +++ b/src/runtime/db.rs @@ -1,4 +1,16 @@ -use crate::data::compare::{rusty_cmp, DB_KEY_PREFIX_LEN}; +use std::collections::BTreeMap; +use std::fmt::{Debug, Formatter}; +use std::sync::Arc; +use std::sync::atomic::{AtomicU64, AtomicUsize, Ordering}; + +use anyhow::Result; +use itertools::Itertools; +use serde_json::json; + +use cozorocks::{DbBuilder, DbIter, RocksDb}; + +use crate::AttrTxItem; +use crate::data::compare::{DB_KEY_PREFIX_LEN, rusty_cmp}; use crate::data::encode::{ decode_ea_key, decode_value_from_key, decode_value_from_val, encode_eav_key, StorageTag, }; @@ -6,15 +18,6 @@ use crate::data::id::{AttrId, EntityId, TxId, Validity}; use crate::data::triple::StoreOp; use crate::data::value::Value; use crate::runtime::transact::SessionTx; -use crate::AttrTxItem; -use anyhow::Result; -use cozorocks::{DbBuilder, DbIter, RocksDb}; -use itertools::Itertools; -use serde_json::json; -use std::collections::BTreeMap; -use std::fmt::{Debug, Formatter}; -use std::sync::atomic::{AtomicU64, AtomicUsize, Ordering}; -use std::sync::Arc; pub struct Db { db: RocksDb, diff --git a/src/runtime/transact.rs b/src/runtime/transact.rs index 5dbb4ca3..904c93fd 100644 --- a/src/runtime/transact.rs +++ b/src/runtime/transact.rs @@ -1,19 +1,22 @@ +use std::collections::{BTreeMap, BTreeSet}; +use std::sync::Arc; +use std::sync::atomic::{AtomicU64, Ordering}; + +use anyhow::Result; +use rmp_serde::Serializer; +use serde::Serialize; +use serde_derive::{Deserialize, Serialize}; +use smallvec::SmallVec; + +use cozorocks::{DbIter, Tx}; + use crate::data::attr::Attribute; use crate::data::encode::{ - encode_tx, encode_sentinel_attr_by_id, encode_sentinel_entity_attr, EncodedVec, + encode_sentinel_attr_by_id, encode_sentinel_entity_attr, encode_tx, EncodedVec, }; use crate::data::id::{AttrId, EntityId, TxId, Validity}; use crate::data::keyword::Keyword; use crate::data::value::StaticValue; -use anyhow::Result; -use cozorocks::{DbIter, Tx}; -use rmp_serde::Serializer; -use serde::Serialize; -use serde_derive::{Deserialize, Serialize}; -use smallvec::SmallVec; -use std::collections::{BTreeMap, BTreeSet}; -use std::sync::atomic::{AtomicU64, Ordering}; -use std::sync::Arc; pub struct SessionTx { pub(crate) tx: Tx, @@ -25,7 +28,7 @@ pub struct SessionTx { pub(crate) attr_by_kw_cache: BTreeMap>, pub(crate) temp_entity_to_perm: BTreeMap, pub(crate) eid_by_attr_val_cache: - BTreeMap>>, + BTreeMap>>, // "touched" requires the id to exist prior to the transaction, and something related to it has changed pub(crate) touched_eids: BTreeSet, } diff --git a/src/transact/attr.rs b/src/transact/attr.rs index 7e52ac8d..64bb851a 100644 --- a/src/transact/attr.rs +++ b/src/transact/attr.rs @@ -1,3 +1,10 @@ +use std::sync::atomic::Ordering; + +use anyhow::Result; + +use cozorocks::{DbIter, IterBuilder}; + +use crate::AttrTxItem; use crate::data::attr::Attribute; use crate::data::encode::{ encode_attr_by_id, encode_sentinel_attr_by_id, encode_sentinel_attr_by_kw, VEC_SIZE_8, @@ -7,10 +14,6 @@ use crate::data::keyword::Keyword; use crate::data::triple::StoreOp; use crate::runtime::transact::{SessionTx, TransactError}; use crate::utils::swap_option_result; -use crate::AttrTxItem; -use anyhow::Result; -use cozorocks::{DbIter, IterBuilder}; -use std::sync::atomic::Ordering; impl SessionTx { pub fn tx_attrs(&mut self, payloads: Vec) -> Result> { @@ -94,7 +97,7 @@ impl SessionTx { }) } - pub(crate) fn all_attrs(&mut self) -> impl Iterator> { + pub(crate) fn all_attrs(&mut self) -> impl Iterator> { AttrIter::new(self.tx.iterator()) } @@ -105,7 +108,7 @@ impl SessionTx { attr.id, "cardinality cannot be 'many' for unique or identity attributes".to_string(), ) - .into()); + .into()); } if self.attr_by_kw(&attr.keyword)?.is_some() { @@ -116,7 +119,7 @@ impl SessionTx { attr.keyword ), ) - .into()); + .into()); } attr.id = AttrId(self.last_attr_id.fetch_add(1, Ordering::AcqRel) + 1); self.put_attr(&attr, StoreOp::Assert) @@ -136,7 +139,7 @@ impl SessionTx { attr.id, format!("alias conflict: {}", attr.keyword), ) - .into()); + .into()); } if existing.val_type != attr.val_type || existing.cardinality != attr.cardinality @@ -171,7 +174,7 @@ impl SessionTx { aid, "attempting to retract non-existing attribute".to_string(), ) - .into()), + .into()), Some(attr) => { self.put_attr(&attr, StoreOp::Retract)?; Ok(attr.id) diff --git a/src/transact/triple.rs b/src/transact/triple.rs index bf40a891..4c9ceea9 100644 --- a/src/transact/triple.rs +++ b/src/transact/triple.rs @@ -1,3 +1,9 @@ +use std::sync::atomic::Ordering; + +use anyhow::Result; + +use cozorocks::{DbIter, IterBuilder}; + use crate::data::attr::{Attribute, AttributeTyping}; use crate::data::compare::compare_key; use crate::data::encode::{ @@ -9,13 +15,10 @@ use crate::data::encode::{ use crate::data::id::{AttrId, EntityId, Validity}; use crate::data::keyword::Keyword; use crate::data::triple::StoreOp; -use crate::data::tx_triple::{Quintuple, TxAction}; -use crate::data::value::{StaticValue, Value, INLINE_VAL_SIZE_LIMIT}; +use crate::data::value::{INLINE_VAL_SIZE_LIMIT, StaticValue, Value}; +use crate::preprocess::triple::{Quintuple, TxAction}; use crate::runtime::transact::{SessionTx, TransactError}; use crate::utils::swap_option_result; -use anyhow::Result; -use cozorocks::{DbIter, IterBuilder}; -use std::sync::atomic::Ordering; #[derive(Debug, thiserror::Error)] enum TripleError { @@ -132,7 +135,7 @@ impl SessionTx { format!("{:?}", v), format!("{:?}", stored_v), ) - .into()); + .into()); } Ok(()) } @@ -211,8 +214,8 @@ impl SessionTx { } else { Validity::NO_HISTORY }; - // back scan if attr.with_history { + // back scan in time for item in self.triple_av_before_scan(attr.id, v, vld_in_key) { let (_, _, found_eid) = item?; if found_eid != eid { @@ -220,19 +223,28 @@ impl SessionTx { attr.keyword.clone(), format!("{:?}", v), ) - .into()); + .into()); } } - } - - for item in self.triple_av_after_scan(attr.id, v, vld_in_key) { - let (_, _, found_eid) = item?; + // fwd scan in time + for item in self.triple_av_after_scan(attr.id, v, vld_in_key) { + let (_, _, found_eid) = item?; + if found_eid != eid { + return Err(TripleError::UniqueConstraintViolated( + attr.keyword.clone(), + format!("{:?}", v), + ) + .into()); + } + } + } else if let Some(v_slice) = self.tx.get(&ave_encoded, false)? { + let (_, found_eid, _) = decode_ae_key(&v_slice)?; if found_eid != eid { return Err(TripleError::UniqueConstraintViolated( attr.keyword.clone(), format!("{:?}", v), ) - .into()); + .into()); } } } @@ -426,7 +438,7 @@ impl SessionTx { &mut self, eid: EntityId, aid: AttrId, - ) -> impl Iterator> { + ) -> impl Iterator> { let lower = encode_eav_key(eid, aid, &Value::Null, Validity::MAX); let upper = encode_eav_key(eid, aid, &Value::Bottom, Validity::MIN); TripleEntityAttrIter::new(self.tx.iterator(), lower, upper) @@ -436,7 +448,7 @@ impl SessionTx { eid: EntityId, aid: AttrId, before: Validity, - ) -> impl Iterator> { + ) -> impl Iterator> { let lower = encode_eav_key(eid, aid, &Value::Null, Validity::MAX); let upper = encode_eav_key(eid, aid, &Value::Bottom, Validity::MIN); TripleEntityAttrBeforeIter::new(self.tx.iterator(), lower, upper, before) @@ -445,7 +457,7 @@ impl SessionTx { &mut self, aid: AttrId, eid: EntityId, - ) -> impl Iterator> { + ) -> impl Iterator> { let lower = encode_aev_key(aid, eid, &Value::Null, Validity::MAX); let upper = encode_aev_key(aid, eid, &Value::Bottom, Validity::MIN); TripleAttrEntityIter::new(self.tx.iterator(), lower, upper) @@ -455,7 +467,7 @@ impl SessionTx { aid: AttrId, eid: EntityId, before: Validity, - ) -> impl Iterator> { + ) -> impl Iterator> { let lower = encode_aev_key(aid, eid, &Value::Null, Validity::MAX); let upper = encode_aev_key(aid, eid, &Value::Bottom, Validity::MIN); TripleAttrEntityBeforeIter::new(self.tx.iterator(), lower, upper, before) @@ -464,7 +476,7 @@ impl SessionTx { &mut self, aid: AttrId, v: &Value, - ) -> impl Iterator> { + ) -> impl Iterator> { let lower = encode_ave_key(aid, v, EntityId::MIN_PERM, Validity::MAX); let upper = encode_ave_key(aid, v, EntityId::MAX_PERM, Validity::MIN); TripleAttrValueIter::new(self.tx.iterator(), lower, upper) @@ -474,7 +486,7 @@ impl SessionTx { aid: AttrId, v: &Value, before: Validity, - ) -> impl Iterator> { + ) -> impl Iterator> { let lower = encode_ave_key(aid, v, EntityId::MIN_PERM, Validity::MAX); let upper = encode_ave_key(aid, v, EntityId::MAX_PERM, Validity::MIN); TripleAttrValueBeforeIter::new(self.tx.iterator(), lower, upper, before) @@ -484,7 +496,7 @@ impl SessionTx { aid: AttrId, v: &Value, after: Validity, - ) -> impl Iterator> { + ) -> impl Iterator> { let lower = encode_ave_key(aid, v, EntityId::MIN_PERM, Validity::MAX); let upper = encode_ave_key(aid, v, EntityId::MAX_PERM, Validity::MIN); TripleAttrValueAfterIter::new(self.tx.iterator(), lower, upper, after) @@ -493,7 +505,7 @@ impl SessionTx { &mut self, v_eid: EntityId, aid: AttrId, - ) -> impl Iterator> { + ) -> impl Iterator> { let lower = encode_vae_key(v_eid, aid, EntityId::MIN_PERM, Validity::MAX); let upper = encode_vae_key(v_eid, aid, EntityId::MAX_PERM, Validity::MIN); TripleValueRefAttrIter::new(self.tx.iterator(), lower, upper) @@ -503,7 +515,7 @@ impl SessionTx { v_eid: EntityId, aid: AttrId, before: Validity, - ) -> impl Iterator> { + ) -> impl Iterator> { let lower = encode_vae_key(v_eid, aid, EntityId::MIN_PERM, Validity::MAX); let upper = encode_vae_key(v_eid, aid, EntityId::MAX_PERM, Validity::MIN); TripleValueRefAttrBeforeIter::new(self.tx.iterator(), lower, upper, before) @@ -511,7 +523,7 @@ impl SessionTx { pub(crate) fn triple_e_scan( &mut self, eid: EntityId, - ) -> impl Iterator> { + ) -> impl Iterator> { let lower = encode_eav_key(eid, AttrId::MIN_PERM, &Value::Null, Validity::MAX); let upper = encode_eav_key(eid, AttrId::MAX_PERM, &Value::Bottom, Validity::MIN); TripleEntityAttrIter::new(self.tx.iterator(), lower, upper) @@ -520,7 +532,7 @@ impl SessionTx { &mut self, eid: EntityId, before: Validity, - ) -> impl Iterator> { + ) -> impl Iterator> { let lower = encode_eav_key(eid, AttrId::MIN_PERM, &Value::Null, Validity::MAX); let upper = encode_eav_key(eid, AttrId::MAX_PERM, &Value::Bottom, Validity::MIN); TripleEntityAttrBeforeIter::new(self.tx.iterator(), lower, upper, before) @@ -528,7 +540,7 @@ impl SessionTx { pub(crate) fn triple_a_scan( &mut self, aid: AttrId, - ) -> impl Iterator> { + ) -> impl Iterator> { let lower = encode_aev_key(aid, EntityId::MIN_PERM, &Value::Null, Validity::MAX); let upper = encode_aev_key(aid, EntityId::MAX_PERM, &Value::Bottom, Validity::MIN); TripleAttrEntityIter::new(self.tx.iterator(), lower, upper) @@ -537,14 +549,14 @@ impl SessionTx { &mut self, aid: AttrId, before: Validity, - ) -> impl Iterator> { + ) -> impl Iterator> { let lower = encode_aev_key(aid, EntityId::MIN_PERM, &Value::Null, Validity::MAX); let upper = encode_aev_key(aid, EntityId::MAX_PERM, &Value::Bottom, Validity::MIN); TripleAttrEntityBeforeIter::new(self.tx.iterator(), lower, upper, before) } pub(crate) fn triple_a_scan_all( &mut self, - ) -> impl Iterator> { + ) -> impl Iterator> { let lower = encode_aev_key( AttrId::MIN_PERM, EntityId::MIN_PERM, @@ -562,7 +574,7 @@ impl SessionTx { pub(crate) fn triple_a_before_scan_all( &mut self, before: Validity, - ) -> impl Iterator> { + ) -> impl Iterator> { let lower = encode_aev_key( AttrId::MIN_PERM, EntityId::MIN_PERM, @@ -580,7 +592,7 @@ impl SessionTx { pub(crate) fn triple_vref_scan( &mut self, v_eid: EntityId, - ) -> impl Iterator> { + ) -> impl Iterator> { let lower = encode_vae_key(v_eid, AttrId::MIN_PERM, EntityId::MIN_PERM, Validity::MAX); let upper = encode_vae_key(v_eid, AttrId::MAX_PERM, EntityId::MAX_PERM, Validity::MIN); TripleValueRefAttrIter::new(self.tx.iterator(), lower, upper) @@ -589,7 +601,7 @@ impl SessionTx { &mut self, v_eid: EntityId, before: Validity, - ) -> impl Iterator> { + ) -> impl Iterator> { let lower = encode_vae_key(v_eid, AttrId::MIN_PERM, EntityId::MIN_PERM, Validity::MAX); let upper = encode_vae_key(v_eid, AttrId::MAX_PERM, EntityId::MAX_PERM, Validity::MIN); TripleValueRefAttrBeforeIter::new(self.tx.iterator(), lower, upper, before)