Skip to content

refactor(spanner): add isDataAvailable to StreamingResultSet - #14685

Open
olavloite wants to merge 2 commits into
mainfrom
spanner-add-is-data-available
Open

olavloite wants to merge 2 commits into
mainfrom
spanner-add-is-data-available

Conversation

@olavloite

Copy link
Copy Markdown
Contributor

Add the isDataAvailable() streaming contract to StreamingResultSet and forward it through StreamingUtil and ForwardingResultSet.

This contract allows callers (such as AsyncResultSetImpl) to inspect whether a row, stream chunk, terminal EOF, or error is available immediately without blocking the calling thread on network I/O.

Key changes:

  • StreamingResultSet: Defined @InternalApi default boolean isDataAvailable(), returning true by default for backward compatibility with synchronous and non-streaming implementations.
  • StreamingUtil: Added null-safe static boolean isDataAvailable(ResultSet) to unwrap StreamingResultSet instances or default to true.
  • ForwardingResultSet: Overrode isDataAvailable() to delegate to the underlying result set.
  • Added comprehensive unit tests in StreamingUtilTest and ForwardingResultSetTest exercising all methods, delegation, try-with-resources lifecycle, and null handling.

Add the `isDataAvailable()` streaming contract to `StreamingResultSet` and forward it through `StreamingUtil` and `ForwardingResultSet`.

This contract allows callers (such as `AsyncResultSetImpl`) to inspect whether a row, stream chunk, terminal EOF, or error is available immediately without blocking the calling thread on network I/O.

Key changes:
- `StreamingResultSet`: Defined `@InternalApi default boolean isDataAvailable()`, returning `true` by default for backward compatibility with synchronous and non-streaming implementations.
- `StreamingUtil`: Added null-safe `static boolean isDataAvailable(ResultSet)` to unwrap `StreamingResultSet` instances or default to `true`.
- `ForwardingResultSet`: Overrode `isDataAvailable()` to delegate to the underlying result set.
- Added comprehensive unit tests in `StreamingUtilTest` and `ForwardingResultSetTest` exercising all methods, delegation, try-with-resources lifecycle, and null handling.
@olavloite
olavloite requested review from a team as code owners October 19, 2026 09:21

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the isDataAvailable() method to the StreamingResultSet interface, allowing callers to check if data is available to read immediately without blocking on network I/O. The default implementation returns true for backward compatibility. The change also updates ForwardingResultSet and StreamingUtil to support this new method, and adds comprehensive unit tests in ForwardingResultSetTest and StreamingUtilTest to verify the behavior. There are no review comments to address, and I have no additional feedback to provide.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant