AMashenkov commented on a change in pull request #739:
URL: https://github.com/apache/ignite-3/pull/739#discussion_r832995381
##########
File path:
modules/core/src/main/java/org/apache/ignite/internal/util/Cursor.java
##########
@@ -25,5 +25,38 @@
* @param <T> Type of elements.
*/
public interface Cursor<T> extends Iterator<T>, Iterable<T>, AutoCloseable {
+ /**
+ * Creates an iterator based cursor.
+ *
+ * @param it Iterator.
+ * @param <T> Type of elements in iterator.
+ * @return Cursor.
+ */
+ static <T> Cursor<T> fromIterator(Iterator<? extends T> it) {
+ return new Cursor<T>() {
+ /** {@inheritDoc} */
+ @Override
+ public void close() throws Exception {
+ // No-op.
+ }
+ /** {@inheritDoc} */
+ @Override
+ public Iterator<T> iterator() {
+ return this;
+ }
Review comment:
I guess, `Cursor extends Iterable` to make Cursor usage easier, e.g.
iteration via 'for' loop.
Does it make sense to make this implementation as a default in the Cursor
interface?
I suggest just move method "as is" from static nested class to outer
interface.
--
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]