Skip to content

Commit 31e1c69

Browse files
Layout extension trait (#627)
* Cursor : LayoutExt * Remove Cursor associated types * Non-working moment * Remove into_owned.rs * Clean-up * Remove generics from upsert
1 parent f9e9798 commit 31e1c69

File tree

24 files changed

+469
-652
lines changed

24 files changed

+469
-652
lines changed

differential-dataflow/src/into_owned.rs

Lines changed: 0 additions & 204 deletions
This file was deleted.

differential-dataflow/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ use std::fmt::Debug;
7979
pub use collection::{Collection, AsCollection};
8080
pub use hashable::Hashable;
8181
pub use difference::Abelian as Diff;
82-
pub use into_owned::IntoOwned;
8382

8483
/// Data type usable in differential dataflow.
8584
///
@@ -106,7 +105,6 @@ pub mod logging;
106105
pub mod consolidation;
107106
pub mod capture;
108107
pub mod containers;
109-
mod into_owned;
110108

111109
/// Configuration options for differential dataflow.
112110
#[derive(Default)]

differential-dataflow/src/operators/arrange/agent.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,12 @@ pub struct TraceAgent<Tr: TraceReader> {
3636
logging: Option<crate::logging::Logger>,
3737
}
3838

39+
use crate::trace::implementations::WithLayout;
40+
impl<Tr: TraceReader> WithLayout for TraceAgent<Tr> {
41+
type Layout = Tr::Layout;
42+
}
43+
3944
impl<Tr: TraceReader> TraceReader for TraceAgent<Tr> {
40-
type Key<'a> = Tr::Key<'a>;
41-
type Val<'a> = Tr::Val<'a>;
42-
type Time = Tr::Time;
43-
type TimeGat<'a> = Tr::TimeGat<'a>;
44-
type Diff = Tr::Diff;
45-
type DiffGat<'a> = Tr::DiffGat<'a>;
4645

4746
type Batch = Tr::Batch;
4847
type Storage = Tr::Storage;

differential-dataflow/src/operators/arrange/arrangement.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use timely::progress::Timestamp;
2626
use timely::progress::Antichain;
2727
use timely::dataflow::operators::Capability;
2828

29-
use crate::{Data, ExchangeData, Collection, AsCollection, Hashable, IntoOwned};
29+
use crate::{Data, ExchangeData, Collection, AsCollection, Hashable};
3030
use crate::difference::Semigroup;
3131
use crate::lattice::Lattice;
3232
use crate::trace::{self, Trace, TraceReader, BatchReader, Batcher, Builder, Cursor};
@@ -285,10 +285,11 @@ where
285285
/// A direct implementation of `ReduceCore::reduce_abelian`.
286286
pub fn reduce_abelian<L, K, V, Bu, T2>(&self, name: &str, mut logic: L) -> Arranged<G, TraceAgent<T2>>
287287
where
288-
for<'a> T1::Key<'a>: IntoOwned<'a, Owned = K>,
288+
T1: TraceReader<KeyOwn = K>,
289289
T2: for<'a> Trace<
290290
Key<'a>= T1::Key<'a>,
291-
Val<'a> : IntoOwned<'a, Owned = V>,
291+
KeyOwn = K,
292+
ValOwn = V,
292293
Time=T1::Time,
293294
Diff: Abelian,
294295
>+'static,
@@ -309,10 +310,11 @@ where
309310
/// A direct implementation of `ReduceCore::reduce_core`.
310311
pub fn reduce_core<L, K, V, Bu, T2>(&self, name: &str, logic: L) -> Arranged<G, TraceAgent<T2>>
311312
where
312-
for<'a> T1::Key<'a>: IntoOwned<'a, Owned = K>,
313+
T1: TraceReader<KeyOwn = K>,
313314
T2: for<'a> Trace<
314315
Key<'a>=T1::Key<'a>,
315-
Val<'a> : IntoOwned<'a, Owned = V>,
316+
KeyOwn = K,
317+
ValOwn = V,
316318
Time=T1::Time,
317319
>+'static,
318320
K: Ord + 'static,

differential-dataflow/src/operators/arrange/upsert.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
//! use differential_dataflow::operators::arrange::upsert;
6060
//!
6161
//! let stream = scope.input_from(&mut input);
62-
//! let arranged = upsert::arrange_from_upsert::<_, _, _, ValBuilder<Key, Val, _, _>, ValSpine<Key, Val, _, _>>(&stream, &"test");
62+
//! let arranged = upsert::arrange_from_upsert::<_, ValBuilder<Key, Val, _, _>, ValSpine<Key, Val, _, _>>(&stream, &"test");
6363
//!
6464
//! arranged
6565
//! .as_collection(|k,v| (k.clone(), v.clone()))
@@ -111,7 +111,9 @@ use timely::dataflow::operators::Capability;
111111
use crate::operators::arrange::arrangement::Arranged;
112112
use crate::trace::{Builder, Description};
113113
use crate::trace::{self, Trace, TraceReader, Cursor};
114-
use crate::{ExchangeData, Hashable, IntoOwned};
114+
use crate::{ExchangeData, Hashable};
115+
116+
use crate::trace::implementations::containers::BatchContainer;
115117

116118
use super::TraceAgent;
117119

@@ -125,21 +127,19 @@ use super::TraceAgent;
125127
/// This method is only implemented for totally ordered times, as we do not yet
126128
/// understand what a "sequence" of upserts would mean for partially ordered
127129
/// timestamps.
128-
pub fn arrange_from_upsert<G, K, V, Bu, Tr>(
129-
stream: &Stream<G, (K, Option<V>, G::Timestamp)>,
130+
pub fn arrange_from_upsert<G, Bu, Tr>(
131+
stream: &Stream<G, (Tr::KeyOwn, Option<Tr::ValOwn>, G::Timestamp)>,
130132
name: &str,
131133
) -> Arranged<G, TraceAgent<Tr>>
132134
where
133135
G: Scope<Timestamp=Tr::Time>,
134-
Tr: Trace + for<'a> TraceReader<
135-
Key<'a> : IntoOwned<'a, Owned = K>,
136-
Val<'a> : IntoOwned<'a, Owned = V>,
136+
Tr: for<'a> Trace<
137+
KeyOwn: ExchangeData+Hashable+std::hash::Hash,
138+
ValOwn: ExchangeData,
137139
Time: TotalOrder+ExchangeData,
138140
Diff=isize,
139141
>+'static,
140-
K: ExchangeData+Hashable+std::hash::Hash,
141-
V: ExchangeData,
142-
Bu: Builder<Time=G::Timestamp, Input = Vec<((K, V), Tr::Time, Tr::Diff)>, Output = Tr::Batch>,
142+
Bu: Builder<Time=G::Timestamp, Input = Vec<((Tr::KeyOwn, Tr::ValOwn), Tr::Time, Tr::Diff)>, Output = Tr::Batch>,
143143
{
144144
let mut reader: Option<TraceAgent<Tr>> = None;
145145

@@ -148,7 +148,7 @@ where
148148

149149
let reader = &mut reader;
150150

151-
let exchange = Exchange::new(move |update: &(K,Option<V>,G::Timestamp)| (update.0).hashed().into());
151+
let exchange = Exchange::new(move |update: &(Tr::KeyOwn,Option<Tr::ValOwn>,G::Timestamp)| (update.0).hashed().into());
152152

153153
stream.unary_frontier(exchange, name, move |_capability, info| {
154154

@@ -173,7 +173,7 @@ where
173173
let mut prev_frontier = Antichain::from_elem(<G::Timestamp as Timestamp>::minimum());
174174

175175
// For stashing input upserts, ordered increasing by time (`BinaryHeap` is a max-heap).
176-
let mut priority_queue = BinaryHeap::<std::cmp::Reverse<(G::Timestamp, K, Option<V>)>>::new();
176+
let mut priority_queue = BinaryHeap::<std::cmp::Reverse<(G::Timestamp, Tr::KeyOwn, Option<Tr::ValOwn>)>>::new();
177177
let mut updates = Vec::new();
178178

179179
move |input, output| {
@@ -236,19 +236,19 @@ where
236236
for (key, mut list) in to_process {
237237

238238
// The prior value associated with the key.
239-
let mut prev_value: Option<V> = None;
239+
let mut prev_value: Option<Tr::ValOwn> = None;
240240

241241
// Attempt to find the key in the trace.
242-
trace_cursor.seek_key(&trace_storage, IntoOwned::borrow_as(&key));
243-
if trace_cursor.get_key(&trace_storage).map(|k| k.eq(&IntoOwned::borrow_as(&key))).unwrap_or(false) {
242+
trace_cursor.seek_key(&trace_storage, Tr::KeyContainer::borrow_as(&key));
243+
if trace_cursor.get_key(&trace_storage).map(|k| k.eq(&Tr::KeyContainer::borrow_as(&key))).unwrap_or(false) {
244244
// Determine the prior value associated with the key.
245245
while let Some(val) = trace_cursor.get_val(&trace_storage) {
246246
let mut count = 0;
247247
trace_cursor.map_times(&trace_storage, |_time, diff| count += Tr::owned_diff(diff));
248248
assert!(count == 0 || count == 1);
249249
if count == 1 {
250250
assert!(prev_value.is_none());
251-
prev_value = Some(val.into_owned());
251+
prev_value = Some(Tr::owned_val(val));
252252
}
253253
trace_cursor.step_val(&trace_storage);
254254
}

0 commit comments

Comments
 (0)