private CompletableFuture < IteratorBatch < T > > fetch ( int position ) { return openFuture . thenCompose ( initialBatch -> { if ( ! initialBatch . complete ( ) ) { return client . applyOn ( partitionId , service -> nextFunction . next ( service , initialBatch . id ( ) , position ) ) . thenCompose ( nextBatch -> { if ( nextBatch == null ) { return close ( ) . thenApply ( v -> null ) ; } return CompletableFuture . completedFuture ( nextBatch ) ; } ) ; } return CompletableFuture . completedFuture ( null ) ; } ) ; }
Fetches the next batch of entries from the cluster .