You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2022/05/31 10:43:34 UTC

[GitHub] [ignite-3] ptupitsyn commented on a diff in pull request #837: IGNITE-14972 Java thin: Implement SQL API

ptupitsyn commented on code in PR #837:
URL: https://github.com/apache/ignite-3/pull/837#discussion_r885485036


##########
modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/sql/ClientSqlCursorNextPageRequest.java:
##########
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.client.handler.requests.sql;
+
+import static org.apache.ignite.client.handler.requests.sql.ClientSqlCommon.packCurrentPage;
+
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.client.handler.ClientResourceRegistry;
+import org.apache.ignite.internal.client.proto.ClientMessagePacker;
+import org.apache.ignite.internal.client.proto.ClientMessageUnpacker;
+import org.apache.ignite.lang.IgniteException;
+import org.apache.ignite.lang.IgniteInternalCheckedException;
+import org.apache.ignite.sql.async.AsyncResultSet;
+
+/**
+ * Client SQL cursor next page request.
+ */
+public class ClientSqlCursorNextPageRequest {
+    /**
+     * Processes the request.
+     *
+     * @param in  Unpacker.
+     * @param out Packer.
+     * @return Future.
+     */
+    public static CompletableFuture<Void> process(
+            ClientMessageUnpacker in,
+            ClientMessagePacker out,
+            ClientResourceRegistry resources)
+            throws IgniteInternalCheckedException {
+        long resourceId = in.unpackLong();
+
+        AsyncResultSet asyncResultSet = resources.get(resourceId).get(AsyncResultSet.class);
+
+        return asyncResultSet.fetchNextPage()
+                .thenCompose(r -> {
+                    packCurrentPage(out, r);
+                    out.packBoolean(r.hasMorePages());
+
+                    if (!r.hasMorePages()) {
+                        try {
+                            resources.remove(resourceId);
+                        } catch (IgniteInternalCheckedException e) {
+                            throw new IgniteException(e);
+                        }

Review Comment:
   Good point. Actually, this checked exception only occurs when resource is already removed, or the registry is closed. There is no leak in any case. We can simply ignore the exception.



-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org