diff --git a/Cargo.toml b/Cargo.toml index f5bb56337..39830188f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,6 +18,7 @@ resolver = "2" [workspace.dependencies] differential-dataflow = { path = "differential-dataflow", default-features = false, version = "0.15.3" } timely = { version = "0.21", default-features = false } +columnar = { version = "0.8", default-features = false } #timely = { path = "../timely-dataflow/timely/", default-features = false } [profile.release] diff --git a/differential-dataflow/Cargo.toml b/differential-dataflow/Cargo.toml index d087c3fd7..f398600a4 100644 --- a/differential-dataflow/Cargo.toml +++ b/differential-dataflow/Cargo.toml @@ -23,7 +23,7 @@ graph_map = "0.1" bytemuck = "1.18.0" [dependencies] -columnar = "0.6" +columnar = { workspace = true } columnation = "0.1.0" fnv="1.0.2" paste = "1.0" diff --git a/differential-dataflow/examples/columnar.rs b/differential-dataflow/examples/columnar.rs index 52d5e141f..1d0da0f10 100644 --- a/differential-dataflow/examples/columnar.rs +++ b/differential-dataflow/examples/columnar.rs @@ -156,15 +156,17 @@ mod container { use columnar::bytes::{EncodeDecode, Indexed}; use columnar::common::IterOwn; + type BorrowedOf<'a, C> = <::Container as columnar::Container>::Borrowed<'a>; + impl Column { - pub fn borrow(&self) -> >::Borrowed<'_> { + pub fn borrow(&self) -> BorrowedOf { match self { Column::Typed(t) => t.borrow(), - Column::Bytes(b) => <>::Borrowed<'_> as FromBytes>::from_bytes(&mut Indexed::decode(bytemuck::cast_slice(b))), - Column::Align(a) => <>::Borrowed<'_> as FromBytes>::from_bytes(&mut Indexed::decode(a)), + Column::Bytes(b) => as FromBytes>::from_bytes(&mut Indexed::decode(bytemuck::cast_slice(b))), + Column::Align(a) => as FromBytes>::from_bytes(&mut Indexed::decode(a)), } } - pub fn get(&self, index: usize) -> C::Ref<'_> { + pub fn get(&self, index: usize) -> columnar::Ref { self.borrow().get(index) } } @@ -174,8 +176,8 @@ mod container { fn len(&self) -> usize { match self { Column::Typed(t) => t.len(), - Column::Bytes(b) => <>::Borrowed<'_> as FromBytes>::from_bytes(&mut Indexed::decode(bytemuck::cast_slice(b))).len(), - Column::Align(a) => <>::Borrowed<'_> as FromBytes>::from_bytes(&mut Indexed::decode(a)).len(), + Column::Bytes(b) => as FromBytes>::from_bytes(&mut Indexed::decode(bytemuck::cast_slice(b))).len(), + Column::Align(a) => as FromBytes>::from_bytes(&mut Indexed::decode(a)).len(), } } // This sets the `Bytes` variant to be an empty `Typed` variant, appropriate for pushing into. @@ -187,23 +189,23 @@ mod container { } } - type ItemRef<'a> = C::Ref<'a>; - type Iter<'a> = IterOwn<>::Borrowed<'a>>; + type ItemRef<'a> = columnar::Ref<'a, C>; + type Iter<'a> = IterOwn>; fn iter<'a>(&'a self) -> Self::Iter<'a> { match self { Column::Typed(t) => t.borrow().into_index_iter(), - Column::Bytes(b) => <>::Borrowed<'a> as FromBytes>::from_bytes(&mut Indexed::decode(bytemuck::cast_slice(b))).into_index_iter(), - Column::Align(a) => <>::Borrowed<'a> as FromBytes>::from_bytes(&mut Indexed::decode(a)).into_index_iter(), + Column::Bytes(b) => as FromBytes>::from_bytes(&mut Indexed::decode(bytemuck::cast_slice(b))).into_index_iter(), + Column::Align(a) => as FromBytes>::from_bytes(&mut Indexed::decode(a)).into_index_iter(), } } - type Item<'a> = C::Ref<'a>; - type DrainIter<'a> = IterOwn<>::Borrowed<'a>>; + type Item<'a> = columnar::Ref<'a, C>; + type DrainIter<'a> = IterOwn>; fn drain<'a>(&'a mut self) -> Self::DrainIter<'a> { match self { Column::Typed(t) => t.borrow().into_index_iter(), - Column::Bytes(b) => <>::Borrowed<'a> as FromBytes>::from_bytes(&mut Indexed::decode(bytemuck::cast_slice(b))).into_index_iter(), - Column::Align(a) => <>::Borrowed<'a> as FromBytes>::from_bytes(&mut Indexed::decode(a)).into_index_iter(), + Column::Bytes(b) => as FromBytes>::from_bytes(&mut Indexed::decode(bytemuck::cast_slice(b))).into_index_iter(), + Column::Align(a) => as FromBytes>::from_bytes(&mut Indexed::decode(a)).into_index_iter(), } } } @@ -406,10 +408,13 @@ pub mod batcher { impl<'a, D, T, R, C2> PushInto<&'a mut Column<(D, T, R)>> for Chunker where - D: for<'b> Columnar: Ord>, - T: for<'b> Columnar: Ord>, - R: for<'b> Columnar: Ord> + for<'b> Semigroup>, - C2: Container + for<'b, 'c> PushInto<(D::Ref<'b>, T::Ref<'b>, &'c R)>, + D: for<'b> Columnar, + for<'b> columnar::Ref<'b, D>: Ord, + T: for<'b> Columnar, + for<'b> columnar::Ref<'b, T>: Ord, + R: for<'b> Columnar + for<'b> Semigroup>, + for<'b> columnar::Ref<'b, R>: Ord, + C2: Container + for<'b, 'c> PushInto<(columnar::Ref<'b, D>, columnar::Ref<'b, T>, &'c R)>, { fn push_into(&mut self, container: &'a mut Column<(D, T, R)>) { @@ -482,11 +487,13 @@ pub mod batcher { impl ContainerQueue> for ColumnQueue<(D, T, R)> where - D: for<'a> Columnar: Ord>, - T: for<'a> Columnar: Ord>, + D: for<'a> Columnar, + for<'b> columnar::Ref<'b, D>: Ord, + T: for<'a> Columnar, + for<'b> columnar::Ref<'b, T>: Ord, R: Columnar, { - fn next_or_alloc(&mut self) -> Result<<(D, T, R) as Columnar>::Ref<'_>, Column<(D, T, R)>> { + fn next_or_alloc(&mut self) -> Result, Column<(D, T, R)>> { if self.is_empty() { Err(std::mem::take(&mut self.list)) } @@ -510,12 +517,12 @@ pub mod batcher { } impl ColumnQueue { - fn pop(&mut self) -> T::Ref<'_> { + fn pop(&mut self) -> columnar::Ref { self.head += 1; self.list.get(self.head - 1) } - fn peek(&self) -> T::Ref<'_> { + fn peek(&self) -> columnar::Ref { self.list.get(self.head) } }