/** * The returned {@link CompletableFuture} completes when all reads are complete for this request * and the entire result has been accounted for on the client. While this method is named "all" it * really refers to retrieving all remaining items in the set. For large result sets it is * preferred to use {@link Iterator} or {@link Stream} options, as the results will be held in * memory at once. */ public CompletableFuture<List<Result>> all() { return readCompleted.thenApplyAsync( it -> { final List<Result> list = new ArrayList<>(); resultQueue.drainTo(list); return list; }, executor); }
/** * The returned {@link CompletableFuture} completes when the number of items specified are * available. The number returned will be equal to or less than that number. They will only be * less if the stream is completed and there are less than that number specified available. */ public CompletableFuture<List<Result>> some(final int items) { return resultQueue.await(items); }
/** Gets the number of items available on the client. */ public int getAvailableItemCount() { return resultQueue.size(); }