Executes a query asychronously, dynamically adjusting the fetch size down if necessary.
550496
public static ListenableFuture<ResultSet> executeAdaptiveQueryAsync(Session session, Statement statement, int fetchSize) {
        return executeAdaptiveQueryAsync(session, statement, fetchSize, MAX_ADAPTATIONS);
    }
577983
private void indexQuery(QueryEntry entry, ServerSessionContext session, CompletableFuture<QueryResponse> future) {
    // If the query index is greater than the session's last applied index, queue the request for handling once the
    // state machine is caught up.
    if (entry.getIndex() > session.getLastApplied()) {
      session.registerIndexQuery(entry.getIndex(), () -> applyQuery(entry, future));
    } else {
      applyQuery(entry, future);
    }
  }
697472
function runQuery(query, connection) {
  const params = {
    host: connection.host,
    port: connection.port ? connection.port : 5433,
    user: connection.username,
    password: connection.password,
    database: connection.database
  };

  return new Promise((resolve, reject) => {
    const client = vertica.connect(params, function(err) {
      if (err) {
        client.disconnect();
        return reject(err);
      }

      let incomplete = false;
      const rows = [];
      let finished = false;
      let columnNames = [];

      const verticaQuery = client.query(query);

      verticaQuery.on('fields', fields => {
        columnNames = fields.map(field => field.name);
      });

      verticaQuery.on('row', function(row) {
        if (rows.length < connection.maxRows) {
          const resultRow = {};
          row.forEach((value, index) => {
            resultRow[columnNames[index]] = value;
          });
          return rows.push(resultRow);
        }
        if (!finished) {
          finished = true;
          client.disconnect();
          incomplete = true;
          return resolve({ rows, incomplete });
        }
      });

      verticaQuery.on('end', function() {
        if (!finished) {
          finished = true;
          client.disconnect();
          return resolve({ rows, incomplete });
        }
      });

      verticaQuery.on('error', function(err) {
        if (!finished) {
          finished = true;
          client.disconnect();
          return reject(err);
        }
      });
    });
  });
}
277688
function runQuery(query, connection) {
  const incomplete = false;

  return new Promise((resolve, reject) => {
    const client = hdb.createClient({
      host: connection.host,
      port: connection.hanaport,
      database: connection.hanadatabase,
      user: connection.username,
      password: connection.password,
      schema: connection.hanaSchema
    });

    client.on('error', err => {
      console.error('Network connection error', err);
      return reject(err);
    });

    client.connect(err => {
      if (err) {
        console.error('Connect error', err);
        return reject(err);
      }
      return client.execute(query, function(err, rs) {
        let rows = [];

        if (err) {
          client.disconnect();
          return reject(err);
        }

        if (!rs) {
          client.disconnect();
          return resolve({ rows, incomplete });
        }

        if (!rs.createObjectStream) {
          // Could be row count or something
          client.disconnect();
          return resolve({ rows: [{ result: rs }], incomplete });
        }

        const stream = rs.createObjectStream();

        stream.on('data', data => {
          if (rows.length < connection.maxRows) {
            return rows.push(data);
          }
          client.disconnect();
          return resolve({ rows, incomplete: true });
        });

        stream.on('error', error => {
          client.disconnect();
          return reject(error);
        });

        stream.on('finish', () => {
          client.disconnect();
          return resolve({ rows, incomplete });
        });
      });
    });
  });
}
552653
private void indexQuery(
      long index,
      long timestamp,
      RaftSession session,
      PrimitiveOperation operation,
      CompletableFuture<OperationResult> future) {
    // If the query index is greater than the session's last applied index, queue the request for handling once the
    // state machine is caught up.
    if (index > currentIndex) {
      log.trace("Registering query with index " + index + " > " + currentIndex);
      session.registerIndexQuery(index, () -> applyQuery(timestamp, session, operation, future));
    } else {
      applyQuery(timestamp, session, operation, future);
    }
  }
1303295
def execute(self, limitRequest=350000, limitResMax=-1):
        """"""
        query = self.getQueries()
        query  = self.__buildLimit(query, limitResMax)
        nbr_results = limitResMax
        if (limitResMax == -1):
            query.setBaseUrl(self.__url+'/count')
            countUrl = query.getUrl()            
            result_count = Util.retrieveJsonResponseFromServer(countUrl)    
            nbr_results=result_count['total']
        else:
            nbr_results = limitResMax
        resultSearch = []
        if nbr_results < limitRequest :            
            query.setBaseUrl(self.__url+'/records')
            url = query.getUrl()
            startVal = query._getParameters()['start']
            while (nbr_results-startVal)>0 :#Do the job per 300 items till nbr_result is reached                
                resultTemp = Util.retrieveJsonResponseFromServer(url)
                resultSearch.extend(self.__parseResponse(resultTemp))
                parameters = query._getParameters()                
                startVal = parameters['start'] + parameters['limit']
                query = UpdateParameter(query, 'start', startVal) 
                query.setBaseUrl(self.__url+'/records')
		url=query.getUrl()            
        else:
            out_mess="Not allowed\nNbr results (%d) exceeds limit_request param: %d\n" % (nbr_results, limitRequest)
            self.__logger.info(out_mess)        
        return resultSearch
1021397
function(table, limit, page, query, fields)
    {
        if (this._doneLoading)
            return;

        var _this = this;

        // Execute -- add orderBy and ascending?
        var args = [table, limit, page, query, fields];
        if (this._orderBy) {
            args.push(this._orderBy);
            args.push(this._ascending);
        }

        var p = this.dataService.query.apply(this.dataService.query, args)

        // Pack results back into <T> and add it to our _results array
        .then(function(results) {
            results.forEach(function(r) {
                var obj = new _this._T();
                _(r).each(function(value, key) {
                    obj[key] = value;
                });
                _this._results.push(obj);
            });

            // If we hit the last page
            if (results.length !== limit)
                _this._doneLoading = true;

            return _this._results;
        });

        return p;
    }
1050810
def execute(self, query, args=None):
        
        self._ensure_conn()
        cur = self._conn.cursor()
        yield cur.execute(query, args)
        raise Return(cur)
1253040
def execute(self, query, vars=None, result=False):
        
        with self.connection() as cur:
            if self.debug:
                print(cur.mogrify(query, vars))

            resp = cur.execute(query, vars)

            if result == False:
                return resp

            else:
                columns = [i[0] for i in cur.description]
                results = cur.fetchall()
                return QueryResult(columns, results)
870682
def query(self, query, *parameters, **kwargs):
        """"""
        cursor = self._cursor()
        try:
            self._execute(cursor, query, parameters or None, kwargs)
            if cursor.description:
                column_names = [column.name for column in cursor.description]
                res = [Row(zip(column_names, row)) for row in cursor.fetchall()]
                cursor.close()
                return res
        except:
            cursor.close()
            raise
94163
def execute_query(self, query, session):
		'''  '''
		self.auto_ensure_indexes(query.type)

		kwargs = dict()
		if query._get_fields():
			if PYMONGO_3: # pragma: nocover
				kwargs['projection'] = query._fields_expression()
			else: # pragma: nocover
				kwargs['fields'] = query._fields_expression()

		collection = self.db[query.type.get_collection_name()]
		
		if query._search:
			index_fields = query._createIndex
			if index_fields:
				# create new index
				if type(index_fields) is list:
					index_list = []
					for field in index_fields:
						index_list.append ((field, pymongo.TEXT))
					collection.create_index(index_list, name='search_index', default_language='english')
				else:
					raise InvalidConfigException()
			cursor = collection.find(query.query, {'__index_score': {'$meta': "textScore"}}, **kwargs)
			cursor.sort([('__index_score', {'$meta': 'textScore'})])
		elif query._rawquery:
			if query._query_type=='aggregate':
				cursor = collection.aggregate(query.query, cursor={}, **kwargs)
			elif query._query_type=='map_reduce':
				cursor = collection.map_reduce( query._mapreduce_mapper, query._mapreduce_reducer, query._mapreduce_key, query=query._mapreduce_query)
		else:
			cursor = collection.find(query.query, **kwargs)

		if query._sort:
			cursor.sort(query._sort)
		elif query.type.config_default_sort:
			cursor.sort(query.type.config_default_sort)
		if query.hints:
			cursor.hint(query.hints)
		if query._get_limit() is not None:
			cursor.limit(query._get_limit())
		if query._get_skip() is not None:
			cursor.skip(query._get_skip())
		return QueryResult(session, cursor, query.type, raw_output=query._raw_output, fields=query._get_fields())
70057
public int executeUpdate(final String query) throws SQLException {
        startTimer();
        try {
            if (queryResult != null) {
                queryResult.close();
            }
            warningsCleared = false;
            if(inputStream == null)
                queryResult = protocol.executeQuery(queryFactory.createQuery(query));
            else 
                queryResult = protocol.executeQuery(queryFactory.createQuery(query), inputStream);
            return (int) ((ModifyQueryResult) queryResult).getUpdateCount();
        } catch (QueryException e) {
            throw SQLExceptionMapper.get(e);
        }
        finally
        {
            stopTimer();
            if(inputStream != null)
            {
                try
                {
                    inputStream.close();
                }
                catch (IOException e)
                {
                }
                inputStream = null;
            }
        }
    }
557485
def execute(self, query, params=None, cursor=None):
        
        conn = yield self._get_conn()
        try:
            cur = conn.cursor(cursor)
            yield cur.execute(query, params)
            yield cur.close()
        except:
            self._close_conn(conn)
            raise
        else:
            self._put_conn(conn)
        raise Return(cur)
965821
function()
    {
        if (this._executePromise)
            return this._executePromise;

        var q = this.clone();

        var table  = q._T.__name__;
        var page   = q._page;
        var fields = q._fields;

        // Create the query from our stuff
        var query = {};
        _(q._where.concat(q._like)).each(function (q) {
            query[q.key] = q.value;
        });

        var doneLoading      = Q.defer();
        this._executePromise = doneLoading.promise;

        var left = q._take;

        // A single iteration of fetching via the API. Called repeatedly in
        // the case of large / unbounded TAKES
        var loop = function() {

            // always take 1000 unless we're almost done
            var take = left < 1000 ? left : 1000;

            // Hit the API and incremement the page
            q._fetch(table, take, page++, query, fields).then(function(res) {

                // publish progress
                doneLoading.notify(q._results.length);

                if (left !== undefined) left -= res.length;

                // Either resolve the the promise with the results if we're
                // done or call the loop again

                if (q._doneLoading || left <= 0)
                    doneLoading.resolve(q._getResults());
                else
                    process.nextTick(loop);

            }).catch(function(err) {
                doneLoading.reject(err);
            });
        };

        // do tha damn thing
        loop();
        return doneLoading.promise;
    }
285589
public void loadFully(boolean skip, Protocol protocol) throws SQLException {
    if (fetchSize != 0) {
      fetchSize = 0;
      if (resultSet != null) {
        if (skip) {
          resultSet.close();
        } else {
          resultSet.fetchRemaining();
        }
      } else {
        SelectResultSet firstResult = executionResults.peekFirst();
        if (firstResult != null) {
          if (skip) {
            firstResult.close();
          } else {
            firstResult.fetchRemaining();
          }
        }
      }
    }

    if (protocol.hasMoreResults()) {
      protocol.getResult(this);
    }
  }
711580
def runQuery(self, *args, **kwargs):
        
        try:
            return self._connectionPool.runQuery(*args, **kwargs)
        except:
            d = defer.Deferred()
            d.errback()
            return d
665969
def fetch_in_batch(query, batch_size = 1000, &block)
      raise "No block given for the batch fetch request!" unless block_given?
      
      # Execute the query and check the result
      exec_result = execute(query)
      raise_error_if_failed!(exec_result)

      # Get search operation handle to fetch the results
      op_handle = exec_result.operationHandle

      # Prepare fetch results request
      fetch_req = prepare_fetch_results(op_handle, :next, batch_size)

      # Now let's iterate over the results
      loop do
        rows = fetch_rows(op_handle, :next, batch_size)
        break if rows.empty?
        yield rows
      end
    end