Ejemplo n.º 1
0
def runMonetDB(numberOfExecutions, polygonID):
    print('Started MonetDB Benchmark')
    db = monetdb_db.Monetdb()
    results = db.runQueries(monetdbqueries(polygonID), numberOfExecutions)
    db.disconnect()
    print('Finished MonetDB Benchmark')
    output.printSingleResult(results)
    return results
Ejemplo n.º 2
0
def createPolygons(resetTables, sizes, areaLength):
    polygons = list()
    for i, polygonSize in enumerate(sizes):
        for x in range(0, int(math.ceil(numPolygons / len(sizes)))):
            polygonIsValid = False
            polygon = list()
            while not polygonIsValid:
                polygon = createPolygon(polygonSize, areaLength)
                # check whether they intersect:
                # hanaDB = hana.Hana()
                # polygonIsValid = hanaDB.isPolygonValid(polygon)
                # hanaDB.disconnect()
                postgisDB = postgis.Postgis()
                polygonIsValid = postgisDB.isPolygonValid(polygon)
                postgisDB.disconnect()
                # spatialiteDB = spatialite.Spatialite(':memory:')
                # polygonIsValid = spatialiteDB.isPolygonValid(polygon)
                # spatialiteDB.disconnect()
                # monetDB = monetdb_db.Monetdb()
                # polygonIsValid = monetDB.isPolygonValid(polygon)
                # monetDB.disconnect()
            polygons.append(polygon)
            if (x + i * int(math.ceil(numPolygons / len(sizes)))) % 100 == 99:
                print "finished: " + str(x + i *
                                         int(math.ceil(1000 / len(sizes))) + 1)

    print "Created valid Polygons"

    # mysqlDB = mysql.Mysql()
    # if resetTables: mysqlDB.dropCreateTable('POLYGONS')
    # mysqlDB.insertPolygons(polygons, offset)
    # mysqlDB.disconnect()

    # postgisDB = postgis.Postgis()
    # if resetTables: postgisDB.dropCreateTable('POLYGONS')
    # postgisDB.insertPolygons(polygons, offset)
    # postgisDB.disconnect()

    # hanaDB = hana.Hana()
    # if resetTables: hanaDB.dropCreateTable('BENCHMARK.POLYGONS')
    # hanaDB.insertPolygons(polygons, offset)
    # hanaDB.disconnect()

    # spatialiteDB = spatialite.Spatialite('benchmark.db')
    # if resetTables: spatialiteDB.dropCreateTable('POLYGONS')
    # spatialiteDB.insertPolygons(polygons, offset)
    # spatialiteDB.disconnect()

    monetDB = monetdb_db.Monetdb()
    if resetTables: monetDB.dropCreateTable('polygons')
    monetDB.insertPolygons(polygons, offset)
    monetDB.disconnect()
Ejemplo n.º 3
0
def run(numberOfExecutions):
    print "Polygons:\n"
    results = list()
    polygonID = 0
    monetDB = monetdb_db.Monetdb()
    query = "SELECT COUNT(*) FROM POLYGONS"
    monetDB.cursor.execute(query)
    result = monetDB.cursor.fetchall()
    for row in result:
        polygonID = int(random.random() * int(str(row[0])))

    # results.append(runMySQL(numberOfExecutions, str(polygonID)))
    # results.append(runPostgis(numberOfExecutions, [polygonID]))
    # results.append(runHana(numberOfExecutions, str(polygonID)))
    # results.append(runSpatialiteMain(numberOfExecutions, [polygonID]))
    results.append(runMonetDB(numberOfExecutions, str(polygonID)))

    print ""
    return results
Ejemplo n.º 4
0
def createPoints(areaLength):
    points = list()
    x = random.random() * 2 * areaLength - areaLength
    y = random.random() * 2 * areaLength - areaLength
    points.append({'x': x, 'y': y})
    points.append({'x': x, 'y': y})
    for i in range(0, numPoints - 2):
        x = random.random() * 2 * areaLength - areaLength
        y = random.random() * 2 * areaLength - areaLength
        points.append({'x': x, 'y': y})
        if i % 1000 == 999:
            print "finished: " + str(i + 1)

    # mysqlDB = mysql.Mysql()
    # mysqlDB.dropCreateTable('B_POINTS')
    # mysqlDB.insertPoints(points)
    # mysqlDB.disconnect()

    # postgisDB = postgis.Postgis()
    # postgisDB.dropCreateTable('B_POINTS')
    # postgisDB.insertPoints(points)
    # postgisDB.disconnect()

    # hanaDB = hana.Hana()
    # hanaDB.dropCreateTable('BENCHMARK.B_POINTS')
    # hanaDB.insertPoints(points)
    # hanaDB.disconnect()

    # spatialiteDB = spatialite.Spatialite('benchmark.db')
    # spatialiteDB.dropCreateTable('B_POINTS')
    # spatialiteDB.insertPoints(points)
    # spatialiteDB.disconnect()

    monetDB = monetdb_db.Monetdb()
    monetDB.dropCreateTable('points')
    monetDB.insertPoints(points)
    monetDB.disconnect()
Ejemplo n.º 5
0
def createLines(resetTables, sizes, areaLength):
    lines = list()
    for i, lineSize in enumerate(sizes):
        for x in range(0, int(math.ceil(numLines / len(sizes)))):
            line = createLine(lineSize, areaLength)
            lines.append(line)
            if (x + i * int(math.ceil(numLines / len(sizes)))) % 1000 == 999:
                print "finished: " + str(
                    x + i * int(math.ceil(numLines / len(sizes))) + 1)

    print "Created valid Lines"

    # mysqlDB = mysql.Mysql()
    # mysqlDB.dropCreateTable('B_LINES')
    # mysqlDB.insertLines(lines, offset)
    # mysqlDB.disconnect()

    # postgisDB = postgis.Postgis()
    # if resetTables: postgisDB.dropCreateTable('LINES')
    # postgisDB.insertLines(lines, offset)
    # postgisDB.disconnect()

    # hanaDB = hana.Hana()
    # if resetTables: hanaDB.dropCreateTable('BENCHMARK.LINES')
    # hanaDB.insertLines(lines, offset)
    # hanaDB.disconnect()

    # spatialiteDB = spatialite.Spatialite('benchmark.db')
    # if resetTables: spatialiteDB.dropCreateTable('LINES')
    # spatialiteDB.insertLines(lines, offset)
    # spatialiteDB.disconnect()

    monetDB = monetdb_db.Monetdb()
    if resetTables: monetDB.dropCreateTable('lines')
    monetDB.insertLines(lines, offset)
    monetDB.disconnect()