- 6.102.0 (latest)
- 6.101.1
- 6.100.0
- 6.99.0
- 6.98.1
- 6.97.1
- 6.96.1
- 6.95.1
- 6.94.0
- 6.93.0
- 6.89.0
- 6.88.0
- 6.87.0
- 6.86.0
- 6.85.0
- 6.83.0
- 6.82.0
- 6.80.1
- 6.79.0
- 6.77.0
- 6.74.1
- 6.72.0
- 6.71.0
- 6.69.0
- 6.68.0
- 6.66.0
- 6.65.1
- 6.62.0
- 6.60.0
- 6.58.0
- 6.57.0
- 6.56.0
- 6.55.0
- 6.54.0
- 6.53.0
- 6.52.1
- 6.51.0
- 6.50.1
- 6.49.0
- 6.25.1
- 6.24.0
- 6.23.4
- 6.22.0
- 6.21.2
- 6.20.0
- 6.19.1
- 6.18.0
- 6.17.4
- 6.14.1
public interface ResultSet extends AutoCloseable, StructReaderProvides access to the data returned by a Cloud Spanner read or query. ResultSet allows a
single row to be inspected at a time through the methods from the StructReader interface,
in the order that the rows were returned by the read or query. The result set can be positioned
over the next row, if one exists, by calling #next(); this method returns false
when all rows returned have been seen. The result set is initially positioned before the first
row, so a call to next() is required before the first row can be inspected.
ResultSet implementations may buffer data ahead and/or maintain a persistent streaming
connection to the remote service until all data has been returned or the resultSet closed. As
such, it is important that all uses of ResultSet either fully consume it (that is, call
next() until false is returned or it throws an exception) or explicitly call
#close(): failure to do so may result in wasted work or leaked resources.
ResultSet implementations are not required to be thread-safe: if methods are called
from multiple threads, external synchronization must be used.
Methods
close()
public abstract void close()Explicitly close the result set, releasing any associated resources. This must always be called
when disposing of a ResultSet before #next() has returned false or
raised an exception. Calling close() is also allowed if the result set has been fully
consumed, so a recommended practice is to unconditionally close the result set once it is done
with, typically using a try-with-resources construct.
getCurrentRowAsStruct()
public abstract Struct getCurrentRowAsStruct()Creates an immutable version of the row that the result set is positioned over. This may
involve copying internal data structures, and so converting all rows to Struct objects
is generally more expensive than processing the ResultSet directly.
| Returns | |
|---|---|
| Type | Description |
Struct |
|
getMetadata()
public default ResultSetMetadata getMetadata()Returns the ResultSetMetadata for this ResultSet. This is method may only be called after calling ResultSet#next() at least once.
| Returns | |
|---|---|
| Type | Description |
ResultSetMetadata |
|
getStats()
public abstract ResultSetStats getStats()Returns the ResultSetStats for the query only if the query was executed in either the
PLAN or the PROFILE mode via the ReadContext#analyzeQuery(Statement,
com.google.cloud.spanner.ReadContext.QueryAnalyzeMode) method or for DML statements in ReadContext#executeQuery(Statement, QueryOption...). Attempts to call this method on a
ResultSet not obtained from analyzeQuery or executeQuery will return a
null ResultSetStats. This method must be called after #next() has
returned @{code false}. Calling it before that will result in null
ResultSetStats too.
| Returns | |
|---|---|
| Type | Description |
ResultSetStats |
|
next()
public abstract boolean next()Advances the result set to the next row, returning false if no such row exists. This method may block.
| Returns | |
|---|---|
| Type | Description |
boolean |
|
| Exceptions | |
|---|---|
| Type | Description |
SpannerException |
|