Created
March 18, 2017 01:57
-
-
Save GaryQian/27f0aec47bf62da617a1b3f9842194ac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def processAllPages(self): | |
| self.initializeSchema() | |
| self.acc = dict() | |
| for (PageId, Page) in iter(self.subPlan): | |
| for Tuple in Page: | |
| # Load the lhs once per inner loop. | |
| val = self.loadSchema(self.subSchema, Tuple) | |
| ntup = self.subSchema.instantiate(*[val[f] for f in self.subSchema.fields]) | |
| expr = self.groupExpr(ntup) | |
| #self.printerr(expr) | |
| hash = self.groupHashFn((expr,0)) | |
| self.emitOutputTupleHash(Tuple, hash) | |
| for k in self.outputPageHash.keys(): | |
| acc = dict() | |
| for i,outSchema in enumerate(self.aggSchema.schema()): | |
| acc[outSchema[0]] = self.aggExprs[i][0] | |
| for pinfo in self.outputPageHash[k]: | |
| page = self.storage.bufferPool.getPage(pinfo[0]) | |
| for tup in page: | |
| val = self.loadSchema(self.subSchema, tup) | |
| temp = namedtuple('temp',val.keys()) | |
| l = list() | |
| for k in val.keys(): | |
| l.append(val[k]) | |
| ntup = temp._make(l) | |
| for i,outSchema in enumerate(self.groupSchema.schema()): | |
| acc[outSchema[0]] = self.groupExpr(ntup) | |
| for i,outSchema in enumerate(self.aggSchema.schema()): | |
| acc[outSchema[0]] = self.aggExprs[i][2](self.aggExprs[i][1](acc[outSchema[0]], ntup)) | |
| outputTuple = self.schema().instantiate(*[acc[f] for f in self.schema().fields]) | |
| self.printerr(outputTuple) | |
| self.emitOutputTuple(self.schema().pack(outputTuple)) | |
| if self.outputPages: | |
| self.outputPages = [self.outputPages[-1]] | |
| return self.storage.pages(self.relationId()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment