Skip to content

Instantly share code, notes, and snippets.

Stream<MessageAndMetadata<byte[], byte[]>> stream = StreamSupport.stream(Spliterators.spliteratorUnknownSize(iterator, Spliterator.ORDERED), false);
while (true) {
stream.parallel().map(d -> {
byte[] value = d.message();
Message msg = message.newBuilderForType().mergeFrom(value, 0, value.length).build();
return 1; // I would actuall extract a field from the message and return it, keeping it simple here
}).sum();
}