Source:
public CompletableFuture<List<ConnectorSplit>> getNextBatch(int maxSize) { checkState(!closed, "Provider is already closed"); ListenableFuture<List<ConnectorSplit>> future = queue.borrowBatchAsync(maxSize, internalSplits -> { ImmutableList.Builder<InternalHiveSplit> splitsToInsertBuilder = ImmutableList.builder(); ImmutableList.Builder<ConnectorSplit> resultBuilder = ImmutableList.builder(); int removedEstimatedSizeInBytes = 0; for (InternalHiveSplit internalSplit : internalSplits) { long maxSplitBytes = maxSplitSize.toBytes(); if (remainingInitialSplits.get() > 0) { if (remainingInitialSplits.getAndDecrement() > 0) { maxSplitBytes = maxInitialSplitSize.toBytes(); } } InternalHiveBlock block = internalSplit.currentBlock(); long splitBytes = min(maxSplitBytes, block.getEnd() - internalSplit.getStart()); resultBuilder.add(new HiveSplit( connectorId, databaseName, tableName, internalSplit.getPartitionName(), internalSplit.getPath(), internalSplit.getStart(), splitBytes, internalSplit.getFileSize(), internalSplit.getSchema(), internalSplit.getPartitionKeys(), block.getAddresses(), internalSplit.getBucketNumber(), internalSplit.isForceLocalScheduling(), (TupleDomain<HiveColumnHandle>) compactEffectivePredicate, transformValues(internalSplit.getColumnCoercions(), HiveTypeName::toHiveType))); internalSplit.increaseStart(splitBytes); if (internalSplit.isDone()) { removedEstimatedSizeInBytes += internalSplit.getEstimatedSizeInBytes(); } else { splitsToInsertBuilder.add(internalSplit); } } estimatedSplitSizeInBytes.addAndGet(-removedEstimatedSizeInBytes); ImmutableList<InternalHiveSplit> splitsToInsert = splitsToInsertBuilder.build(); ImmutableList<ConnectorSplit> result = resultBuilder.build(); bufferedInternalSplitCount.addAndGet(splitsToInsert.size() - result.size()); return new AsyncQueue.BorrowResult<>(splitsToInsert, result); }); if (throwable.get() != null) { return failedFuture(throwable.get()); } return toCompletableFuture(future); }

Target:
public CompletableFuture<List<ConnectorSplit>> getNextBatch(int maxSize) { checkState(!closed, "Provider is already closed"); ListenableFuture<List<ConnectorSplit>> future = queue.borrowBatchAsync(maxSize, internalSplits -> { ImmutableList.Builder<InternalHiveSplit> splitsToInsertBuilder = ImmutableList.builder(); ImmutableList.Builder<ConnectorSplit> resultBuilder = ImmutableList.builder(); int removedEstimatedSizeInBytes = 0; for (InternalHiveSplit internalSplit : internalSplits) { long maxSplitBytes = maxSplitSize.toBytes(); if (remainingInitialSplits.get() > 0) { if (remainingInitialSplits.getAndDecrement() > 0) { maxSplitBytes = maxInitialSplitSize.toBytes(); } } InternalHiveBlock block = internalSplit.currentBlock(); long splitBytes; if (internalSplit.isSplittable()) { splitBytes = min(maxSplitBytes, block.getEnd() - internalSplit.getStart()); } else { splitBytes = internalSplit.getEnd() - internalSplit.getStart(); } resultBuilder.add(new HiveSplit( databaseName, tableName, internalSplit.getPartitionName(), internalSplit.getPath(), internalSplit.getStart(), splitBytes, internalSplit.getFileSize(), internalSplit.getSchema(), internalSplit.getPartitionKeys(), block.getAddresses(), internalSplit.getBucketNumber(), internalSplit.isForceLocalScheduling(), (TupleDomain<HiveColumnHandle>) compactEffectivePredicate, transformValues(internalSplit.getColumnCoercions(), HiveTypeName::toHiveType))); internalSplit.increaseStart(splitBytes); if (internalSplit.isDone()) { removedEstimatedSizeInBytes += internalSplit.getEstimatedSizeInBytes(); } else { splitsToInsertBuilder.add(internalSplit); } } estimatedSplitSizeInBytes.addAndGet(-removedEstimatedSizeInBytes); List<InternalHiveSplit> splitsToInsert = splitsToInsertBuilder.build(); List<ConnectorSplit> result = resultBuilder.build(); bufferedInternalSplitCount.addAndGet(splitsToInsert.size() - result.size()); return new AsyncQueue.BorrowResult<>(splitsToInsert, result); }); if (throwable.get() != null) { return failedFuture(throwable.get()); } return toCompletableFuture(future); }