输入一个字符串
@param query
@param callback
490044
function (query, callback) {
    var stdin = process.openStdin();
    var all = '';
    process.stdout.write(query);
    var hidepass = function (char) {
        char = char + "";
        all += char;
        switch (char) {
            case "\n":
            case "\r":
            case "\u0003":
                stdin.removeListener('data', hidepass);
                if (callback !== undefined) {
                    callback(all);
                }
                break;
            case "\u0004":
                stdin.pause();
                break;
            default:
                if (paramObj.username === undefined) {
                    process.stdout.write("");
                } else {
                    process.stdout.write("\033[1D");
                }

                break;
        }
    };
    process.stdin.on("data", hidepass);
}
202483
<T> void query(Query<T> query, IOConsumer<T> f) throws IOException {
    run(() -> rw.run(query).forEachRemaining(IOConsumer.unchecked(f)));
  }
1335619
@Override
    public void search(final Query query) {
        getDispatcher().invokeLater(new AsyncTask(SEARCH, listeners) {
            @Override
            public void invoke(List<TwitterListener> listeners) throws TwitterException {
                QueryResult result = twitter.search(query);
                for (TwitterListener listener : listeners) {
                    try {
                        listener.searched(result);
                    } catch (Exception e) {
                        logger.warn("Exception at search", e);
                    }
                }
            }
        });
    }
905974
function query(queryString, args, callback) {
  getClient(function (err, client) {
    if (err) { callback(err); }

    if (!client) {
      callback('Could not connect to the database');
    }
    else {
      runQuery(client, queryString, args, callback);
    }
  });
}
95097
protected function run($query, $bindings, Closure $callback) {
        $start = microtime(true);

        // To execute the statement, we'll simply call the callback, which will actually
        // run the Cypher against the Orientdb connection. Then we can calculate the time it
        // took to execute and log the query Cypher, bindings and time in our memory.
        try {
            $result = $callback($this, $query, $bindings);
        }

        // If an exception occurs when attempting to run a query, we'll format the error
        // message to include the bindings with Cypher, which will make this exception a
        // lot more helpful to the developer instead of just the database's errors.
        catch (\Exception $e) {
            throw new QueryException($query, $bindings, $e);
        }

        // Once we have run the query we will calculate the time that it took to run and
        // then log the query, bindings, and execution time so we will report them on
        // the event that the developer needs them. We'll log time in milliseconds.
        $time = $this->getElapsedTime($start);

        $this->logQuery($query, $bindings, $time);

        return $result;
    }
238385
function query(base, q, callback) {
    // Added unescape to fix URI errors resulting from hexadecimal escape sequences
    var url = util.format("%s?%s", base, querystring.unescape(querystring.stringify(q)));
    request(url, function (err, response) {
        if (err) return callback(err);
        callback(null, response.body);
    });
}
204049
function(Collection, Query, callback) {
			if (typeof callback !== 'function') { throw Error('The callback function is a required parameter for Count.'); }
			do_database_call(Socket, DatabaseType, {
					collection: Collection,
					operation: 'Count',
					query: Query
				},
				callback);
			return;
		}
331731
function find(query, options, callback) {
    if (typeof options === 'function') {
      callback = options
      options = {}
    }

    self.emit('find', query, options)
    if (callback !== undefined) {
      findByQuery(query, options, function(error, data) {
        if (error) return callback(error)
        self.emit('received', data)
        callback(null, data)
      })
    } else {
      return findByQuery(query, options)
    }
  }
1173122
function formQuery(params, callback) {
  params = params || { query: {}};

  var query = formQueryLib.createFormQuery(params);
  var q = {
    _source : params.sourceFields || sourceFields,
    sort : params.sort || [
      { "timestamp" : {"order" : "desc"}},
    ],
    from: params.from || 0,
    size : querySize(params),
    query: query
  };
  if (params.query && params.query.terms) {
    q.highlight = { fields: {"title" : {}, "text" : {}}};
  }

  getEs().search({ _index : GLOBAL.config.ESEARCH._index, _type : 'contentItem'}, q, function(err, res) {
    if (err) {
      utils.passingError(err, params);

    } else {
      res.from = params.from || 0;
      res.query = q;
      if (!res || res.hits.hits.length < 1) {
        GLOBAL.debug('NO HITS FOR', JSON.stringify(q, null, 2));
      }
    }
    formQueryLib.filter(params.filters, res);
    callback(err, res);
  });
}
449636
private void handleLastDataPointQuery(final TSDB tsdb, final HttpQuery query) {
    
    final LastPointQuery data_query;
    if (query.method() == HttpMethod.POST) {
      switch (query.apiVersion()) {
      case 0:
      case 1:
        data_query = query.serializer().parseLastPointQueryV1();
        break;
      default: 
        throw new BadRequestException(HttpResponseStatus.NOT_IMPLEMENTED, 
            "Requested API version not implemented", "Version " + 
            query.apiVersion() + " is not implemented");
      }
    } else {
      data_query = this.parseLastPointQuery(tsdb, query);
    }
    
    if (data_query.sub_queries == null || data_query.sub_queries.isEmpty()) {
      throw new BadRequestException(HttpResponseStatus.BAD_REQUEST, 
          "Missing sub queries");
    }
    
    // a list of deferreds to wait on
    final ArrayList<Deferred<Object>> calls = new ArrayList<Deferred<Object>>();
    // final results for serialization
    final List<IncomingDataPoint> results = new ArrayList<IncomingDataPoint>();
    
    /**
     * Used to catch exceptions 
     */
    final class ErrBack implements Callback<Object, Exception> {
      public Object call(final Exception e) throws Exception {
        Throwable ex = e;
        while (ex.getClass().equals(DeferredGroupException.class)) {
          if (ex.getCause() == null) {
            LOG.warn("Unable to get to the root cause of the DGE");
            break;
          }
          ex = ex.getCause();
        }
        if (ex instanceof RuntimeException) {
          throw new BadRequestException(ex);
        } else {
          throw e;
        }
      }
      @Override
      public String toString() {
        return "Error back";
      }
    }
    
    final class FetchCB implements Callback<Deferred<Object>, ArrayList<IncomingDataPoint>> {
      @Override
      public Deferred<Object> call(final ArrayList<IncomingDataPoint> dps) throws Exception {
        synchronized(results) {
          for (final IncomingDataPoint dp : dps) {
            if (dp != null) {
              results.add(dp);
            }
          }
        }
        return Deferred.fromResult(null);
      }
      @Override
      public String toString() {
        return "Fetched data points CB";
      }
    }
    
    /**
     * Called after scanning the tsdb-meta table for TSUIDs that match the given
     * metric and/or tags. If matches were found, it fires off a number of
     * getLastPoint requests, adding the deferreds to the calls list
     */
    final class TSUIDQueryCB implements Callback<Deferred<Object>, ByteMap<Long>> {
      public Deferred<Object> call(final ByteMap<Long> tsuids) throws Exception {
        if (tsuids == null || tsuids.isEmpty()) {
          return null;
        }
        final ArrayList<Deferred<IncomingDataPoint>> deferreds =
            new ArrayList<Deferred<IncomingDataPoint>>(tsuids.size());
        for (Map.Entry<byte[], Long> entry : tsuids.entrySet()) {
          deferreds.add(TSUIDQuery.getLastPoint(tsdb, entry.getKey(), 
              data_query.getResolveNames(), data_query.getBackScan(), 
              entry.getValue()));
        }
        return Deferred.group(deferreds).addCallbackDeferring(new FetchCB());
      }
      @Override
      public String toString() {
        return "TSMeta scan CB";
      }
    }

    /**
     * Used to wait on the list of data point deferreds. Once they're all done
     * this will return the results to the call via the serializer
     */
    final class FinalCB implements Callback<Object, ArrayList<Object>> {
      public Object call(final ArrayList<Object> done) throws Exception {
        query.sendReply(query.serializer().formatLastPointQueryV1(results));
        return null;
      }
      @Override
      public String toString() {
        return "Final CB";
      }
    }
    
    try {   
      // start executing the queries
      for (final LastPointSubQuery sub_query : data_query.getQueries()) {
        final ArrayList<Deferred<IncomingDataPoint>> deferreds =
            new ArrayList<Deferred<IncomingDataPoint>>();
        // TSUID queries take precedence so if there are any TSUIDs listed, 
        // process the TSUIDs and ignore the metric/tags
        if (sub_query.getTSUIDs() != null && !sub_query.getTSUIDs().isEmpty()) {
          for (final String tsuid : sub_query.getTSUIDs()) {
            final TSUIDQuery tsuid_query = new TSUIDQuery(tsdb, 
                UniqueId.stringToUid(tsuid));
            deferreds.add(tsuid_query.getLastPoint(data_query.getResolveNames(), 
                data_query.getBackScan()));
          }
        } else {
          @SuppressWarnings("unchecked")
          final TSUIDQuery tsuid_query = 
              new TSUIDQuery(tsdb, sub_query.getMetric(), 
                  sub_query.getTags() != null ? 
                      sub_query.getTags() : Collections.EMPTY_MAP);
          if (data_query.getBackScan() > 0) {
            deferreds.add(tsuid_query.getLastPoint(data_query.getResolveNames(), 
                data_query.getBackScan()));
          } else {
            calls.add(tsuid_query.getLastWriteTimes()
                .addCallbackDeferring(new TSUIDQueryCB()));
          }
        }
        
        if (deferreds.size() > 0) {
          calls.add(Deferred.group(deferreds).addCallbackDeferring(new FetchCB()));
        }
      }
      
      Deferred.group(calls)
        .addCallback(new FinalCB())
        .addErrback(new ErrBack())
        .joinUninterruptibly();
      
    } catch (Exception e) {
      Throwable ex = e;
      while (ex.getClass().equals(DeferredGroupException.class)) {
        if (ex.getCause() == null) {
          LOG.warn("Unable to get to the root cause of the DGE");
          break;
        }
        ex = ex.getCause();
      }
      if (ex instanceof RuntimeException) {
        throw new BadRequestException(ex);
      } else {
        throw new RuntimeException("Shouldn't be here", e);
      }
    }
  }
641282
public String query(String query) {
        try {
            Connection conn = this.tx().getConnection();
            ObjectNode result = this.mapper.createObjectNode();
            ArrayNode dataNode = this.mapper.createArrayNode();
            ArrayNode metaNode = this.mapper.createArrayNode();
            Statement statement = conn.createStatement();
            if (logger.isDebugEnabled()) {
                logger.debug(query);
            }
            ResultSet rs = statement.executeQuery(query);
            ResultSetMetaData rsmd = rs.getMetaData();
            boolean first = true;
            while (rs.next()) {
                int numColumns = rsmd.getColumnCount();
                ObjectNode obj = this.mapper.createObjectNode();
                for (int i = 1; i < numColumns + 1; i++) {
                    String columnName = rsmd.getColumnLabel(i);
                    int type = rsmd.getColumnType(i);
                    //make sure to obtain array using getArray()
                    //At least in H2, this makes a difference...
                    Object o = type == Types.ARRAY ? rs.getArray(i) : rs.getObject(i);
                    this.sqlDialect.putJsonObject(obj, columnName, type, o);
                    if (first) {
                        this.sqlDialect.putJsonMetaObject(this.mapper, metaNode, columnName, type, o);
                    }
                }
                first = false;
                dataNode.add(obj);
            }
            result.set("data", dataNode);
            result.set("meta", metaNode);
            return result.toString();
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            this.tx().rollback();
        }
    }
927844
function count(query, callback) {
    self.emit('count', query)
    findByQuery(query, options, function (error, objects) {
      self.emit('received', objects.length)
      callback(undefined, objects.length)
    })
  }
1181155
function query(p, callback) {
		if (p.data) {
			extend(p.query, p.data);
			p.data = null;
		}

		callback(p.path);
	}
840171
protected function runQueryCallback($query, $bindings, Closure $callback)
    {
        // To execute the statement, we'll simply call the callback, which will actually
        // run the SQL against the PDO connection. Then we can calculate the time it
        // took to execute and log the query SQL, bindings and time in our memory.
        try {
            $result = $callback($query, $bindings);
        }

            // If an exception occurs when attempting to run a query, we'll format the error
            // message to include the bindings with SQL, which will make this exception a
            // lot more helpful to the developer instead of just the database's errors.
        catch (Exception $e) {
            throw new QueryException(
                $query, $bindings, $e
            );
        }

        return $result;
    }
164148
public void queryMessagesFromServer(int limit, final AVIMMessagesQueryCallback callback) {
    queryMessagesFromServer(null, 0, limit, null, 0, new AVIMMessagesQueryCallback() {
      @Override
      public void done(List<AVIMMessage> messages, AVIMException e) {
        if (null == e) {
          if (AVIMOptions.getGlobalOptions().isMessageQueryCacheEnabled()) {
            processContinuousMessages(messages);
          }
          callback.internalDone(messages, null);
        } else {
          callback.internalDone(null, e);
        }
      }
    });
  }
911355
public CqlQuery<K, N, V> setQuery(String query) {
    this.query = StringSerializer.get().toByteBuffer(query);
    return this;
  }
742282
public boolean handle(CallbackQuery query, int button) {
        if (button < 0 || button > buttons.size()) {
            return false;
        }

        buttonAt(button).handlePress(query);
        return true;
    }