use serde_derive::{Deserialize, Serialize};
#[derive(Debug, Hash, Default, Clone, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize)]
pub struct AltNeu<T> {
pub time: T,
pub neu: bool, }
impl<T> AltNeu<T> {
pub fn alt(time: T) -> Self { AltNeu { time, neu: false } }
pub fn neu(time: T) -> Self { AltNeu { time, neu: true } }
}
use timely::order::PartialOrder;
impl<T: PartialOrder> PartialOrder for AltNeu<T> {
fn less_equal(&self, other: &Self) -> bool {
if self.time.eq(&other.time) {
self.neu <= other.neu
}
else {
self.time.less_equal(&other.time)
}
}
}
use timely::progress::PathSummary;
impl<T: Timestamp> PathSummary<AltNeu<T>> for () {
fn results_in(&self, timestamp: &AltNeu<T>) -> Option<AltNeu<T>> {
Some(timestamp.clone())
}
fn followed_by(&self, other: &Self) -> Option<Self> {
Some(other.clone())
}
}
use timely::progress::Timestamp;
impl<T: Timestamp> Timestamp for AltNeu<T> {
type Summary = ();
fn minimum() -> Self { AltNeu::alt(T::minimum()) }
}
use timely::progress::timestamp::Refines;
impl<T: Timestamp> Refines<T> for AltNeu<T> {
fn to_inner(other: T) -> Self {
AltNeu::alt(other)
}
fn to_outer(self: AltNeu<T>) -> T {
self.time
}
fn summarize(_path: ()) -> <T as Timestamp>::Summary {
Default::default()
}
}
use differential_dataflow::lattice::Lattice;
impl<T: Lattice> Lattice for AltNeu<T> {
fn join(&self, other: &Self) -> Self {
let time = self.time.join(&other.time);
let mut neu = false;
if time == self.time {
neu = neu || self.neu;
}
if time == other.time {
neu = neu || other.neu;
}
AltNeu { time, neu }
}
fn meet(&self, other: &Self) -> Self {
let time = self.time.meet(&other.time);
let mut neu = true;
if time == self.time {
neu = neu && self.neu;
}
if time == other.time {
neu = neu && other.neu;
}
AltNeu { time, neu }
}
}