def consume(self, ctxt): self.consumeCall += 1 if (self.consumeCall % 2 == 1): commentOperator("nested join: materialize inner ", ctxt.codegen) self.tableName = "inner" + str(self.algExpr.opId) self.denseWrite = DenseWrite(self.algExpr.leftChild.outRelation, self.tableName, MaterializationType.TEMPTABLE, self.algExpr.leftChild.tupleNum, ctxt) elif (self.consumeCall % 2 == 0): commentOperator("nested join: loop inner ", ctxt.codegen) ctxt.codegen.currentKernel.addVar(self.denseWrite.numOut) self.innerTid = Variable.tidLit(self.denseWrite.getTable(), 0) ctxt.innerLoopCount += 1 with ScanLoop(self.innerTid, ScanType.INNER, True, self.denseWrite.getTable(), self.algExpr.leftChild.outRelation, self.algExpr, ctxt): with IfClause(ctxt.vars.activeVar, ctxt.codegen): emit( assign(ctxt.vars.activeVar, self.algExpr.condition.translate(ctxt)), ctxt.codegen) # call parent operator self.parent.consume(ctxt) ctxt.innerLoopCount -= 1
def produce(self, ctxt): algExpr = self.algExpr ctxt.vars.scanTid = Variable.tidLit(algExpr.table, algExpr.scanTableId) with ScanLoop(ctxt.vars.scanTid, ScanType.KERNEL, algExpr.isTempScan, self.algExpr.table, algExpr.outRelation, algExpr, ctxt): if self.algExpr.isTempScan: numOutVar = Variable.val(CType.INT, "nout_" + algExpr.table["name"]) ctxt.codegen.currentKernel.addVar(numOutVar) # call parent operator self.parent.consume(ctxt)
def consumeHashTable(self, ctxt): htmem = self.htmem ctxt.vars.scanTid = Variable.tidLit(htmem.getTable(self.algExpr.opId), self.algExpr.opId) self.algExpr.table = htmem.getTable(self.algExpr.opId) self.algExpr.scanTableId = 1 with ScanLoop(ctxt.vars.scanTid, ScanType.KERNEL, False, htmem.getTable(self.algExpr.opId), dict(), self.algExpr, ctxt): commentOperator("scan aggregation ht", self.algExpr.opId, ctxt.codegen) htmem.addToKernel(ctxt.codegen.currentKernel) if self.algExpr.doGroup: with IfClause(ctxt.vars.activeVar, ctxt.codegen): emit( assignAnd( ctxt.vars.activeVar, equals( member(htmem.ht.arrayAccess(ctxt.vars.scanTid), "lock.lock"), "OnceLock::LOCK_DONE")), ctxt.codegen) with IfClause(ctxt.vars.activeVar, ctxt.codegen): payl = Variable.val(self.payload.getType(), "payl") payl.declareAssign( member(htmem.ht.arrayAccess(ctxt.vars.scanTid), "payload"), ctxt.codegen) self.payload.dematerialize(payl, ctxt) with IfClause(ctxt.vars.activeVar, ctxt.codegen): htmem.dematerializeAggregationAttributes( ctxt.vars.scanTid, ctxt) for (id, att) in self.algExpr.avgAggregates.items(): count = self.algExpr.countAttr type = ctxt.codegen.langType(att.dataType) emit( assign( ctxt.attFile.access(att), div(ctxt.attFile.access(att), cast(type, ctxt.attFile.access(count)))), ctxt.codegen) # call parent operator self.parent.consume(ctxt)