public BiConsumer<List<T>, T> accumulator() {
        return (ts, t) -> {
            ts.add(t);
            if (ts.size() >= batchSize) {
                batchProcessor.accept(ts);
                recordsProcessed.addAndGet(ts.size());
                ts.clear();
            }
        };
    }
Creates a new batch collector

@param batchSize      the batch size after which the batchProcessor should be called
@param batchProcessor the batch processor which accepts batches of records to process
@param <T>            the type of elements being processed
@return a batch collector instance
stroom-util/src/main/java/stroom/util/collections/BatchingCollector.java