Skip to content

Instantly share code, notes, and snippets.

@ersiny
Created March 12, 2015 10:59
Show Gist options
  • Save ersiny/a3ada6ea84aeb88491b2 to your computer and use it in GitHub Desktop.
Save ersiny/a3ada6ea84aeb88491b2 to your computer and use it in GitHub Desktop.
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();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment