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.
This commit is contained in:
Nick Alexander 2018-07-03 13:18:02 -07:00
parent 1cb1847aa6
commit 06056a8468
10 changed files with 50 additions and 28 deletions

View file

@ -60,9 +60,14 @@ pub use cache::{
/// Core types defining a Mentat knowledge base. /// Core types defining a Mentat knowledge base.
mod types; mod types;
mod tx_report;
mod value_type_set; mod value_type_set;
mod sql_types; mod sql_types;
pub use tx_report::{
TxReport,
};
pub use types::{ pub use types::{
Binding, Binding,
Entid, Entid,

38
core/src/tx_report.rs Normal file
View file

@ -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<Utc>,
/// 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<String, Entid>,
}

View file

@ -1131,6 +1131,7 @@ mod tests {
HasSchema, HasSchema,
Keyword, Keyword,
KnownEntid, KnownEntid,
TxReport,
attribute, attribute,
}; };
use mentat_core::util::Either::*; use mentat_core::util::Either::*;
@ -1142,7 +1143,6 @@ mod tests {
Term, Term,
TermWithTempIds, TermWithTempIds,
}; };
use types::TxReport;
use tx::{ use tx::{
transact_terms, transact_terms,
}; };

View file

@ -106,7 +106,6 @@ pub use types::{
DB, DB,
PartitionMap, PartitionMap,
TransactableValue, TransactableValue,
TxReport,
}; };
pub fn to_namespaced_keyword(s: &str) -> Result<symbols::Keyword> { pub fn to_namespaced_keyword(s: &str) -> Result<symbols::Keyword> {

View file

@ -94,6 +94,7 @@ use mentat_core::{
DateTime, DateTime,
KnownEntid, KnownEntid,
Schema, Schema,
TxReport,
Utc, Utc,
attribute, attribute,
now, now,
@ -119,7 +120,6 @@ use types::{
Entid, Entid,
PartitionMap, PartitionMap,
TransactableValue, TransactableValue,
TxReport,
TypedValue, TypedValue,
ValueType, ValueType,
}; };

View file

@ -95,23 +95,6 @@ pub type AVMap<'a> = HashMap<&'a AVPair, Entid>;
// represents a set of entids that are correspond to attributes // represents a set of entids that are correspond to attributes
pub type AttributeSet = BTreeSet<Entid>; pub type AttributeSet = BTreeSet<Entid>;
/// 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<Utc>,
/// 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<String, Entid>,
}
/// The transactor is tied to `edn::ValueAndSpan` right now, but in the future we'd like to support /// 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 /// `TypedValue` directly for programmatic use. `TransactableValue` encapsulates the interface
/// value types (i.e., values in the value place) need to support to be transacted. /// value types (i.e., values in the value place) need to support to be transacted.

View file

@ -53,6 +53,7 @@ use mentat_core::{
Keyword, Keyword,
Schema, Schema,
StructuredMap, StructuredMap,
TxReport,
TypedValue, TypedValue,
ValueRc, ValueRc,
ValueType, ValueType,
@ -74,7 +75,6 @@ use mentat_db::{
TransactWatcher, TransactWatcher,
TxObservationService, TxObservationService,
TxObserver, TxObserver,
TxReport,
}; };
use mentat_db::internal_types::TermWithTempIds; use mentat_db::internal_types::TermWithTempIds;

View file

@ -66,11 +66,8 @@ use edn::entities::{
}; };
use mentat_core::{ use mentat_core::{
TypedValue,
};
use mentat_db::{
TxReport, TxReport,
TypedValue,
}; };
use conn::{ use conn::{
@ -277,8 +274,8 @@ mod testing {
KnownEntid, KnownEntid,
MentatError, MentatError,
Queryable, Queryable,
TypedValue,
TxReport, TxReport,
TypedValue,
}; };
use super::*; use super::*;

View file

@ -41,6 +41,7 @@ pub use mentat_core::{
Keyword, Keyword,
Schema, Schema,
Binding, Binding,
TxReport,
TypedValue, TypedValue,
Uuid, Uuid,
Utc, Utc,
@ -56,7 +57,6 @@ pub use mentat_db::{
DB_SCHEMA_CORE, DB_SCHEMA_CORE,
AttributeSet, AttributeSet,
TxObserver, TxObserver,
TxReport,
new_connection, new_connection,
}; };

View file

@ -30,12 +30,12 @@ use mentat_core::{
Entid, Entid,
Keyword, Keyword,
StructuredMap, StructuredMap,
TxReport,
TypedValue, TypedValue,
ValueRc, ValueRc,
}; };
use mentat_db::{ use mentat_db::{
TxObserver, TxObserver,
TxReport,
}; };
use mentat_tolstoy::Syncer; use mentat_tolstoy::Syncer;