rishabhdaim commented on code in PR #2146: URL: https://github.com/apache/jackrabbit-oak/pull/2146#discussion_r1984714276
########## oak-store-spi/src/main/java/org/apache/jackrabbit/oak/plugins/memory/PropertyStates.java: ########## @@ -89,7 +90,7 @@ public static PropertyState createProperty( String name, Iterable<Value> values) throws RepositoryException { int type = PropertyType.STRING; - Value first = Iterables.getFirst(values, null); + Value first = StreamUtils.toStream(values).findFirst().orElse(null); Review Comment: Thanks, @nfsantos for the review. I measured the performance of 3 implementations (using JMH) for: 1. Guava's 2. Stream 3. Apache commons Please find the results below: Code is: `@Benchmark public void guava(Blackhole bh) { bh.consume(Iterables.getFirst(itr, bh)); } @Benchmark public void apache(Blackhole bh) { bh.consume(org.apache.commons.collections4.IterableUtils.first(itr)); } @Benchmark public void stream(Blackhole bh) { bh.consume(StreamSupport.stream(itr.spliterator(), false).findFirst().orElse(0)); }` Results `Benchmark (size) Mode Cnt Score Error Units IterableUtils.apache 1 avgt 4 0.001 ± 0.001 us/op IterableUtils.apache 100 avgt 4 0.001 ± 0.001 us/op IterableUtils.apache 10000 avgt 4 0.001 ± 0.001 us/op IterableUtils.guava 1 avgt 4 0.001 ± 0.001 us/op IterableUtils.guava 100 avgt 4 0.001 ± 0.001 us/op IterableUtils.guava 10000 avgt 4 0.001 ± 0.001 us/op IterableUtils.stream 1 avgt 4 0.008 ± 0.003 us/op IterableUtils.stream 100 avgt 4 0.007 ± 0.002 us/op IterableUtils.stream 10000 avgt 4 0.007 ± 0.002 us/op` Although the performance with Stream is a bit slow for getting `first`, that is not going to have a very drastic impact on overall OAK performance. But, we do have a better alternative in `commons-collections4`, I think we can go with that as well. Will update the PR to use Apache commons-collections4. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: oak-dev-unsubscr...@jackrabbit.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org