def mapInputAttribute(self, attr, table): dbIdent = table["name"] + "_" + attr.name attIdent = ident.iatt(attr) size = table["size"] charSize = 0 if attr.dataType == Type.STRING: charSize = table["charSizes"][attr.name] dbCol = self.inputColumns(attr, dbIdent, size, charSize) attCol = self.inputColumns(attr, attIdent, size, charSize) for a, db in zip(listWrap(attCol), listWrap(dbCol)): # base table attributes are currently always stored as FP32 if a.dataType == CType.FP64: a.dataType = CType.FP32 baseColFileSys = self.file(db) # add new gpu input column if baseColFileSys not in self.baseColumns: a.declarePointer(self.codegen.read) emit(assign(a, mmapFile(a.dataType, baseColFileSys)), self.codegen.read) self.codegen.gpumem.mapForRead(a) self.baseColumns[baseColFileSys] = a.getGPU() # gpu input column that was already used else: a.declarePointer(self.codegen.read) emit(assign(a, mmapFile(a.dataType, baseColFileSys)), self.codegen.read) self.codegen.gpumem.declare(a) emit(assign(a.getGPU(), self.baseColumns[baseColFileSys]), self.codegen.gpumem.cudaMalloc) self.codegen.currentKernel.addVar(a) self.locFile[attr.id] = AttributeLocation.TABLE self.incolFile[attr.id] = attCol
def __init__(self, ctxt, groupingIdentifiers, aggregates, child): UnaryAlgExpr.__init__(self, ctxt, child) self.groupingIdentifiers = listWrap(groupingIdentifiers) self.aggregates = listWrap(aggregates) self.aggregateTuplesCreated = OrderedDict() self.aggregateAttributes = dict() self.avgAggregates = dict() # add count for avg if necessary if any([agg[0] == Reduction.AVG for agg in aggregates]): if not any([agg[0] == Reduction.COUNT for agg in aggregates]): self.aggregates.append((Reduction.COUNT, "", "count_agg")) # create aggregation attributes for reductionType, inputIdentifier, aliasName in aggregates: id, aggAttr = ctxt.createAttribute(aliasName) aggAttr.dataType = Type.DOUBLE if reductionType == Reduction.COUNT: aggAttr.dataType = Type.INT self.countAttr = aggAttr self.aggregateAttributes[id] = aggAttr if reductionType == Reduction.AVG: self.avgAggregates[id] = aggAttr self.aggregateTuplesCreated[id] = (aggAttr, inputIdentifier, reductionType)
def showGraph ( self, plan ): from graphviz import Digraph plan = listWrap ( plan ) graph = Digraph () graph.graph_attr['rankdir'] = 'BT' for node in plan: node.toDOT ( graph ) graph.view()
def resolveAlgebraPlan ( self, plan, cfg ): plan = listWrap ( plan ) # add query result as root plan [ len ( plan ) - 1 ] = self.result ( plan [ len ( plan ) - 1 ] ) translationPlan = list() for node in plan: node.resolve ( self.ctxt ) attr = node.prune () num = node.configure ( cfg, self.ctxt ) return plan
def showGraph(self, plan): from graphviz import Digraph plan = listWrap(plan) graph = Digraph() graph.graph_attr['rankdir'] = 'BT' for node in plan: node.toDOT(graph) file = open("query.dot", "w") file.write(graph.source) graph.render("qplan")
def __init__ ( self, ctxt, identifiers, child ): UnaryAlgExpr.__init__ ( self, ctxt, child ) self.identifiers = listWrap ( identifiers )
def __init__ ( self, ctxt, joinType, equalityConditions, otherConditions, leftChild, rightChild ): BinaryAlgExpr.__init__ ( self, ctxt, leftChild, rightChild ) self.equalities = listWrap ( equalityConditions ) self.conditions = otherConditions self.joinType = joinType