コード例 #1
0
  @Override
  public int getResultSize() {
    int accumulator;
    if (resultSize == null) {
      ClusteredQueryCommand command = ClusteredQueryCommand.getResultSize(hSearchQuery, cache);

      ClusteredQueryInvoker invoker = new ClusteredQueryInvoker(cache, asyncExecutor);
      List<QueryResponse> responses = invoker.broadcast(command);

      accumulator = 0;
      for (QueryResponse response : responses) {
        accumulator += response.getResultSize();
      }
      resultSize = Integer.valueOf(accumulator);
    } else {
      accumulator = resultSize.intValue();
    }
    return accumulator;
  }
コード例 #2
0
  private HashMap<UUID, ClusteredTopDocs> broadcastQuery(ClusteredQueryCommand command) {
    ClusteredQueryInvoker invoker = new ClusteredQueryInvoker(cache, asyncExecutor);

    HashMap<UUID, ClusteredTopDocs> topDocsResponses = new HashMap<UUID, ClusteredTopDocs>();
    int resultSize = 0;
    List<QueryResponse> responses = invoker.broadcast(command);

    for (Object response : responses) {
      QueryResponse queryResponse = (QueryResponse) response;
      ClusteredTopDocs topDocs =
          new ClusteredTopDocs(queryResponse.getTopDocs(), queryResponse.getNodeUUID());

      resultSize += queryResponse.getResultSize();
      topDocs.setNodeAddress(queryResponse.getAddress());
      topDocsResponses.put(queryResponse.getNodeUUID(), topDocs);
    }

    this.resultSize = resultSize;
    return topDocsResponses;
  }