def query(self, queryId, iterationId, queriesParameters): (eTime, result) = (-1, None) connection = self.getConnection() cursor = connection.cursor() self.prepareQuery(cursor, queryId, queriesParameters, iterationId == 0) oracleops.dropTable(cursor, self.resultTable, True) wkt = self.qp.wkt if self.qp.queryType == 'nn': g = loads(self.qp.wkt) wkt = dumps(g.buffer(self.qp.rad)) t0 = time.time() scaledWKT = wktops.scale(wkt, self.scaleX, self.scaleY, self.minX, self.minY) (mimranges, mxmranges) = self.quadtree.getMortonRanges(scaledWKT, self.mortonDistinctIn, maxRanges=MAXIMUM_RANGES) if len(mimranges) == 0 and len(mxmranges) == 0: logging.info('None morton range in specified extent!') return (eTime, result) self.hints = [] if not self.flatTableIOT: self.hints.append('INDEX(' + self.flatTable + ' ' + self.flatTable + '_IDX)') if self.qp.queryMethod != 'stream' and self.numProcessesQuery > 1 and self.parallelType != 'nati' and self.qp.queryType in ( 'rectangle', 'circle', 'generic'): return self.pythonParallelization(t0, mimranges, mxmranges) if self.numProcessesQuery > 1: self.hints.append('PARALLEL (' + str(self.numProcessesQuery) + ')') (query, queryArgs) = dbops.getSelectMorton( mimranges, mxmranges, self.qp, self.flatTable, self.addContainsCondition, self.colsDict, self.getHintStatement(self.hints)) if self.qp.queryMethod != 'stream': # disk or stat oracleops.mogrifyExecute( cursor, "CREATE TABLE " + self.resultTable + " AS " + query + "", queryArgs) (eTime, result) = dbops.getResult(cursor, t0, self.resultTable, self.colsDict, (not self.mortonDistinctIn), self.qp.columns, self.qp.statistics) else: sqlFileName = str(queryId) + '.sql' oracleops.createSQLFile(cursor, sqlFileName, query, queryArgs) result = oracleops.executeSQLFileCount( self.getConnectionString(False), sqlFileName) eTime = time.time() - t0 connection.close() return (eTime, result)
def query(self, queryId, iterationId, queriesParameters): (eTime, result) = (-1, None) connection = self.getConnection() cursor = connection.cursor() self.prepareQuery(cursor, queryId, queriesParameters, iterationId == 0) postgresops.dropTable(cursor, self.resultTable, True) wkt = self.qp.wkt if self.qp.queryType == 'nn': g = loads(self.qp.wkt) wkt = dumps(g.buffer(self.qp.rad)) t0 = time.time() scaledWKT = wktops.scale(wkt, self.scaleX, self.scaleY, self.minX, self.minY) (mimranges, mxmranges) = self.quadtree.getMortonRanges(scaledWKT, self.mortonDistinctIn, maxRanges=MAXIMUM_RANGES) if len(mimranges) == 0 and len(mxmranges) == 0: logging.info('None morton range in specified extent!') return (eTime, result) if self.numProcessesQuery > 1: if self.qp.queryMethod != 'stream' and self.qp.queryType in ( 'rectangle', 'circle', 'generic'): return self.pythonParallelization(t0, mimranges, mxmranges) else: logging.error( 'Python parallelization only available for disk queries (CTAS) which are not NN queries!' ) return (eTime, result) (query, queryArgs) = dbops.getSelectMorton(mimranges, mxmranges, self.qp, self.flatTable, self.addContainsCondition, self.DM_FLAT) if self.qp.queryMethod != 'stream': # disk or stat postgresops.mogrifyExecute( cursor, "CREATE TABLE " + self.resultTable + " AS " + query + "", queryArgs) (eTime, result) = dbops.getResult(cursor, t0, self.resultTable, self.DM_FLAT, (not self.mortonDistinctIn), self.qp.columns, self.qp.statistics) else: sqlFileName = str(queryId) + '.sql' postgresops.createSQLFile(cursor, sqlFileName, query, queryArgs) result = postgresops.executeSQLFileCount( self.getConnectionString(False, True), sqlFileName) eTime = time.time() - t0 connection.close() return (eTime, result)
def query(self, queryId, iterationId, queriesParameters): (eTime, result) = (-1, None) connection = self.getConnection() cursor = connection.cursor() self.prepareQuery(cursor, queryId, queriesParameters, iterationId == 0) postgresops.dropTable(cursor, self.resultTable, True) wkt = self.qp.wkt if self.qp.queryType == 'nn': g = loads(self.qp.wkt) wkt = dumps(g.buffer(self.qp.rad)) t0 = time.time() scaledWKT = wktops.scale(wkt, self.scaleX, self.scaleY, self.minX, self.minY) (mimranges,mxmranges) = self.quadtree.getMortonRanges(scaledWKT, self.mortonDistinctIn, maxRanges = MAXIMUM_RANGES) if len(mimranges) == 0 and len(mxmranges) == 0: logging.info('None morton range in specified extent!') return (eTime, result) if self.qp.queryType == 'nn': logging.error('NN queries not available!') return (eTime, result) if self.numProcessesQuery > 1: if self.qp.queryMethod != 'stream' and self.qp.queryType in ('rectangle','circle','generic') : return self.pythonParallelization(t0, mimranges, mxmranges) else: logging.error('Python parallelization only available for disk queries (CTAS) which are not NN queries!') return (eTime, result) (query, queryArgs) = self.getSelect(self.qp, mimranges, mxmranges) if self.qp.queryMethod != 'stream': # disk or stat postgresops.mogrifyExecute(cursor, "CREATE TABLE " + self.resultTable + " AS (" + query + ")", queryArgs) (eTime, result) = dbops.getResult(cursor, t0, self.resultTable, self.DM_FLAT, (not self.mortonDistinctIn), self.qp.columns, self.qp.statistics) else: sqlFileName = str(queryId) + '.sql' postgresops.createSQLFile(cursor, sqlFileName, query, queryArgs) result = postgresops.executeSQLFileCount(self.getConnectionString(False, True), sqlFileName) eTime = time.time() - t0 connection.close() return (eTime, result)
def query(self, queryId, iterationId, queriesParameters): (eTime, result) = (-1, None) connection = self.getConnection() cursor = connection.cursor() self.prepareQuery(cursor, queryId, queriesParameters, False) monetdbops.dropTable(cursor, self.resultTable, True) wkt = self.qp.wkt if self.qp.queryType == 'nn': g = loads(self.qp.wkt) wkt = dumps(g.buffer(self.qp.rad)) t0 = time.time() scaledWKT = wktops.scale(wkt, self.scaleX, self.scaleY, self.minX, self.minY) (mimranges, mxmranges) = self.quadtree.getMortonRanges(scaledWKT, self.mortonDistinctIn, maxRanges=MAXIMUM_RANGES) if len(mimranges) == 0 and len(mxmranges) == 0: logging.info('None morton range in specified extent!') return (eTime, result) (query, queryArgs) = dbops.getSelectMorton(mimranges, mxmranges, self.qp, self.flatTable, self.addContainsCondition, self.queryColsData) if self.qp.queryMethod != 'stream': # disk or stat monetdbops.mogrifyExecute( cursor, "CREATE TABLE " + self.resultTable + " AS " + query + " WITH DATA", queryArgs) (eTime, result) = dbops.getResult(cursor, t0, self.resultTable, self.DM_FLAT, True, self.qp.columns, self.qp.statistics) else: sqlFileName = str(queryId) + '.sql' monetdbops.createSQLFile(sqlFileName, query, queryArgs) result = monetdbops.executeSQLFileCount(self.dbName, sqlFileName) eTime = time.time() - t0 connection.close() return (eTime, result)
def query(self, queryId, iterationId, queriesParameters): (eTime, result) = (-1, None) connection = self.getConnection() cursor = connection.cursor() self.prepareQuery(cursor, queryId, queriesParameters, iterationId == 0) oracleops.dropTable(cursor, self.resultTable, True) wkt = self.qp.wkt if self.qp.queryType == 'nn': g = loads(self.qp.wkt) wkt = dumps(g.buffer(self.qp.rad)) t0 = time.time() scaledWKT = wktops.scale(wkt, self.scaleX, self.scaleY, self.minX, self.minY) (mimranges,mxmranges) = self.quadtree.getMortonRanges(scaledWKT, self.mortonDistinctIn, maxRanges = MAXIMUM_RANGES) if len(mimranges) == 0 and len(mxmranges) == 0: logging.info('None morton range in specified extent!') return (eTime, result) self.hints = [] if not self.flatTableIOT: self.hints.append('INDEX(' + self.flatTable + ' ' + self.flatTable + '_IDX)') if self.qp.queryMethod != 'stream' and self.numProcessesQuery > 1 and self.parallelType != 'nati' and self.qp.queryType in ('rectangle','circle','generic') : return self.pythonParallelization(t0, mimranges, mxmranges) if self.numProcessesQuery > 1: self.hints.append('PARALLEL (' + str(self.numProcessesQuery) + ')') (query, queryArgs) = dbops.getSelectMorton(mimranges, mxmranges, self.qp, self.flatTable, self.addContainsCondition, self.colsDict, self.getHintStatement(self.hints)) if self.qp.queryMethod != 'stream': # disk or stat oracleops.mogrifyExecute(cursor, "CREATE TABLE " + self.resultTable + " AS " + query + "", queryArgs) (eTime, result) = dbops.getResult(cursor, t0, self.resultTable, self.colsDict, (not self.mortonDistinctIn), self.qp.columns, self.qp.statistics) else: sqlFileName = str(queryId) + '.sql' oracleops.createSQLFile(cursor, sqlFileName, query, queryArgs) result = oracleops.executeSQLFileCount(self.getConnectionString(False), sqlFileName) eTime = time.time() - t0 connection.close() return (eTime, result)
def query(self, queryId, iterationId, queriesParameters): (eTime, result) = (-1, None) connection = self.getConnection() cursor = connection.cursor() self.prepareQuery(cursor, queryId, queriesParameters, False) monetdbops.dropTable(cursor, self.resultTable, True) wkt = self.qp.wkt if self.qp.queryType == "nn": g = loads(self.qp.wkt) wkt = dumps(g.buffer(self.qp.rad)) t0 = time.time() scaledWKT = wktops.scale(wkt, self.scaleX, self.scaleY, self.minX, self.minY) (mimranges, mxmranges) = self.quadtree.getMortonRanges( scaledWKT, self.mortonDistinctIn, maxRanges=MAXIMUM_RANGES ) if len(mimranges) == 0 and len(mxmranges) == 0: logging.info("None morton range in specified extent!") return (eTime, result) (query, queryArgs) = dbops.getSelectMorton( mimranges, mxmranges, self.qp, self.flatTable, self.addContainsCondition, self.queryColsData ) if self.qp.queryMethod != "stream": # disk or stat monetdbops.mogrifyExecute( cursor, "CREATE TABLE " + self.resultTable + " AS " + query + " WITH DATA", queryArgs ) (eTime, result) = dbops.getResult( cursor, t0, self.resultTable, self.DM_FLAT, True, self.qp.columns, self.qp.statistics ) else: sqlFileName = str(queryId) + ".sql" monetdbops.createSQLFile(sqlFileName, query, queryArgs) result = monetdbops.executeSQLFileCount(self.dbName, sqlFileName) eTime = time.time() - t0 connection.close() return (eTime, result)