You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by pt...@apache.org on 2022/05/30 15:16:25 UTC
[ignite-3] branch ignite-14972 updated: ClientSqlExecuteRequest cleanup
This is an automated email from the ASF dual-hosted git repository.
ptupitsyn pushed a commit to branch ignite-14972
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/ignite-14972 by this push:
new 1dd0435c6 ClientSqlExecuteRequest cleanup
1dd0435c6 is described below
commit 1dd0435c60fd7654b09982e2a0e87faacf8f0a90
Author: Pavel Tupitsyn <pt...@apache.org>
AuthorDate: Mon May 30 18:16:18 2022 +0300
ClientSqlExecuteRequest cleanup
---
.../requests/sql/ClientSqlExecuteRequest.java | 104 +++++++++++----------
1 file changed, 55 insertions(+), 49 deletions(-)
diff --git a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/sql/ClientSqlExecuteRequest.java b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/sql/ClientSqlExecuteRequest.java
index 199c5c6be..58ec320be 100644
--- a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/sql/ClientSqlExecuteRequest.java
+++ b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/sql/ClientSqlExecuteRequest.java
@@ -52,55 +52,8 @@ public class ClientSqlExecuteRequest {
IgniteSql sql,
ClientResourceRegistry resources) {
var tx = readTx(in, resources);
-
- SessionBuilder sessionBuilder = sql.sessionBuilder();
-
- if (!in.tryUnpackNil()) {
- sessionBuilder.defaultPageSize(in.unpackInt());
- }
-
- if (!in.tryUnpackNil()) {
- sessionBuilder.defaultSchema(in.unpackString());
- }
-
- if (!in.tryUnpackNil()) {
- sessionBuilder.defaultTimeout(in.unpackLong(), TimeUnit.MILLISECONDS);
- }
-
- var propCount = in.unpackMapHeader();
-
- for (int i = 0; i < propCount; i++) {
- sessionBuilder.property(in.unpackString(), in.unpackObjectWithType());
- }
-
- // Session simply tracks active queries. We don't need to store it in resources.
- // Instead, we track active queries in the ClientSession and close them there accordingly.
- Session session = sessionBuilder.build();
-
- StatementBuilder statementBuilder = sql.statementBuilder();
-
- if (!in.tryUnpackNil()) {
- statementBuilder.defaultSchema(in.unpackString());
- }
- if (!in.tryUnpackNil()) {
- statementBuilder.pageSize(in.unpackInt());
- }
-
- statementBuilder.query(in.unpackString());
-
- if (!in.tryUnpackNil()) {
- statementBuilder.queryTimeout(in.unpackLong(), TimeUnit.MILLISECONDS);
- }
-
- statementBuilder.prepared(in.unpackBoolean());
-
- propCount = in.unpackMapHeader();
-
- for (int i = 0; i < propCount; i++) {
- statementBuilder.property(in.unpackString(), in.unpackObjectWithType());
- }
-
- Statement statement = statementBuilder.build();
+ Session session = readSession(in, sql);
+ Statement statement = readStatement(in, sql);
return session.executeAsync(tx, statement).thenCompose(asyncResultSet -> {
if (asyncResultSet.hasRowSet() && asyncResultSet.hasMorePages()) {
@@ -152,4 +105,57 @@ public class ClientSqlExecuteRequest {
return CompletableFuture.completedFuture(null);
});
}
+
+ private static Session readSession(ClientMessageUnpacker in, IgniteSql sql) {
+ SessionBuilder sessionBuilder = sql.sessionBuilder();
+
+ if (!in.tryUnpackNil()) {
+ sessionBuilder.defaultPageSize(in.unpackInt());
+ }
+
+ if (!in.tryUnpackNil()) {
+ sessionBuilder.defaultSchema(in.unpackString());
+ }
+
+ if (!in.tryUnpackNil()) {
+ sessionBuilder.defaultTimeout(in.unpackLong(), TimeUnit.MILLISECONDS);
+ }
+
+ var propCount = in.unpackMapHeader();
+
+ for (int i = 0; i < propCount; i++) {
+ sessionBuilder.property(in.unpackString(), in.unpackObjectWithType());
+ }
+
+ // NOTE: Session simply tracks active queries. We don't need to store it in resources.
+ // Instead, we track active queries in the ClientSession and close them there accordingly.
+ return sessionBuilder.build();
+ }
+
+ private static Statement readStatement(ClientMessageUnpacker in, IgniteSql sql) {
+ StatementBuilder statementBuilder = sql.statementBuilder();
+
+ if (!in.tryUnpackNil()) {
+ statementBuilder.defaultSchema(in.unpackString());
+ }
+ if (!in.tryUnpackNil()) {
+ statementBuilder.pageSize(in.unpackInt());
+ }
+
+ statementBuilder.query(in.unpackString());
+
+ if (!in.tryUnpackNil()) {
+ statementBuilder.queryTimeout(in.unpackLong(), TimeUnit.MILLISECONDS);
+ }
+
+ statementBuilder.prepared(in.unpackBoolean());
+
+ var propCount = in.unpackMapHeader();
+
+ for (int i = 0; i < propCount; i++) {
+ statementBuilder.property(in.unpackString(), in.unpackObjectWithType());
+ }
+
+ return statementBuilder.build();
+ }
}