-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add stream method for ServerStream
#1575
Changes from all commits
67cd16c
96fdde8
387931a
beeccdf
e456efc
680b1c5
f3ce064
229d32b
c3fcd38
cf053db
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,8 @@ | |
|
||
import com.google.api.core.InternalApi; | ||
import java.util.Iterator; | ||
import java.util.stream.Stream; | ||
import java.util.stream.StreamSupport; | ||
import javax.annotation.Nonnull; | ||
|
||
/** | ||
|
@@ -89,6 +91,15 @@ public Iterator<V> iterator() { | |
return iterator; | ||
} | ||
|
||
/** | ||
* Returns a sequential {@code Stream} with server responses as its source. | ||
* | ||
* @return a sequential {@code Stream} over the elements in server responses | ||
*/ | ||
public Stream<V> stream() { | ||
return StreamSupport.stream(this.spliterator(), false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see that the second argument is set to false, which means this is a sequential stream, do we want to expose another There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure whether a deterministic result is required as parallel stream can randomize the result. Also, we could explore more about parallel stream later as we did in |
||
} | ||
|
||
/** | ||
* Returns true if the next call to the iterator's hasNext() or next() is guaranteed to be | ||
* nonblocking. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add Javadoc? All public methods are required to have Javadoc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done