Ejemplo n.º 1
0
 public static <T> BatchingVisitable<T> getOrderedVisitableUsingSublists(
     final OrderedSublistProvider<T> sublistProvider,
     @Inclusive final long startId,
     final Function<T, Long> idFunction) {
   BatchingVisitable<T> visitableWithDuplicates =
       new AbstractBatchingVisitable<T>() {
         @Override
         protected <K extends Exception> void batchAcceptSizeHint(
             int batchSizeHint, ConsistentVisitor<T, K> v) throws K {
           long nextId = startId;
           boolean abortedOrFinished = false;
           while (!abortedOrFinished) {
             List<T> resultBatchWithDuplicates =
                 sublistProvider.getBatchAllowDuplicates(nextId, batchSizeHint);
             boolean abortedByVisitor = !v.visit(resultBatchWithDuplicates);
             nextId = nextIdStart(resultBatchWithDuplicates, batchSizeHint, idFunction);
             boolean finishedAllBatches = nextId == -1L;
             abortedOrFinished = abortedByVisitor || finishedAllBatches;
           }
         }
       };
   return BatchingVisitables.unique(visitableWithDuplicates);
 }
Ejemplo n.º 2
0
 public static BatchingVisitable<Long> getOrderedVisitableUsingSublists(
     final OrderedSublistProvider<Long> sublistProvider, @Inclusive final long startId) {
   return BatchingVisitables.getOrderedVisitableUsingSublists(
       sublistProvider, startId, Functions.<Long>identity());
 }