Skip to content

Commit d9ec6db

Browse files
committed
Relax Arrange trait to input types
1 parent d19b934 commit d9ec6db

File tree

1 file changed

+37
-38
lines changed

1 file changed

+37
-38
lines changed

src/operators/arrange/arrangement.rs

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -434,85 +434,84 @@ where
434434
}
435435
}
436436

437-
/// A type that can be arranged into a trace of type `T`.
437+
/// A type that can be arranged as if a collection of updates shaped as `((K,V),G::Timestamp,R)`.
438438
///
439-
/// This trait is implemented for appropriately typed collections and all traces that might accommodate them,
440-
/// as well as by arranged data for their corresponding trace type.
441-
pub trait Arrange<G: Scope, K, V, R: Semigroup>
439+
/// This trait is primarily implemented by `Collection<G,(K,V),R>`.
440+
///
441+
/// The resulting arrangements may not present as `((K,V),T,R)`, as their output types are unconstrained.
442+
/// This allows e.g. for `Vec<u8>` inputs to present as `&[u8]` when read, but that relationship is not
443+
/// constrained by this trait.
444+
pub trait Arrange<G, K, V, R>
442445
where
446+
G: Scope,
443447
G::Timestamp: Lattice,
444-
K: ToOwned + ?Sized,
445-
K::Owned: Data,
446-
V: Data,
448+
R: Semigroup
447449
{
448-
/// Arranges a stream of `(Key, Val)` updates by `Key`. Accepts an empty instance of the trace type.
450+
/// Arranges a stream of `(Key, Val)` updates by `Key`.
449451
///
450452
/// This operator arranges a stream of values into a shared trace, whose contents it maintains.
451-
/// This trace is current for all times marked completed in the output stream, and probing this stream
452-
/// is the correct way to determine that times in the shared trace are committed.
453453
fn arrange<Tr>(&self) -> Arranged<G, TraceAgent<Tr>>
454454
where
455-
K::Owned: ExchangeData+Hashable,
455+
Tr: Trace<Time=G::Timestamp> + 'static,
456+
K: ExchangeData + Hashable,
456457
V: ExchangeData,
457458
R: ExchangeData,
458-
Tr: Trace<Key=K>+TraceReader<Time=G::Timestamp>+'static,
459459
Tr::Batch: Batch,
460-
Tr::Batcher: Batcher<Item = ((K::Owned,V),G::Timestamp,R), Time = G::Timestamp>,
461-
Tr::Builder: Builder<Item = ((K::Owned,V),G::Timestamp,R), Time = G::Timestamp, Output = Tr::Batch>,
460+
Tr::Batcher: Batcher<Item = ((K,V),G::Timestamp,R), Time = G::Timestamp>,
461+
Tr::Builder: Builder<Item = ((K,V),G::Timestamp,R), Time = G::Timestamp, Output = Tr::Batch>,
462462
{
463463
self.arrange_named("Arrange")
464464
}
465465

466-
/// Arranges a stream of `(Key, Val)` updates by `Key`. Accepts an empty instance of the trace type.
466+
/// Arranges a stream of `(Key, Val)` updates by `Key`, and presents with a `name` argument.
467467
///
468468
/// This operator arranges a stream of values into a shared trace, whose contents it maintains.
469-
/// This trace is current for all times marked completed in the output stream, and probing this stream
470-
/// is the correct way to determine that times in the shared trace are committed.
471469
fn arrange_named<Tr>(&self, name: &str) -> Arranged<G, TraceAgent<Tr>>
472470
where
473-
K::Owned: ExchangeData+Hashable,
471+
Tr: Trace<Time=G::Timestamp> + 'static,
472+
K: ExchangeData + Hashable,
474473
V: ExchangeData,
475474
R: ExchangeData,
476-
Tr: Trace<Key=K>+TraceReader<Time=G::Timestamp>+'static,
477475
Tr::Batch: Batch,
478-
Tr::Batcher: Batcher<Item = ((K::Owned,V),G::Timestamp,R), Time = G::Timestamp>,
479-
Tr::Builder: Builder<Item = ((K::Owned,V),G::Timestamp,R), Time = G::Timestamp, Output = Tr::Batch>,
476+
Tr::Batcher: Batcher<Item = ((K,V),G::Timestamp,R), Time = G::Timestamp>,
477+
Tr::Builder: Builder<Item = ((K,V),G::Timestamp,R), Time = G::Timestamp, Output = Tr::Batch>,
480478
{
481-
let exchange = Exchange::new(move |update: &((K::Owned,V),G::Timestamp,R)| (update.0).0.hashed().into());
479+
let exchange = Exchange::new(move |update: &((K,V),G::Timestamp,R)| (update.0).0.hashed().into());
482480
self.arrange_core(exchange, name)
483481
}
484482

485-
/// Arranges a stream of `(Key, Val)` updates by `Key`. Accepts an empty instance of the trace type.
483+
/// Arranges a stream of `(Key, Val)` updates by `Key`, configured with a name and a parallelization contract.
486484
///
487485
/// This operator arranges a stream of values into a shared trace, whose contents it maintains.
488-
/// This trace is current for all times marked completed in the output stream, and probing this stream
489-
/// is the correct way to determine that times in the shared trace are committed.
486+
/// It uses the supplied parallelization contract to distribute the data, which does not need to
487+
/// be consistently by key (though this is the most common).
490488
fn arrange_core<P, Tr>(&self, pact: P, name: &str) -> Arranged<G, TraceAgent<Tr>>
491489
where
492-
P: ParallelizationContract<G::Timestamp, ((K::Owned,V),G::Timestamp,R)>,
493-
Tr: Trace<Key=K>+TraceReader<Time=G::Timestamp>+'static,
490+
P: ParallelizationContract<G::Timestamp, ((K,V),G::Timestamp,R)>,
491+
K: Clone,
492+
V: Clone,
493+
Tr: Trace<Time=G::Timestamp>+'static,
494494
Tr::Batch: Batch,
495-
Tr::Batcher: Batcher<Item = ((K::Owned,V),G::Timestamp,R), Time = G::Timestamp>,
496-
Tr::Builder: Builder<Item = ((K::Owned,V),G::Timestamp,R), Time = G::Timestamp, Output = Tr::Batch>,
495+
Tr::Batcher: Batcher<Item = ((K,V),G::Timestamp,R), Time = G::Timestamp>,
496+
Tr::Builder: Builder<Item = ((K,V),G::Timestamp,R), Time = G::Timestamp, Output = Tr::Batch>,
497497
;
498498
}
499499

500-
impl<G, K, V, R> Arrange<G, K, V, R> for Collection<G, (K::Owned, V), R>
500+
impl<G, K, V, R> Arrange<G, K, V, R> for Collection<G, (K, V), R>
501501
where
502502
G: Scope,
503-
G::Timestamp: Lattice+Ord,
504-
K: ToOwned + ?Sized,
505-
K::Owned: Data,
506-
V: Data,
503+
G::Timestamp: Lattice,
504+
K: Clone + 'static,
505+
V: Clone + 'static,
507506
R: Semigroup,
508507
{
509508
fn arrange_core<P, Tr>(&self, pact: P, name: &str) -> Arranged<G, TraceAgent<Tr>>
510509
where
511-
P: ParallelizationContract<G::Timestamp, ((K::Owned,V),G::Timestamp,R)>,
512-
Tr: Trace<Key=K>+TraceReader<Time=G::Timestamp>+'static,
510+
P: ParallelizationContract<G::Timestamp, ((K,V),G::Timestamp,R)>,
511+
Tr: Trace<Time=G::Timestamp>+'static,
513512
Tr::Batch: Batch,
514-
Tr::Batcher: Batcher<Item = ((K::Owned,V),G::Timestamp,R), Time = G::Timestamp>,
515-
Tr::Builder: Builder<Item = ((K::Owned,V),G::Timestamp,R), Time = G::Timestamp, Output = Tr::Batch>,
513+
Tr::Batcher: Batcher<Item = ((K,V),G::Timestamp,R), Time = G::Timestamp>,
514+
Tr::Builder: Builder<Item = ((K,V),G::Timestamp,R), Time = G::Timestamp, Output = Tr::Batch>,
516515
{
517516
// The `Arrange` operator is tasked with reacting to an advancing input
518517
// frontier by producing the sequence of batches whose lower and upper

0 commit comments

Comments
 (0)