Skip to main content

differential_dataflow/columnar/
layout.rs

1//! Layout traits for columnar arrangements.
2//!
3//! `ColumnarUpdate` names the four constituent columnar types of an update,
4//! and `ColumnarLayout` glues them into a DD `Layout` backed by `Coltainer`.
5
6use std::fmt::Debug;
7use columnar::Columnar;
8use crate::trace::implementations::{Layout, OffsetList};
9use crate::difference::Semigroup;
10use crate::lattice::Lattice;
11use timely::progress::Timestamp;
12
13/// A layout based on columnar
14pub struct ColumnarLayout<U: ColumnarUpdate> {
15    phantom: std::marker::PhantomData<U>,
16}
17
18impl<K, V, T, R> ColumnarUpdate for (K, V, T, R)
19where
20    K: Columnar<Container: OrdContainer + Debug + Default> + Debug + Ord + Clone + 'static,
21    V: Columnar<Container: OrdContainer + Debug + Default> + Debug + Ord + Clone + 'static,
22    T: Columnar<Container: OrdContainer + Debug + Default> + Debug + Ord + Default + Clone + Lattice + Timestamp,
23    R: Columnar<Container: OrdContainer + Debug + Default> + Debug + Ord + Default + Semigroup + 'static,
24{
25    type Key = K;
26    type Val = V;
27    type Time = T;
28    type Diff = R;
29}
30
31impl<U: ColumnarUpdate> Layout for ColumnarLayout<U> {
32    type KeyContainer    = super::arrangement::Coltainer<U::Key>;
33    type ValContainer    = super::arrangement::Coltainer<U::Val>;
34    type TimeContainer   = super::arrangement::Coltainer<U::Time>;
35    type DiffContainer   = super::arrangement::Coltainer<U::Diff>;
36    type OffsetContainer = OffsetList;
37}
38
39/// A type that names constituent update types.
40///
41/// We will use their associated `Columnar::Container`
42pub trait ColumnarUpdate : Debug + 'static {
43    /// The key type.
44    type Key:  Columnar<Container: OrdContainer + Debug + Default> + Debug + Ord + Clone + 'static;
45    /// The value type.
46    type Val:  Columnar<Container: OrdContainer + Debug + Default> + Debug + Ord + Clone + 'static;
47    /// The time type.
48    type Time: Columnar<Container: OrdContainer + Debug + Default> + Debug + Ord + Default + Clone + Lattice + Timestamp;
49    /// The difference type.
50    type Diff: Columnar<Container: OrdContainer + Debug + Default> + Debug + Ord + Default + Semigroup + 'static;
51}
52
53/// A container whose references can be ordered.
54pub trait OrdContainer : for<'a> columnar::Container<Ref<'a> : Ord> { }
55impl<C: for<'a> columnar::Container<Ref<'a> : Ord>> OrdContainer for C { }