{@inheritDoc}

@throws QueryResultSizeExceededException if the size of this result
exceeds the result size limit.
199628
@Override
    public void add(QueryableEntry entry) {
        if (++resultSize > resultLimit) {
            throw new QueryResultSizeExceededException();
        }

        rows.add(orderAndLimitExpected ? entry : convertEntryToRow(entry));
    }
274680
private void orderResults(ResultSet cqlRows) throws InvalidRequestException
    {
        if (cqlRows.size() == 0 || !needsPostQueryOrdering())
            return;

        assert orderingIndexes != null;

        List<Integer> idToSort = new ArrayList<Integer>();
        List<Comparator<ByteBuffer>> sorters = new ArrayList<Comparator<ByteBuffer>>();

        for (ColumnIdentifier.Raw identifier : parameters.orderings.keySet())
        {
            ColumnDefinition orderingColumn = cfm.getColumnDefinition(identifier.prepare(cfm));
            idToSort.add(orderingIndexes.get(orderingColumn.name));
            sorters.add(orderingColumn.type);
        }

        Comparator<List<ByteBuffer>> comparator = idToSort.size() == 1
                                                ? new SingleColumnComparator(idToSort.get(0), sorters.get(0))
                                                : new CompositeComparator(sorters, idToSort);
        Collections.sort(cqlRows.rows, comparator);
    }
1258670
public void processResponse(Object result) {
        if (result instanceof JSObject) {
            MaxZoomResult mzr = new MaxZoomResult((JSObject) result);
            callback.maxZoomReceived(mzr);
        }
    }
428342
protected T getSingleResult(Query q) {
		try {
			@SuppressWarnings("unchecked")
			T retVal = (T) q.getSingleResult();
			return retVal;
		} catch (NoResultException e) {
			return null;
		}
	}
777622
protected void reportSizeLimitExceeded(final SizeLimitExceededException e, Validator validator) {
		validator.add(new I18nMessage("upload", "file.limit.exceeded", e.getActualSize(), e.getPermittedSize()));
		logger.warn("The file size limit was exceeded. Actual {} permitted {}", e.getActualSize(), e.getPermittedSize());
	}
658346
function queryChunkedData($query, $limit = 1000, $resultType = MYSQLI_ASSOC)
  {
    return new MySQLiChunkedResult($this, $query, $limit, $resultType);
  }
597527
private long calculateLimit(ScanQuery query, Map<String, Object> responseContext)
  {
    if (query.getOrder().equals(ScanQuery.Order.NONE)) {
      return query.getLimit() - (long) responseContext.get(ScanQueryRunnerFactory.CTX_COUNT);
    }
    return query.getLimit();
  }
267061
@Override
	public SqlEntityQuery<E> limit(final long limit) {
		if (!agent().getSqlConfig().getDialect().supportsLimitClause()) {
			throw new UroborosqlRuntimeException("Unsupported limit clause.");
		}
		this.limit = limit;
		return this;
	}
677311
private void processStorageQueryResult(List<AVIMMessage> cachedMessages,
                                         List<Boolean> breakpoints, String originMsgId, long originMsgTS, int limit,
                                         final AVIMMessagesQueryCallback callback) {

    final List<AVIMMessage> continuousMessages = new ArrayList<AVIMMessage>();
    int firstBreakPointIndex = -1;
    for (int index = 0; index < cachedMessages.size(); index++) {
      if (breakpoints.get(index)) {
        firstBreakPointIndex = index;
        break;
      } else {
        continuousMessages.add(cachedMessages.get(index));
      }
    }
    final boolean connected = AppConfiguration.getGlobalNetworkingDetector().isConnected();
    // 如果只是最后一个消息是breakPoint，那还走啥网络
    if (!connected || continuousMessages.size() >= limit/* - 1*/) {
      // in case of wifi is invalid, and thre query list contain breakpoint, the result is error.
      Collections.sort(continuousMessages, messageComparator);
      callback.internalDone(continuousMessages, null);
    } else {
      final int restCount;
      final AVIMMessage startMessage;
      if (!continuousMessages.isEmpty()) {
        // 这里是缓存里面没有breakPoint，但是limit不够的情况下
        restCount = limit - continuousMessages.size();
        startMessage = continuousMessages.get(continuousMessages.size() - 1);
      } else {
        startMessage = null;
        restCount = limit;
      }
      queryMessagesFromServer(startMessage == null ? originMsgId : startMessage.messageId,
              startMessage == null ? originMsgTS : startMessage.timestamp, restCount, null, 0,
              new AVIMMessagesQueryCallback() {
                @Override
                public void done(List<AVIMMessage> serverMessages, AVIMException e) {
                  if (e != null) {
                    // 不管如何，先返回缓存里面已有的有效数据
                    if (continuousMessages.size() > 0) {
                      callback.internalDone(continuousMessages, null);
                    } else {
                      callback.internalDone(e);
                    }
                  } else {
                    if (serverMessages == null) {
                      serverMessages = new ArrayList<AVIMMessage>();
                    }
                    continuousMessages.addAll(serverMessages);
                    processContinuousMessages(continuousMessages);
                    callback.internalDone(continuousMessages, null);
                  }
                }
              });
    }
  }
578094
@Override
    public boolean hasNext()
    {
        if (fetchSize != 0 && (count % fetchSize) == 0)
        {
            try
            {
                results = populateEntities(entityMetadata, client);
                count = 0;
            }
            catch (Exception e)
            {
                throw new PersistenceException("Error while scrolling over results, Caused by :.", e);
            }
        }
        if (results != null && !results.isEmpty() && count < results.size())
        {
            return true;
        }

        return false;
    }
835548
@SuppressWarnings( "deprecation" )
    @Override
    public org.modeshape.jcr.api.query.QueryResult execute() throws RepositoryException {
        context.checkValid();
        final long start = System.nanoTime();
        // Create an executable query and set it on this object ...
        CancellableQuery newExecutable = context.createExecutableQuery(query, hints, variables);
        CancellableQuery executable = executingQuery.getAndSet(newExecutable);
        if (executable == null) {
            // We are the first to call 'execute()', so use our newly-created one ...
            executable = newExecutable;
        }
        // otherwise, some other thread called execute, so we can use it and just wait for the results ...
        final QueryResults result = executable.execute(); // may be cancelled

        // And reset the reference to null (if not already set to something else) ...
        executingQuery.compareAndSet(executable, null);

        checkForProblems(result.getProblems());
        context.recordDuration(Math.abs(System.nanoTime() - start), TimeUnit.NANOSECONDS, statement, language);
        if (Query.XPATH.equals(language)) {
            return new XPathQueryResult(context, statement, result, hints.restartable, hints.rowsKeptInMemory);
        } else if (Query.SQL.equals(language)) {
            return new JcrSqlQueryResult(context, statement, result, hints.restartable, hints.rowsKeptInMemory);
        }
        return new JcrQueryResult(context, statement, result, hints.restartable, hints.rowsKeptInMemory);
    }
406037
public synchronized QueryResult execute() throws QueryException, InterruptedException {
		// create query string
		String queryString = createQueryString();

        PreparedStatement countPstmt = null;
        if (computeCount) {
            try {
                // count statement
                String countQueryString = "SELECT COUNT(*) FROM (" + queryString + ") A";
                if (isCsv) {
                	// csv jdbc driver does not support sub-select
                	countQueryString = getCsvCountQuery(queryString);
                }
                countPstmt = createStatement(countQueryString);
                if (parameterNames.size() != 0) {
                    setParameterValues(countPstmt);
                }
            } catch (QueryException ex) {
                LOG.info("Cannot create count statement : " + ex.getMessage() + " .Will use rs.last()");
                countPstmt = null;
            }
        }

        // create statement
		PreparedStatement pstmt = createStatement(queryString);

        // set parameter values
		if (parameterNames.size() != 0) {
			setParameterValues(pstmt);
		}
        
        try {
            setOutParametersValues(pstmt);
        } catch (SQLException e) {
            throw new QueryException(e);
        } catch (DialectException e) {
            throw new QueryException("Error set out parameter values for executing query : could not get dialect", e);
        }

        // set query's input wrapper
		synchronized (inputWrapper) {
			inputWrapper.statement = pstmt;
            inputWrapper.countStatement = countPstmt;
            inputWrapper.query = queryString;
			inputWrapper.pending = true;
			inputWrapper.notify();
		}

		synchronized (resultWrapper) {
			try {
				// wait for the query to complete
				while (!resultWrapper.serviced) {
					resultWrapper.wait();
				}
				if (resultWrapper.exception != null) {
					throw resultWrapper.exception;
				}
			} catch (InterruptedException e) {
				cancel();
				throw e;
			} finally {
				resultWrapper.serviced = false;
			}

			if ((maxRows > 0) && (resultWrapper.count > maxRows)) {
				resultWrapper.count = maxRows;
			}

			//must finish run method thread normally
			closeRequest = true;
			synchronized (inputWrapper) {
				inputWrapper.pending = true;
				inputWrapper.notify();
			}

			return new QueryResult(resultWrapper.resultSet, resultWrapper.count, resultWrapper.executeTime);
		}
	}
486161
protected QueryResult getQueryResult(QueryResponse queryResponse) {
        QueryResult queryResult = null;
        if (queryResponse != null) {
            queryResult = new QueryResult();
            queryResult.setEntities(getEntities(queryResponse));
            queryResult.setFault(queryResponse.getFault());
            queryResult.setMaxResults(queryResponse.getMaxResults());
            queryResult.setStartPosition(queryResponse.getStartPosition());
            queryResult.setTotalCount(queryResponse.getTotalCount());
        }

        return queryResult;
    }
1240086
private void enforceCpuLimits()
    {
        for (QueryExecution query : queryTracker.getAllQueries()) {
            Duration cpuTime = query.getTotalCpuTime();
            Duration sessionLimit = getQueryMaxCpuTime(query.getSession());
            Duration limit = Ordering.natural().min(maxQueryCpuTime, sessionLimit);
            if (cpuTime.compareTo(limit) > 0) {
                query.fail(new ExceededCpuLimitException(limit));
            }
        }
    }
284221
public T uniqueResult()
	{
		if (list == null || list.size() == 0)
			return null;
		else if (list.size() == 1)
			return list.get(0);
		else
			throw new IllegalArgumentException("Asked for unique result but resultset contained " + list.size() + " results!");
	}
1326870
public void evaluate(TupleQueryResultHandler resultHandler,long start, long pageLength) throws QueryEvaluationException, TupleQueryResultHandlerException {
        TupleQueryResult queryResult = evaluate(start,pageLength);
        if(queryResult.hasNext()){
            QueryResults.report(queryResult, resultHandler);
        }
        queryResult.close();
    }
134439
public function checkResult(Pjb62\Exception\JavaException $result): void
    {
        $exception = $this->getExceptionFromResult($result);
        throw $exception;
    }