diff --git a/src/operators/reduce.rs b/src/operators/reduce.rs index 135128efe..f8d9edeb1 100644 --- a/src/operators/reduce.rs +++ b/src/operators/reduce.rs @@ -210,16 +210,25 @@ pub trait Count where G::Timestamp: Lattice+Ord /// }); /// } /// ``` - fn count(&self) -> Collection; + fn count(&self) -> Collection { + self.count_core() + } + + /// Count for general integer differences. + /// + /// This method allows `count` to produce collections whose difference + /// type is something other than an `isize` integer, for example perhaps an + /// `i32`. + fn count_core>(&self) -> Collection; } impl Count for Collection where G::Timestamp: Lattice+Ord, { - fn count(&self) -> Collection { + fn count_core>(&self) -> Collection { self.arrange_by_self_named("Arrange: Count") - .count() + .count_core() } } @@ -230,8 +239,8 @@ where T1::Batch: BatchReader, T1::Cursor: Cursor, { - fn count(&self) -> Collection { - self.reduce_abelian::<_,DefaultValTrace<_,_,_,_>>("Count", |_k,s,t| t.push((s[0].1.clone(), 1))) + fn count_core>(&self) -> Collection { + self.reduce_abelian::<_,DefaultValTrace<_,_,_,_>>("Count", |_k,s,t| t.push((s[0].1.clone(), R2::from(1i8)))) .as_collection(|k,c| (k.clone(), c.clone())) } }