johnsolomonj commented on code in PR #16782:
URL: https://github.com/apache/pinot/pull/16782#discussion_r2338100317
##########
pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/Connection.java:
##########
@@ -205,4 +204,281 @@ public void close()
public PinotClientTransport<?> getTransport() {
return _transport;
}
+
+ // ========== Cursor Methods (Default implementations for backward
compatibility) ==========
+
+ /**
+ * Opens a cursor for paginated query execution using the Cursor Handle
Pattern.
+ * The returned cursor starts with the first page already loaded.
+ *
+ * @param query the query to execute
+ * @param pageSize the number of rows per page
+ * @return ResultCursor with the first page loaded and ready for navigation
+ * @throws PinotClientException If an exception occurs while processing the
query
+ */
+ public ResultCursor openCursor(String query, int pageSize) throws
PinotClientException {
+ // Select broker for cursor operation
+ String brokerHostPort = _brokerSelector.selectBroker((String) null);
+ if (brokerHostPort == null) {
+ throw new PinotClientException("Could not find broker to execute cursor
query");
+ }
+
+ try {
+ CursorAwareBrokerResponse initialResponse =
_transport.executeQueryWithCursor(brokerHostPort, query, pageSize);
+ if (initialResponse.hasExceptions() && _failOnExceptions) {
+ throw new PinotClientException("Query had processing exceptions: \n" +
initialResponse.getExceptions());
+ }
+
+ return new ResultCursorImpl(_transport, brokerHostPort, initialResponse,
_failOnExceptions);
+ } catch (UnsupportedOperationException e) {
+ throw new UnsupportedOperationException("Cursor operations not supported
by this connection type", e);
+ } catch (Exception e) {
+ throw new PinotClientException("Failed to open cursor", e);
+ }
+ }
+
+ /**
+ * Executes a query with cursor support for pagination.
+ *
+ * @deprecated Use openCursor(String, int) instead for better resource
management
+ * @param query the query to execute
+ * @param numRows the number of rows per page
+ * @return CursorResultSetGroup containing the first page and cursor metadata
+ * @throws PinotClientException If an exception occurs while processing the
query
+ */
+ @Deprecated
+ public CursorResultSetGroup executeCursorQuery(String query, int numRows)
throws PinotClientException {
+ // Select broker for the query
+ String[] tableNames = resolveTableName(query);
+ String brokerHostPort = _brokerSelector.selectBroker(tableNames);
+ if (brokerHostPort == null) {
+ throw new PinotClientException("Could not find broker to execute cursor
query");
+ }
+
+ try {
+ // Execute query with cursor support
+ CursorAwareBrokerResponse response =
_transport.executeQueryWithCursor(brokerHostPort, query, numRows);
+ if (response.hasExceptions() && _failOnExceptions) {
+ throw new PinotClientException("Query had processing exceptions: \n" +
response.getExceptions());
+ }
+
+ // Create cursor result set group
+ return new CursorResultSetGroup(response);
+ } catch (UnsupportedOperationException e) {
+ throw new UnsupportedOperationException("Cursor operations not supported
by this connection type", e);
+ } catch (Exception e) {
+ throw new PinotClientException("Failed to execute cursor query", e);
+ }
+ }
+
+ /**
+ * Executes a query with cursor support asynchronously.
+ *
+ * @param query The SQL query to execute
+ * @param pageSize The number of rows per page
+ * @return CompletableFuture containing CursorResultSet
+ */
+ public CompletableFuture<CursorResultSetGroup>
executeCursorQueryAsync(String query, int pageSize) {
Review Comment:
Resolved
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]