|
2 | 2 | import cloudpickle |
3 | 3 | import pickle |
4 | 4 |
|
| 5 | +class GearsRemoteLocalGroupByStep(): |
| 6 | + def __init__(self, extractor, reducer): |
| 7 | + self.extractor = extractor |
| 8 | + self.reducer = reducer |
| 9 | + |
| 10 | + def AddToGB(self, gb): |
| 11 | + gb.localgroupby(self.extractor, self.reducer) |
| 12 | + |
| 13 | +class GearsRemoteAccumulateStep(): |
| 14 | + def __init__(self, accumulator): |
| 15 | + self.accumulator = accumulator |
| 16 | + |
| 17 | + def AddToGB(self, gb): |
| 18 | + gb.accumulate(self.accumulator) |
| 19 | + |
5 | 20 | class GearsRemoteRepartitionStep(): |
6 | 21 | def __init__(self, extractor): |
7 | 22 | self.extractor = extractor |
@@ -126,6 +141,14 @@ def __init__(self, reader='KeysReader', defaultArg='*'): |
126 | 141 | self.defaultArg = defaultArg |
127 | 142 | self.steps = [] |
128 | 143 |
|
| 144 | + def localgroupby(self, extractor, reducer): |
| 145 | + self.steps.append(GearsRemoteLocalGroupByStep(extractor, reducer)) |
| 146 | + return self |
| 147 | + |
| 148 | + def accumulate(self, accumulator): |
| 149 | + self.steps.append(GearsRemoteAccumulateStep(accumulator)) |
| 150 | + return self |
| 151 | + |
129 | 152 | def repartition(self, extractor): |
130 | 153 | self.steps.append(GearsRemoteRepartitionStep(extractor)) |
131 | 154 | return self |
@@ -198,6 +221,14 @@ def __init__(self, reader='KeysReader', defaultArg='*', r=None): |
198 | 221 | self.r = r |
199 | 222 | self.pipe = GearsPipe(reader, defaultArg) |
200 | 223 |
|
| 224 | + def localgroupby(self, extractor, reducer): |
| 225 | + self.pipe.localgroupby(extractor, reducer) |
| 226 | + return self |
| 227 | + |
| 228 | + def accumulate(self, accumulator): |
| 229 | + self.pipe.accumulate(accumulator) |
| 230 | + return self |
| 231 | + |
201 | 232 | def repartition(self, extractor): |
202 | 233 | self.pipe.repartition(extractor) |
203 | 234 | return self |
|
0 commit comments