Package dev.grafeo.gwp
Class ResultCursor
java.lang.Object
dev.grafeo.gwp.ResultCursor
- All Implemented Interfaces:
AutoCloseable,Iterator<List<Object>>
Cursor over streaming result frames from an Execute RPC.
Implements Iterator over rows (each row is a List<Object>)
and AutoCloseable for use with try-with-resources.
This is a blocking cursor. Rows are consumed from the gRPC response stream
on demand. The cursor buffers rows from each RowBatch frame.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classSummary of a completed query execution. -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new ResultCursor wrapping a gRPC response stream. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Collect all remaining rows into a list.Get the column names from the result header.booleanhasNext()booleanCheck if the execution was successful.next()nextRow()Get the next row.longGet the number of rows affected.summary()Get the result summary.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemaining, remove
-
Constructor Details
-
ResultCursor
Create a new ResultCursor wrapping a gRPC response stream.- Parameters:
stream- the response stream iterator from an Execute RPC
-
-
Method Details
-
columnNames
Get the column names from the result header.Consumes frames from the stream if the header has not been received yet.
- Returns:
- the list of column names, or an empty list if no header
-
nextRow
Get the next row. Returnsnullwhen there are no more rows.- Returns:
- the next row as a list of native Java objects, or null if done
-
collectRows
Collect all remaining rows into a list.- Returns:
- all remaining rows
-
summary
Get the result summary. Consumes all remaining frames if needed.- Returns:
- the result summary, or null if the stream ended without one
-
isSuccess
public boolean isSuccess()Check if the execution was successful.- Returns:
- true if the result summary indicates success
-
rowsAffected
public long rowsAffected()Get the number of rows affected.- Returns:
- the row count, or 0 if no summary
-
hasNext
public boolean hasNext() -
next
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-