예제 #1
0
def testEmit(query, name):
    LOG.info("compiling %s: %s", name, query)

    # Create a compiler object
    dlog = RACompiler()

    # parse the query
    dlog.fromDatalog(query)
    #print dlog.parsed
    LOG.info("logical: %s",dlog.logicalplan)

    dlog.optimize(target=GrappaAlgebra)

    LOG.info("physical: %s",dlog.physicalplan[0][1])

    # generate code in the target language
    code = ""
    code += comment("Query " + query)
    code += dlog.compile()

    with open(name+'.cpp', 'w') as f:
        f.write(code)
예제 #2
0
def testEmit(query, name):
    LOG.info("compiling %s: %s", name, query)

    # Create a compiler object
    dlog = RACompiler()

    # parse the query
    dlog.fromDatalog(query)
    #print dlog.parsed
    LOG.info("logical: %s", dlog.logicalplan)

    dlog.optimize(target=GrappaAlgebra)

    LOG.info("physical: %s", dlog.physicalplan[0][1])

    # generate code in the target language
    code = ""
    code += comment("Query " + query)
    code += dlog.compile()

    with open(name + '.cpp', 'w') as f:
        f.write(code)
예제 #3
0
# Compute the cluster centers. First, compute the server-local cluster centers
   CL(cid, avg(x) ) :- C(pid, cid), P(pid, x)

"""

query = """
A@*(x) :- R(x,y,z)
"""

query = """
smallTableJoin(x,z) :- smallTable(x,y),smallTable(y,z)
"""

def comment(s):
  print "/*\n%s\n*/" % str(s)

dlog = RACompiler()

dlog.fromDatalog(query)
print dlog.logicalplan

dlog.optimize(target=MyriaAlgebra, eliminate_common_subexpressions=False)

code = dlog.compile()
print code

# generate code in the target language
#print compile(physicalplan)
#compile(physicalplan)
print compile(physicalplan)