private boolean visitBufferWithDelegate(List<T> list) throws K { boolean ret = v.visit(list); visitorAlwaysReturnedTrue &= ret; return ret; }
public static <T, K extends Exception> AbortingVisitor<Iterable<T>, K> batching(final AbortingVisitor<? super T, ? extends K> v) { return item -> { for (T t : item) { if (!v.visit(t)) { return false; } } return true; }; }
/** * Since a visitor is purely a consumer of values, it can be cast to a more specific type. If you have a * visitor than consumes Objects, it could also consume any other more specific type. * * @param <F> from type * @param <T> to type */ public static <F, T extends F, K extends Exception> AbortingVisitor<List<T>, K> wrapBatching(final AbortingVisitor<? super List<F>, ? extends K> v) { return item -> v.visit(Collections.<F>unmodifiableList(item)); }
@Override public <K extends Exception> boolean batchAccept(int batchSize, AbortingVisitor<? super List<T>, K> v) throws K { return v.visit(ImmutableList.of(t)); } });
/** * @deprecated in favor of {@link BatchingVisitableView#filter(Predicate)} */ @Deprecated public static <T, K extends Exception> AbortingVisitor<Iterable<T>, K> filterBatch( final AbortingVisitor<? super List<T>, K> v, final Predicate<? super T> p) { return item -> { List<T> list = ImmutableList.copyOf(Iterables.filter(item, p)); if (list.isEmpty()) { return true; } else { return v.visit(list); } }; }
@Override public <K extends Exception> boolean batchAccept( int batchSize, AbortingVisitor<? super List<RowResult<byte[]>>, K> visitor) throws K { boolean hitEnd = ret.batchAccept(batchSize, items -> { if (items.size() < batchSize) { reachedEndOfRange(tableRef, rangeRequest); } markRangeRead(tableRef, rangeRequest, items); return visitor.visit(items); }); if (hitEnd) { reachedEndOfRange(tableRef, rangeRequest); } return hitEnd; } };
@Override final public <K extends Exception> boolean batchAccept(int batchSize, AbortingVisitor<? super List<T>, K> v) throws K { Preconditions.checkArgument(batchSize > 0); if (v instanceof ConsistentVisitor) { @SuppressWarnings("unchecked") AbortingVisitor<List<T>, K> v2 = (AbortingVisitor<List<T>, K>) v; ConsistentVisitor<T, K> consistentVisitor = (ConsistentVisitor<T, K>) v2; Preconditions.checkState(consistentVisitor.visitorAlwaysReturnedTrue, "passed a visitor that has already said stop"); batchAcceptSizeHint(batchSize, consistentVisitor); return consistentVisitor.visitorAlwaysReturnedTrue; } AbstractBatchingVisitable.ConsistentVisitor<T, K> consistentVisitor = AbstractBatchingVisitable.ConsistentVisitor.create(batchSize, v); batchAcceptSizeHint(batchSize, consistentVisitor); if (consistentVisitor.visitorAlwaysReturnedTrue && !consistentVisitor.buffer.isEmpty()) { Preconditions.checkState(consistentVisitor.buffer.size() < batchSize); return v.visit(Collections.unmodifiableList(consistentVisitor.buffer)); } else { return consistentVisitor.visitorAlwaysReturnedTrue; } }
boolean proceed = v.visit(batch); visitTime.stop(); if (!proceed) {
public static <T, K extends Exception> AbortingVisitor<Iterable<T>, K> batching(final AbortingVisitor<? super T, ? extends K> v) { return item -> { for (T t : item) { if (!v.visit(t)) { return false; } } return true; }; }
private boolean visitBufferWithDelegate(List<T> list) throws K { boolean ret = v.visit(list); visitorAlwaysReturnedTrue &= ret; return ret; }
/** * Since a visitor is purely a consumer of values, it can be cast to a more specific type. If you have a * visitor than consumes Objects, it could also consume any other more specific type. * * @param <F> from type * @param <T> to type */ public static <F, T extends F, K extends Exception> AbortingVisitor<List<T>, K> wrapBatching(final AbortingVisitor<? super List<F>, ? extends K> v) { return item -> v.visit(Collections.<F>unmodifiableList(item)); }
@Override public <K extends Exception> boolean batchAccept(int batchSize, AbortingVisitor<? super List<T>, K> v) throws K { return v.visit(ImmutableList.of(t)); } });
/** * @deprecated in favor of {@link BatchingVisitableView#filter(Predicate)} */ @Deprecated public static <T, K extends Exception> AbortingVisitor<Iterable<T>, K> filterBatch( final AbortingVisitor<? super List<T>, K> v, final Predicate<? super T> p) { return item -> { List<T> list = ImmutableList.copyOf(Iterables.filter(item, p)); if (list.isEmpty()) { return true; } else { return v.visit(list); } }; }
@Override public <K extends Exception> boolean batchAccept( int batchSize, AbortingVisitor<? super List<RowResult<byte[]>>, K> visitor) throws K { boolean hitEnd = ret.batchAccept(batchSize, items -> { if (items.size() < batchSize) { reachedEndOfRange(tableRef, rangeRequest); } markRangeRead(tableRef, rangeRequest, items); return visitor.visit(items); }); if (hitEnd) { reachedEndOfRange(tableRef, rangeRequest); } return hitEnd; } };
@Override final public <K extends Exception> boolean batchAccept(int batchSize, AbortingVisitor<? super List<T>, K> v) throws K { Preconditions.checkArgument(batchSize > 0); if (v instanceof ConsistentVisitor) { @SuppressWarnings("unchecked") AbortingVisitor<List<T>, K> v2 = (AbortingVisitor<List<T>, K>) v; ConsistentVisitor<T, K> consistentVisitor = (ConsistentVisitor<T, K>) v2; Preconditions.checkState(consistentVisitor.visitorAlwaysReturnedTrue, "passed a visitor that has already said stop"); batchAcceptSizeHint(batchSize, consistentVisitor); return consistentVisitor.visitorAlwaysReturnedTrue; } AbstractBatchingVisitable.ConsistentVisitor<T, K> consistentVisitor = AbstractBatchingVisitable.ConsistentVisitor.create(batchSize, v); batchAcceptSizeHint(batchSize, consistentVisitor); if (consistentVisitor.visitorAlwaysReturnedTrue && !consistentVisitor.buffer.isEmpty()) { Preconditions.checkState(consistentVisitor.buffer.size() < batchSize); return v.visit(Collections.unmodifiableList(consistentVisitor.buffer)); } else { return consistentVisitor.visitorAlwaysReturnedTrue; } }
boolean proceed = v.visit(batch); visitTime.stop(); if (!proceed) {