private static <T> long countInternal(BatchingVisitable<T> visitable, int batchSize) { final long[] count = new long[1]; visitable.batchAccept(batchSize, AbortingVisitors.<T, RuntimeException>batching( item -> { count[0]++; return true; })); return count[0]; }
public static <T> boolean isEmpty(BatchingVisitable<T> v) { return v.batchAccept(1, AbortingVisitors.<T, RuntimeException>batching(AbortingVisitors.<T>alwaysFalse())); }
@Nullable public static <T> T getFirst(BatchingVisitable<T> visitable, @Nullable T defaultElement) { final Mutable<T> ret = Mutables.newMutable(defaultElement); visitable.batchAccept(1, AbortingVisitors.<T, RuntimeException>batching(item -> { ret.set(item); return false; })); return ret.get(); }
@Nullable public static <T> T getLast(BatchingVisitable<T> visitable, @Nullable T defaultElement) { final Mutable<T> ret = Mutables.newMutable(defaultElement); visitable.batchAccept(DEFAULT_BATCH_SIZE, AbortingVisitors.<T, RuntimeException>batching(item -> { ret.set(item); return true; })); return ret.get(); }
v.batchAccept( DEFAULT_BATCH_SIZE, AbortingVisitors.<T, RuntimeException>batching(new AbortingVisitor<T, RuntimeException>() { boolean hasSeenFirst = false; @Override
v.batchAccept( DEFAULT_BATCH_SIZE, AbortingVisitors.<T, RuntimeException>batching(new AbortingVisitor<T, RuntimeException>() { boolean hasSeenFirst = false; @Override
private byte[] internalCopyRange(BatchingVisitable<RowResult<byte[]>> bv, final long maxBytes, final Transaction txn) { final Mutable<byte[]> lastRowName = Mutables.newMutable(null); final MutableLong bytesPut = new MutableLong(0L); bv.batchAccept(readBatchSize, AbortingVisitors.batching( // Replacing this with a lambda results in an unreported exception compile error // even though no exception can be thrown :-( new AbortingVisitor<RowResult<byte[]>, RuntimeException>() { @Override public boolean visit(RowResult<byte[]> rr) throws RuntimeException { return TransactionRangeMigrator.this.internalCopyRow(rr, maxBytes, txn, bytesPut, lastRowName); } })); return lastRowName.get(); }
private byte[] internalCopyRange(BatchingVisitable<RowResult<byte[]>> bv, final long maxBytes, @Output final Map<Cell, byte[]> writeMap) { final Mutable<byte[]> lastRowName = Mutables.newMutable(null); final MutableLong bytesPut = new MutableLong(0L); bv.batchAccept(readBatchSize, AbortingVisitors.batching( // Replacing this with a lambda results in an unreported exception compile error // even though no exception can be thrown :-( new AbortingVisitor<RowResult<byte[]>, RuntimeException>() { @Override public boolean visit(RowResult<byte[]> rr) throws RuntimeException { return KvsRangeMigrator.this.internalCopyRow(rr, maxBytes, writeMap, bytesPut, lastRowName); } })); return lastRowName.get(); }
visitable.batchAccept(100, AbortingVisitors.batching((RowVisitor) item -> { MapEntries.putAll(vals, item.getCells()); if (Arrays.equals(item.getRowName(), "row1".getBytes())) {
final Map<Cell, byte[]> vals = Maps.newHashMap(); try { visitable.batchAccept(1, AbortingVisitors.batching((RowVisitor) item -> { try { latch.countDown();
@Test public void testConcat() { BatchingVisitable<Long> visitor = ListVisitor.create(Lists.newArrayList(0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L)); BatchingVisitableView<Long> limited = BatchingVisitableView.of(visitor).limit(3); BatchingVisitableView<Long> concat = BatchingVisitables.concat(limited, visitor); assertTrue("concatenated batchAccept should be true", concat.batchAccept(2, AbortingVisitors .batching(AbortingVisitors.alwaysTrue()))); }
private static <T> long countInternal(BatchingVisitable<T> visitable, int batchSize) { final long[] count = new long[1]; visitable.batchAccept(batchSize, AbortingVisitors.<T, RuntimeException>batching( item -> { count[0]++; return true; })); return count[0]; }
assertTrue("batchAccept should be true", limited.batchAccept(2, AbortingVisitors.batching(cv))); assertEquals("CountingVisitor had wrong count", 3, cv.count); assertTrue("batchAccept should be true", limited.batchAccept(3, AbortingVisitors.batching(cv))); assertEquals("CountingVisitor had wrong count", 6, cv.count); assertTrue("batchAccept should be true", limited.batchAccept(4, AbortingVisitors.batching(cv))); assertEquals("CountingVisitor had wrong count", 9, cv.count); assertFalse("batchAccept should be false", limited.batchAccept(1, AbortingVisitors.batching(lv))); lv = new LimitVisitor<>(4); assertTrue("batchAccept should be true", limited.batchAccept(1, AbortingVisitors.batching(lv))); lv = new LimitVisitor<>(2); assertFalse("batchAccept should be false", limited.batchAccept(1, AbortingVisitors.batching(lv)));
public static <T> boolean isEmpty(BatchingVisitable<T> v) { return v.batchAccept(1, AbortingVisitors.<T, RuntimeException>batching(AbortingVisitors.<T>alwaysFalse())); }
@Nullable public static <T> T getLast(BatchingVisitable<T> visitable, @Nullable T defaultElement) { final Mutable<T> ret = Mutables.newMutable(defaultElement); visitable.batchAccept(DEFAULT_BATCH_SIZE, AbortingVisitors.<T, RuntimeException>batching(item -> { ret.set(item); return true; })); return ret.get(); }
@Nullable public static <T> T getFirst(BatchingVisitable<T> visitable, @Nullable T defaultElement) { final Mutable<T> ret = Mutables.newMutable(defaultElement); visitable.batchAccept(1, AbortingVisitors.<T, RuntimeException>batching(item -> { ret.set(item); return false; })); return ret.get(); }
private byte[] internalCopyRange(BatchingVisitable<RowResult<byte[]>> bv, final long maxBytes, final Transaction txn) { final Mutable<byte[]> lastRowName = Mutables.newMutable(null); final MutableLong bytesPut = new MutableLong(0L); bv.batchAccept(readBatchSize, AbortingVisitors.batching( // Replacing this with a lambda results in an unreported exception compile error // even though no exception can be thrown :-( new AbortingVisitor<RowResult<byte[]>, RuntimeException>() { @Override public boolean visit(RowResult<byte[]> rr) throws RuntimeException { return TransactionRangeMigrator.this.internalCopyRow(rr, maxBytes, txn, bytesPut, lastRowName); } })); return lastRowName.get(); }
private byte[] internalCopyRange(BatchingVisitable<RowResult<byte[]>> bv, final long maxBytes, @Output final Map<Cell, byte[]> writeMap) { final Mutable<byte[]> lastRowName = Mutables.newMutable(null); final MutableLong bytesPut = new MutableLong(0L); bv.batchAccept(readBatchSize, AbortingVisitors.batching( // Replacing this with a lambda results in an unreported exception compile error // even though no exception can be thrown :-( new AbortingVisitor<RowResult<byte[]>, RuntimeException>() { @Override public boolean visit(RowResult<byte[]> rr) throws RuntimeException { return KvsRangeMigrator.this.internalCopyRow(rr, maxBytes, writeMap, bytesPut, lastRowName); } })); return lastRowName.get(); }
verifyTxManager.runTaskReadOnly((TransactionTask<Void, RuntimeException>) txn -> { BatchingVisitable<RowResult<byte[]>> bv = txn.getRange(name, RangeRequest.all()); bv.batchAccept(1000, AbortingVisitors.batching( new AbortingVisitor<RowResult<byte[]>, RuntimeException>() { @Override