@SuppressWarnings("ObjectEquality") @Override public CompletableFuture<ConnectorSplitBatch> getNextBatch(ConnectorPartitionHandle partitionHandle, int maxSize) { if (!partitionHandle.equals(NOT_PARTITIONED)) { throw new IllegalArgumentException("partitionHandle must be NOT_PARTITIONED"); } int remainingSplits = splits.size() - offset; int size = Math.min(remainingSplits, maxSize); List<ConnectorSplit> results = splits.subList(offset, offset + size); offset += size; return completedFuture(new ConnectorSplitBatch(results, isFinished())); }
private Supplier<ConnectorSplitBatch> batchSupplier(int maxSize) { return () -> { ImmutableList.Builder<ConnectorSplit> list = ImmutableList.builder(); for (int i = 0; i < maxSize; i++) { if (Thread.currentThread().isInterrupted()) { throw new RuntimeException("Split batch fetch was interrupted"); } if (!iterator.hasNext()) { break; } list.add(createSplit(iterator.next())); } return new ConnectorSplitBatch(list.build(), isFinished()); }; }
checkState(nextToken.compareAndSet(currentToken, batch.getNextToken())); checkState(hasMoreData.compareAndSet(true, nextToken.get() != null)); return new ConnectorSplitBatch(splits, isFinished()); }, directExecutor()); resultFuture = catchingThriftException(resultFuture);
return new ConnectorSplitBatch(splits, splits.isEmpty() && queues.isFinished(bucketNumber)); return new ConnectorSplitBatch(splits, false);
@Override public CompletableFuture<ConnectorSplitBatch> getNextBatch(ConnectorPartitionHandle partitionHandle, int maxSize) { checkArgument(partitionHandle.equals(NOT_PARTITIONED), "partitionHandle must be NOT_PARTITIONED"); return notEmptyFuture .thenApply(x -> getBatch(maxSize)) .thenApply(splits -> new ConnectorSplitBatch(splits, isFinished())); }
@Override public CompletableFuture<ConnectorSplitBatch> getNextBatch(ConnectorPartitionHandle partitionHandle, int maxSize) { checkArgument(partitionHandle.equals(NOT_PARTITIONED), "partitionHandle must be NOT_PARTITIONED"); return notEmptyFuture .thenApply(x -> getBatch(maxSize)) .thenApply(splits -> new ConnectorSplitBatch(splits, isFinished())); }