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) if self.numProcessesQuery > 1 and self.parallelType != 'nati': if self.qp.queryType in ('rectangle', 'circle', 'generic'): return self.pythonParallelization() else: logging.error( 'Python parallelization only available for queries which are not NN!' ) return (eTime, result) t0 = time.time() query = self.getSelect() if self.qp.queryMethod != 'stream': # disk or stat oracleops.mogrifyExecute( cursor, "CREATE TABLE " + self.resultTable + " AS " + query) (eTime, result) = dbops.getResult(cursor, t0, self.resultTable, None, True, self.qp.columns, self.qp.statistics) else: sqlFileName = str(queryId) + '.sql' oracleops.createSQLFile(cursor, sqlFileName, query, None) 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) oracleops.dropTable(cursor, self.resultTable, True) if self.numProcessesQuery > 1 and self.parallelType != 'nati': if self.qp.queryType in ('rectangle','circle','generic') : return self.pythonParallelization() else: logging.error('Python parallelization only available for queries which are not NN!') return (eTime, result) t0 = time.time() query = self.getSelect() if self.qp.queryMethod != 'stream': # disk or stat oracleops.mogrifyExecute(cursor, "CREATE TABLE " + self.resultTable + " AS " + query) (eTime, result) = dbops.getResult(cursor, t0, self.resultTable, None, True, self.qp.columns, self.qp.statistics) else: sqlFileName = str(queryId) + '.sql' oracleops.createSQLFile(cursor, sqlFileName, query, None) 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) 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) 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)