@@ -48,14 +48,23 @@ pub trait CountTotal<G: Scope, K: ExchangeData, R: Semigroup> where G::Timestamp
48
48
/// });
49
49
/// }
50
50
/// ```
51
- fn count_total ( & self ) -> Collection < G , ( K , R ) , isize > ;
51
+ fn count_total ( & self ) -> Collection < G , ( K , R ) , isize > {
52
+ self . count_total_core ( )
53
+ }
54
+
55
+ /// Count for general integer differences.
56
+ ///
57
+ /// This method allows `count_total` to produce collections whose difference
58
+ /// type is something other than an `isize` integer, for example perhaps an
59
+ /// `i32`.
60
+ fn count_total_core < R2 : Semigroup + From < i8 > > ( & self ) -> Collection < G , ( K , R ) , R2 > ;
52
61
}
53
62
54
63
impl < G : Scope , K : ExchangeData +Hashable , R : ExchangeData +Semigroup > CountTotal < G , K , R > for Collection < G , K , R >
55
64
where G :: Timestamp : TotalOrder +Lattice +Ord {
56
- fn count_total ( & self ) -> Collection < G , ( K , R ) , isize > {
65
+ fn count_total_core < R2 : Semigroup + From < i8 > > ( & self ) -> Collection < G , ( K , R ) , R2 > {
57
66
self . arrange_by_self_named ( "Arrange: CountTotal" )
58
- . count_total ( )
67
+ . count_total_core ( )
59
68
}
60
69
}
61
70
68
77
T1 :: Batch : BatchReader < T1 :: Key , ( ) , G :: Timestamp , T1 :: R > ,
69
78
T1 :: Cursor : Cursor < T1 :: Key , ( ) , G :: Timestamp , T1 :: R > ,
70
79
{
71
- fn count_total ( & self ) -> Collection < G , ( T1 :: Key , T1 :: R ) , isize > {
80
+ fn count_total_core < R2 : Semigroup + From < i8 > > ( & self ) -> Collection < G , ( T1 :: Key , T1 :: R ) , R2 > {
72
81
73
82
let mut trace = self . trace . clone ( ) ;
74
83
let mut buffer = Vec :: new ( ) ;
@@ -105,14 +114,14 @@ where
105
114
106
115
if let Some ( count) = count. as_ref ( ) {
107
116
if !count. is_zero ( ) {
108
- session. give ( ( ( key. clone ( ) , count. clone ( ) ) , time. clone ( ) , - 1 ) ) ;
117
+ session. give ( ( ( key. clone ( ) , count. clone ( ) ) , time. clone ( ) , R2 :: from ( - 1i8 ) ) ) ;
109
118
}
110
119
}
111
120
count. as_mut ( ) . map ( |c| c. plus_equals ( diff) ) ;
112
121
if count. is_none ( ) { count = Some ( diff. clone ( ) ) ; }
113
122
if let Some ( count) = count. as_ref ( ) {
114
123
if !count. is_zero ( ) {
115
- session. give ( ( ( key. clone ( ) , count. clone ( ) ) , time. clone ( ) , 1 ) ) ;
124
+ session. give ( ( ( key. clone ( ) , count. clone ( ) ) , time. clone ( ) , R2 :: from ( 1i8 ) ) ) ;
116
125
}
117
126
}
118
127
} ) ;
0 commit comments