You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2022/04/25 15:07:16 UTC

[GitHub] [accumulo] DomGarguilo commented on a diff in pull request #2646: Replace iterator usage

DomGarguilo commented on code in PR #2646:
URL: https://github.com/apache/accumulo/pull/2646#discussion_r857735260


##########
test/src/main/java/org/apache/accumulo/test/mapreduce/AccumuloOutputFormatIT.java:
##########
@@ -164,11 +162,9 @@ public void testMR() throws Exception {
       assertNull(e1);
 
       try (Scanner scanner = c.createScanner(table2, new Authorizations())) {
-        Iterator<Entry<Key,Value>> iter = scanner.iterator();
-        assertTrue(iter.hasNext());
-        Entry<Key,Value> entry = iter.next();
-        assertEquals(Integer.parseInt(new String(entry.getValue().get())), 100);
-        assertFalse(iter.hasNext());
+        int actual = scanner.stream().map(Entry::getValue).map(Value::get).map(String::new)
+            .map(Integer::parseInt).collect(onlyElement());

Review Comment:
   Personally, it seems to be a bit more intuitive or readable, when using multiple `.map()` operations, to just keep with that pattern and do the `parseInt` within a `.map()` as well, even if it is slightly longer.



-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org