262 def mytest_repr(self): |
262 def mytest_repr(self): |
263 """return a representation of this step suitable for test""" |
263 """return a representation of this step suitable for test""" |
264 return (self.__class__.__name__, self.limit, self.offset) |
264 return (self.__class__.__name__, self.limit, self.offset) |
265 |
265 |
266 |
266 |
|
267 class IntersectStep(UnionStep): |
|
268 """return intersection of results of child in-memory steps (e.g. OneFetchStep / AggrStep)""" |
|
269 |
|
270 def execute(self): |
|
271 """execute this step""" |
|
272 result = set() |
|
273 for step in self.children: |
|
274 result &= frozenset(step.execute()) |
|
275 result = list(result) |
|
276 if self.offset: |
|
277 result = result[offset:] |
|
278 if self.limit: |
|
279 result = result[:limit] |
|
280 return result |
|
281 |
|
282 |
267 class UnionFetchStep(Step): |
283 class UnionFetchStep(Step): |
268 """union results of child steps using temporary tables (e.g. FetchStep)""" |
284 """union results of child steps using temporary tables (e.g. FetchStep)""" |
269 |
285 |
270 def execute(self): |
286 def execute(self): |
271 """execute this step""" |
287 """execute this step""" |
272 self.execute_children() |
288 self.execute_children() |
273 |
289 |
274 |
290 |
275 __all__ = ('FetchStep', 'AggrStep', 'UnionStep', 'UnionFetchStep') |
291 __all__ = ('FetchStep', 'AggrStep', 'UnionStep', 'UnionFetchStep', 'IntersectStep') |