Skip to content

Commit

Permalink
release 0.11 (#185)
Browse files Browse the repository at this point in the history
* bump crate version numbers & update host documentation

* bump client version

* use the as_type macro to generate AsType impls

* bump dep versions

* bump dep versions
  • Loading branch information
haydnv authored Sep 14, 2022
1 parent 84c2641 commit 430ee32
Show file tree
Hide file tree
Showing 24 changed files with 62 additions and 306 deletions.
2 changes: 1 addition & 1 deletion client/setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = tinychain
version = 0.10.0
version = 0.11.0
author = The TinyChain Contributors
author_email = [email protected]
description = A Python client for TinyChain: http://git.io/JtryR
Expand Down
14 changes: 7 additions & 7 deletions host/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tinychain"
version = "0.10.0"
version = "0.11.0"
authors = ["[email protected]"]
edition = "2018"
description = "A next-gen database + application server"
Expand Down Expand Up @@ -44,13 +44,13 @@ serde_json = { version = "1.0" }
sha2 = "0.10"
structopt = "0.3"
tbon = "~0.3.5"
tc-btree = { path = "btree" }
tc-btree = "0.7"
tc-error = "0.6"
tc-math = { path = "math", optional = true }
tc-tensor = { path = "tensor", optional = true }
tc-transact = { path = "transact", features = ["tensor"] }
tc-value = { path = "value" }
tc-table = { path = "table" }
tc-math = { version = "0.5", optional = true }
tc-tensor = { version = "0.7", optional = true }
tc-transact = { version = "0.14", features = ["tensor"] }
tc-value = "0.7"
tc-table = "0.6"
tcgeneric = "0.5"
tokio = { version = "1.21", features = ["rt-multi-thread", "signal"] }
tokio-util = { version = "0.7", features = ["io"] }
Expand Down
4 changes: 2 additions & 2 deletions host/btree/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ log = { version = "0.4", features = ["release_max_level_warn"] }
num_cpus = "1.13"
safecast = "0.1"
tc-error = "0.6"
tc-transact = { path = "../transact" }
tc-value = { path = "../value" }
tc-transact = "0.14"
tc-value = "0.7"
tcgeneric = "0.5"
uuid = { version = "1.1", features=["v4"] }
12 changes: 4 additions & 8 deletions host/math/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tc-math"
version = "0.4.0"
version = "0.5.0"
authors = ["[email protected]"]
edition = "2018"
description = "Mathematical algorithms for TinyChain tensors. Unstable."
Expand All @@ -13,12 +13,8 @@ categories = ["algorithms", "concurrency", "mathematics", "science"]

[dependencies]
log = { version = "0.4", features = ["release_max_level_warn"] }
# TODO: remove
tc-btree = { path = "../btree" }
tc-error = "0.6"
tc-transact = { path = "../transact", features = ["tensor"] }
tc-value = { path = "../value" }
# TODO: remove
tc-table = { path = "../table" }
tc-tensor = { path = "../tensor" }
tc-transact = { version = "0.14", features = ["tensor"] }
tc-value = "0.7"
tc-tensor = "0.7"
tcgeneric = "0.5"
2 changes: 1 addition & 1 deletion host/src/chain/data/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ impl ChainBlock {
}

/// Append a [`Mutation`] to this [`ChainBlock`]
pub fn append(&mut self, txn_id: TxnId, mutation: Mutation) {
pub(super) fn append(&mut self, txn_id: TxnId, mutation: Mutation) {
match self.mutations.entry(txn_id) {
Entry::Vacant(entry) => {
entry.insert(vec![mutation]);
Expand Down
2 changes: 1 addition & 1 deletion host/src/collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub type SparseTensor<A> =
pub type SparseTable =
tc_tensor::SparseTable<fs::File<Array>, fs::File<tc_btree::Node>, fs::Dir, Txn>;

pub const PREFIX: PathLabel = path_label(&["state", "collection"]);
pub(crate) const PREFIX: PathLabel = path_label(&["state", "collection"]);

/// The [`Class`] of a [`Collection`].
#[derive(Clone, Copy, Eq, PartialEq)]
Expand Down
135 changes: 5 additions & 130 deletions host/src/fs/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use async_trait::async_trait;
use bytes::Bytes;
use destream::en;
use futures::{TryFutureExt, TryStreamExt};
use safecast::AsType;
use safecast::{as_type, AsType};
use tokio::fs;
use tokio_util::io::StreamReader;

Expand Down Expand Up @@ -84,136 +84,11 @@ impl freqfs::FileLoad for CacheBlock {
}
}

// TODO: use a macro to generate this code
impl AsType<Node> for CacheBlock {
fn as_type(&self) -> Option<&Node> {
if let Self::BTree(node) = self {
Some(node)
} else {
None
}
}

fn as_type_mut(&mut self) -> Option<&mut Node> {
if let Self::BTree(node) = self {
Some(node)
} else {
None
}
}

fn into_type(self) -> Option<Node> {
if let Self::BTree(node) = self {
Some(node)
} else {
None
}
}
}

impl AsType<ChainBlock> for CacheBlock {
fn as_type(&self) -> Option<&ChainBlock> {
if let Self::Chain(block) = self {
Some(block)
} else {
None
}
}

fn as_type_mut(&mut self) -> Option<&mut ChainBlock> {
if let Self::Chain(block) = self {
Some(block)
} else {
None
}
}

fn into_type(self) -> Option<ChainBlock> {
if let Self::Chain(block) = self {
Some(block)
} else {
None
}
}
}

#[cfg(feature = "tensor")]
impl AsType<Array> for CacheBlock {
fn as_type(&self) -> Option<&Array> {
if let Self::Tensor(array) = self {
Some(array)
} else {
None
}
}

fn as_type_mut(&mut self) -> Option<&mut Array> {
if let Self::Tensor(array) = self {
Some(array)
} else {
None
}
}

fn into_type(self) -> Option<Array> {
if let Self::Tensor(array) = self {
Some(array)
} else {
None
}
}
}

impl AsType<Scalar> for CacheBlock {
fn as_type(&self) -> Option<&Scalar> {
if let Self::Scalar(scalar) = self {
Some(scalar)
} else {
None
}
}

fn as_type_mut(&mut self) -> Option<&mut Scalar> {
if let Self::Scalar(scalar) = self {
Some(scalar)
} else {
None
}
}

fn into_type(self) -> Option<Scalar> {
if let Self::Scalar(scalar) = self {
Some(scalar)
} else {
None
}
}
}

impl From<Node> for CacheBlock {
fn from(node: Node) -> Self {
Self::BTree(node)
}
}

impl From<ChainBlock> for CacheBlock {
fn from(block: ChainBlock) -> Self {
Self::Chain(block)
}
}

as_type!(CacheBlock, BTree, Node);
as_type!(CacheBlock, Chain, ChainBlock);
as_type!(CacheBlock, Scalar, Scalar);
#[cfg(feature = "tensor")]
impl From<Array> for CacheBlock {
fn from(array: Array) -> Self {
Self::Tensor(array)
}
}

impl From<Scalar> for CacheBlock {
fn from(scalar: Scalar) -> Self {
Self::Scalar(scalar)
}
}
as_type!(CacheBlock, Tensor, Array);

async fn persist<'en, T: en::ToStream<'en>>(
data: &'en T,
Expand Down
Loading

0 comments on commit 430ee32

Please sign in to comment.