You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "ebyhr (via GitHub)" <gi...@apache.org> on 2026/05/08 12:59:01 UTC

[PR] Core: Use toOptional and onlyElement methods in MoreCollectors [iceberg]

ebyhr opened a new pull request, #16254:
URL: https://github.com/apache/iceberg/pull/16254

   The existing `findFirst` silently hides multiple matching elements.
   
   This PR replaces it with Guava [MoreCollectors](https://www.javadoc.io/doc/com.google.guava/guava/latest/com/google/common/collect/MoreCollectors.html):
   
   onlyElement method: 
   > A collector that takes a stream containing exactly one element and returns that element. The returned collector throws an IllegalArgumentException if the stream consists of two or more elements, and a NoSuchElementException if the stream is empty.
   
   toOptional method: 
   > A collector that converts a stream of zero or one elements to an Optional.
   > Throws: IllegalArgumentException - if the stream consists of two or more elements.
   > Throws: NullPointerException - if any element in the stream is null.
   
   I only updated a few places to demonstrate how to use them. 


-- 
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: issues-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core: Use toOptional and onlyElement methods in MoreCollectors [iceberg]

Posted by "ebyhr (via GitHub)" <gi...@apache.org>.
ebyhr commented on PR #16254:
URL: https://github.com/apache/iceberg/pull/16254#issuecomment-4409204638

   @singhpk234 Yes, the same pattern persists even in non-test code. I've made additional modifications, and there are actually more places where this pattern occurs. 


-- 
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: issues-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core: Use toOptional and onlyElement methods in MoreCollectors [iceberg]

Posted by "ebyhr (via GitHub)" <gi...@apache.org>.
ebyhr commented on PR #16254:
URL: https://github.com/apache/iceberg/pull/16254#issuecomment-4541973198

   Closing as there has been no response for a while.


-- 
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: issues-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core: Use toOptional and onlyElement methods in MoreCollectors [iceberg]

Posted by "ebyhr (via GitHub)" <gi...@apache.org>.
ebyhr closed pull request #16254: Core: Use toOptional and onlyElement methods in MoreCollectors
URL: https://github.com/apache/iceberg/pull/16254


-- 
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: issues-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org