def runPostgis(numberOfExecutions):
    print('Starting postgresql (postgis) Benchmark')
    postgisDB = postgis.Postgis()
    postgisResults = postgisDB.runQueries(postgisqueries(), numberOfExecutions)
    postgisDB.disconnect()
    print('Finished postgresql (postgis) Benchmark')
    output.printSingleResult(postgisResults)
    return postgisResults
Example #2
0
def removeData(size):
    postgisDB = postgis.Postgis()
    postgisDB.removeLines(size)
    postgisDB.disconnect()

    # hanaDB = hana.Hana()
    # hanaDB.removePolygons(size)
    # hanaDB.disconnect()
Example #3
0
def initDb(db):
	if db == "mysql":
		return mysql.MySQL(), False
	elif db == "postgis" or db == "postgresql":
		return postgis.Postgis(), False
	elif db == "sqlite" or db == "spatialite":
		return spatialite.Spatialite('benchmark.db'), True
	elif db == "monetdb":
		return monet_db.Monet_db(), False
Example #4
0
def runPostgis(numberOfExecutions, areaPoints):
    print('Started postgis Benchmark')
    postgisDB = postgis.Postgis()
    areaString = postgisDB.polygonString(areaPoints)
    postgisResults = postgisDB.runQueries(postgisqueries(areaString),
                                          numberOfExecutions)
    postgisDB.disconnect()
    print('Finished postgis Benchmark')
    output.printSingleResult(postgisResults)
    return postgisResults
Example #5
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()
def initDestinationDb(destination_db):
    if destination_db == "postgis" or destination_db == "postgresql":
        db = postgis.Postgis()
        param = "%s"
        spatial_column_extra = False
        buffer_insteadof_string = False
        geomFunction = "ST_GeomFromText"
        return db, {
            'param': param,
            'spatial_column_extra': spatial_column_extra,
            'buffer_insteadof_string': buffer_insteadof_string,
            'geomFunction': geomFunction
        }
    elif destination_db == "spatialite" or destination_db == "sqlite":
        db = spatialite.Spatialite('benchmark.db')
        param = "?"
        spatial_column_extra = True
        buffer_insteadof_string = True
        init = 'SELECT InitSpatialMetadata()'
        db.cursor.execute(init)
        geomFunction = "ST_GeomFromText"
        return db, {
            'param': param,
            'spatial_column_extra': spatial_column_extra,
            'buffer_insteadof_string': buffer_insteadof_string,
            'geomFunction': geomFunction
        }
    elif destination_db == "monetdb":
        db = monet_db.Monet_db()
        param = "%s"
        spatial_column_extra = False
        buffer_insteadof_string = False
        geomFunction = "GeomFromText"
        return db, {
            'param': param,
            'spatial_column_extra': spatial_column_extra,
            'buffer_insteadof_string': buffer_insteadof_string,
            'geomFunction': geomFunction
        }
    else:
        print "The output database is not supported!"
        sys.exit(2)