From 06056a8468ac0836c677038390d9036e6ea2c29d Mon Sep 17 00:00:00 2001 From: Nick Alexander Date: Tue, 3 Jul 2018 13:18:02 -0700 Subject: [PATCH] Part 6: Lift `TxReport` to `core` crate. The `core` create didn't exist when the `db` was started, but this type is clearly part of the public interface of Mentat. --- core/src/lib.rs | 5 +++++ core/src/tx_report.rs | 38 ++++++++++++++++++++++++++++++++++++++ db/src/db.rs | 2 +- db/src/lib.rs | 1 - db/src/tx.rs | 2 +- db/src/types.rs | 17 ----------------- src/conn.rs | 2 +- src/entity_builder.rs | 7 ++----- src/lib.rs | 2 +- src/store.rs | 2 +- 10 files changed, 50 insertions(+), 28 deletions(-) create mode 100644 core/src/tx_report.rs diff --git a/core/src/lib.rs b/core/src/lib.rs index 4282a0b6..5e406554 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -60,9 +60,14 @@ pub use cache::{ /// Core types defining a Mentat knowledge base. mod types; +mod tx_report; mod value_type_set; mod sql_types; +pub use tx_report::{ + TxReport, +}; + pub use types::{ Binding, Entid, diff --git a/core/src/tx_report.rs b/core/src/tx_report.rs new file mode 100644 index 00000000..1b30278f --- /dev/null +++ b/core/src/tx_report.rs @@ -0,0 +1,38 @@ +// Copyright 2018 Mozilla +// +// Licensed under the Apache License, Version 2.0 (the "License"); you may not use +// this file except in compliance with the License. You may obtain a copy of the +// License at http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software distributed +// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, either express or implied. See the License for the +// specific language governing permissions and limitations under the License. + +#![allow(dead_code)] + +use std::collections::{ + BTreeMap, +}; + +use ::{ + DateTime, + Entid, + Utc, +}; + +/// A transaction report summarizes an applied transaction. +#[derive(Clone, Debug, Eq, Hash, Ord, PartialOrd, PartialEq)] +pub struct TxReport { + /// The transaction ID of the transaction. + pub tx_id: Entid, + + /// The timestamp when the transaction began to be committed. + pub tx_instant: DateTime, + + /// A map from string literal tempid to resolved or allocated entid. + /// + /// Every string literal tempid presented to the transactor either resolves via upsert to an + /// existing entid, or is allocated a new entid. (It is possible for multiple distinct string + /// literal tempids to all unify to a single freshly allocated entid.) + pub tempids: BTreeMap, +} diff --git a/db/src/db.rs b/db/src/db.rs index c8dd0fa5..8ad0cc60 100644 --- a/db/src/db.rs +++ b/db/src/db.rs @@ -1131,6 +1131,7 @@ mod tests { HasSchema, Keyword, KnownEntid, + TxReport, attribute, }; use mentat_core::util::Either::*; @@ -1142,7 +1143,6 @@ mod tests { Term, TermWithTempIds, }; - use types::TxReport; use tx::{ transact_terms, }; diff --git a/db/src/lib.rs b/db/src/lib.rs index c7cf40eb..bd8fe154 100644 --- a/db/src/lib.rs +++ b/db/src/lib.rs @@ -106,7 +106,6 @@ pub use types::{ DB, PartitionMap, TransactableValue, - TxReport, }; pub fn to_namespaced_keyword(s: &str) -> Result { diff --git a/db/src/tx.rs b/db/src/tx.rs index a398b114..4179fa24 100644 --- a/db/src/tx.rs +++ b/db/src/tx.rs @@ -94,6 +94,7 @@ use mentat_core::{ DateTime, KnownEntid, Schema, + TxReport, Utc, attribute, now, @@ -119,7 +120,6 @@ use types::{ Entid, PartitionMap, TransactableValue, - TxReport, TypedValue, ValueType, }; diff --git a/db/src/types.rs b/db/src/types.rs index 70ea4964..138dd66b 100644 --- a/db/src/types.rs +++ b/db/src/types.rs @@ -95,23 +95,6 @@ pub type AVMap<'a> = HashMap<&'a AVPair, Entid>; // represents a set of entids that are correspond to attributes pub type AttributeSet = BTreeSet; -/// A transaction report summarizes an applied transaction. -#[derive(Clone, Debug, Eq, Hash, Ord, PartialOrd, PartialEq)] -pub struct TxReport { - /// The transaction ID of the transaction. - pub tx_id: Entid, - - /// The timestamp when the transaction began to be committed. - pub tx_instant: DateTime, - - /// A map from string literal tempid to resolved or allocated entid. - /// - /// Every string literal tempid presented to the transactor either resolves via upsert to an - /// existing entid, or is allocated a new entid. (It is possible for multiple distinct string - /// literal tempids to all unify to a single freshly allocated entid.) - pub tempids: BTreeMap, -} - /// The transactor is tied to `edn::ValueAndSpan` right now, but in the future we'd like to support /// `TypedValue` directly for programmatic use. `TransactableValue` encapsulates the interface /// value types (i.e., values in the value place) need to support to be transacted. diff --git a/src/conn.rs b/src/conn.rs index 05caf746..eb54dbbf 100644 --- a/src/conn.rs +++ b/src/conn.rs @@ -53,6 +53,7 @@ use mentat_core::{ Keyword, Schema, StructuredMap, + TxReport, TypedValue, ValueRc, ValueType, @@ -74,7 +75,6 @@ use mentat_db::{ TransactWatcher, TxObservationService, TxObserver, - TxReport, }; use mentat_db::internal_types::TermWithTempIds; diff --git a/src/entity_builder.rs b/src/entity_builder.rs index 62fd43f3..bfc9dde6 100644 --- a/src/entity_builder.rs +++ b/src/entity_builder.rs @@ -66,11 +66,8 @@ use edn::entities::{ }; use mentat_core::{ - TypedValue, -}; - -use mentat_db::{ TxReport, + TypedValue, }; use conn::{ @@ -277,8 +274,8 @@ mod testing { KnownEntid, MentatError, Queryable, - TypedValue, TxReport, + TypedValue, }; use super::*; diff --git a/src/lib.rs b/src/lib.rs index b8e83cd2..f1da47a9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -41,6 +41,7 @@ pub use mentat_core::{ Keyword, Schema, Binding, + TxReport, TypedValue, Uuid, Utc, @@ -56,7 +57,6 @@ pub use mentat_db::{ DB_SCHEMA_CORE, AttributeSet, TxObserver, - TxReport, new_connection, }; diff --git a/src/store.rs b/src/store.rs index 8f04d00c..1cfce8bc 100644 --- a/src/store.rs +++ b/src/store.rs @@ -30,12 +30,12 @@ use mentat_core::{ Entid, Keyword, StructuredMap, + TxReport, TypedValue, ValueRc, }; use mentat_db::{ TxObserver, - TxReport, }; use mentat_tolstoy::Syncer;