Beispiel #1
0
    def getLowCostMRQ(self, stop, _run=True):
	global count
	if len(self.child_list) == 0:
	#if len(self.child_list) == 0 and self.isBottom():
	    print "FINDROOT_BEGIN"
	    count = count + 1
	    #root_mrq = self.findRoot()
	    #root_mrq.__printAll__()
	    #root_mrq.postProcess()
	    #if root_mrq.id == [1] and root_mrq.child_list[0].id == [2, 3, 4, 5, 6, 7, 8, 9]:
	    #    root_mrq.__printAll__()
	    #	codegen.genCode(root_mrq, "testquery")
	    if count >= int(stop):
		root_mrq = self.findRoot()
		root_mrq.postProcess()
		#root_mrq.__printAll__()
		#op_list = codegen.genCode(root_mrq, "testquery")
		#op_id = [op.getID() for op in op_list]
		#print op_id
		codegen.run(root_mrq, "testquery", _run)
		exit(29)
		#return
	    #if root_mrq.getMRQCost() < cost:
	    #	mrq = copyMRQ(root_mrq)
	    #    print "END"
	    #    exit(29)
	    print "FINDROOT_END"
	    return
	if count >= int(stop):
	    return
	for child in self.child_list:
	    child.getLowCostMRQ(stop, _run)
	    if count >= int(stop):
		return
	    new_op = None
	    for i in range(1, 5):
		op1_child, op2_child = [], []
	        new_op = Op.merge(child, self, i, op1_child, op2_child)
		if new_op is not None:
		    new_op.getLowCostMRQ(stop, _run)
		    Op.detach(new_op, child, self, op1_child, op2_child)
Beispiel #2
0
import ast
import node
import schema
import util
import op
import codegen
import sys
import os
import config

if __name__ == "__main__":
    pwd = os.getcwd()
    _file = open("../test/10.xml", "r")
    schema = "../test/tpch.schema"
    pt = ast.astToQueryPlan(schema, _file)
    _file.close()
    mrq = node.planTreeToMRQ(pt)
    if len(sys.argv) < 2:
        print "./test.py [o/number] [r]"
        exit(0)
    _run = False
    if len(sys.argv) == 3 and sys.argv[2] == "r":
	_run = True
    if sys.argv[1] == "o":
        mrq.optimize()
        mrq.postProcess()
        filename = "testquery"
        codegen.run(mrq, filename, _run)
    else:
        mrq.getLowCostMRQ(sys.argv[1], _run)