Skip to content

Instantly share code, notes, and snippets.

@GaryQian
Created March 18, 2017 01:57
Show Gist options
  • Select an option

  • Save GaryQian/27f0aec47bf62da617a1b3f9842194ac to your computer and use it in GitHub Desktop.

Select an option

Save GaryQian/27f0aec47bf62da617a1b3f9842194ac to your computer and use it in GitHub Desktop.
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