You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by jl...@apache.org on 2022/11/04 23:41:58 UTC

[pinot] branch test-pagination updated (1a76a93eea -> 6473c38e1d)

This is an automated email from the ASF dual-hosted git repository.

jlli pushed a change to branch test-pagination
in repository https://gitbox.apache.org/repos/asf/pinot.git


 discard 1a76a93eea Add sample code to show how pagination protocol works in broker code
     new 6473c38e1d Add sample code to show how pagination protocol works in broker code

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (1a76a93eea)
            \
             N -- N -- N   refs/heads/test-pagination (6473c38e1d)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/pinot/broker/requesthandler/BaseBrokerRequestHandler.java | 1 +
 1 file changed, 1 insertion(+)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[pinot] 01/01: Add sample code to show how pagination protocol works in broker code

Posted by jl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jlli pushed a commit to branch test-pagination
in repository https://gitbox.apache.org/repos/asf/pinot.git

commit 6473c38e1decf1245d8b882fcbd7ca023172c461
Author: Jack Li(Analytics Engineering) <jl...@jlli-mn1.linkedin.biz>
AuthorDate: Fri Nov 4 16:39:28 2022 -0700

    Add sample code to show how pagination protocol works in broker code
---
 .../requesthandler/BaseBrokerRequestHandler.java   | 44 ++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BaseBrokerRequestHandler.java b/pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BaseBrokerRequestHandler.java
index 224f46c440..ee1aa8b73c 100644
--- a/pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BaseBrokerRequestHandler.java
+++ b/pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BaseBrokerRequestHandler.java
@@ -30,6 +30,8 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CompletionException;
 import java.util.concurrent.CompletionService;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.Executor;
@@ -284,6 +286,48 @@ public abstract class BaseBrokerRequestHandler implements BrokerRequestHandler {
       return new BrokerResponseNative(QueryException.getException(QueryException.SQL_PARSING_ERROR, e));
     }
 
+    if (Boolean.parseBoolean(pinotQuery.getQueryOptions().get("pagination"))) {
+      String tableName = TableNameBuilder.extractRawTableName(pinotQuery.getDataSource().getTableName());
+      // Step 1: Generate a pointer.
+      // TODO: a. add a method to generate a ID
+      //       b. replace the dummyInstanceId with a real one.
+      int hash = ("dummyInstanceId" + requestId + System.currentTimeMillis()).hashCode();
+      String pointer = tableName + "_" + hash;
+
+      // Step 2: TODO invoke pagination query initialization API.
+
+      // Step 3: Submit to query executor.
+      final SqlNodeAndOptions finalSqlNodeAndOptions = sqlNodeAndOptions;
+      // TODO: use an pool based executor as the 2nd parameter below.
+      CompletableFuture.supplyAsync(() -> {
+        try {
+          return handleRequest(requestId, query, pinotQuery, compilationStartTimeNs, finalSqlNodeAndOptions, request,
+              requesterIdentity, requestContext);
+        } catch (Exception e) {
+          throw new CompletionException(e);
+        }
+      }).thenApply(brokerResponseNative -> {
+        // Step 5: TODO invoke upload result API.
+
+        return null;
+      }).exceptionally(exception -> {
+        // Step 6: TODO Handle exception.
+        System.out.println();
+        return null;
+      });
+
+      // Step 4: TODO Put pointer only to the response and return.
+      return new BrokerResponseNative();
+    }
+
+    return handleRequest(requestId, query, pinotQuery, compilationStartTimeNs, sqlNodeAndOptions, request, requesterIdentity,
+        requestContext);
+  }
+
+  private BrokerResponseNative handleRequest(long requestId, String query, PinotQuery pinotQuery,
+      long compilationStartTimeNs, @Nullable SqlNodeAndOptions sqlNodeAndOptions, JsonNode request,
+      @Nullable RequesterIdentity requesterIdentity, RequestContext requestContext)
+      throws Exception {
     if (isLiteralOnlyQuery(pinotQuery)) {
       LOGGER.debug("Request {} contains only Literal, skipping server query: {}", requestId, query);
       try {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org