Пример #1
0
    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)

        t0 = time.time()
        (query, queryArgs) = dbops.getSelect(self.qp, self.flatTable,
                                             self.addContainsCondition,
                                             self.DM_FLAT)

        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)
Пример #2
0
    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)
Пример #3
0
 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)    
     
     t0 = time.time()
     (query, queryArgs) = dbops.getSelect(self.qp, self.flatTable, self.addContainsCondition, self.DM_FLAT)
     
     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, 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)