maedhroz commented on code in PR #4353:
URL: https://github.com/apache/cassandra/pull/4353#discussion_r2670375770
##########
src/java/org/apache/cassandra/utils/CloseableIterator.java:
##########
@@ -17,14 +17,29 @@
*/
package org.apache.cassandra.utils;
+import java.io.Closeable;
+import java.util.Collections;
import java.util.Iterator;
import java.util.NoSuchElementException;
+import org.apache.cassandra.io.util.FileUtils;
+
// so we can instantiate anonymous classes implementing both interfaces
public interface CloseableIterator<T> extends Iterator<T>, AutoCloseable
{
public void close();
+ CloseableIterator<Object> EMPTY =
CloseableIterator.wrap(Collections.emptyIterator());
+
+ /**
+ * Returns an empty {@link CloseableIterator}.
+ */
+ @SuppressWarnings("unchecked")
+ static <T> CloseableIterator<T> emptyIterator()
+ {
+ return (CloseableIterator<T>) EMPTY;
+ }
Review Comment:
Is this functionally equivalent to `empty()` below...just optimized to avoid
creating a new instance of `CloseableIterator`?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]