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 14:27:12 UTC

[ignite-3] branch ignite-14972 updated: wip ClientStatementBuilder

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 af85dd2e3 wip ClientStatementBuilder
af85dd2e3 is described below

commit af85dd2e3f67053c163170aaf82215724eb62e72
Author: Pavel Tupitsyn <pt...@apache.org>
AuthorDate: Mon May 30 17:27:06 2022 +0300

    wip ClientStatementBuilder
---
 .../main/java/org/apache/ignite/sql/Statement.java |   7 ++
 .../internal/client/sql/ClientStatement.java       |  65 ++++++++++++
 .../client/sql/ClientStatementBuilder.java         | 111 +++++++++++++++++++++
 3 files changed, 183 insertions(+)

diff --git a/modules/api/src/main/java/org/apache/ignite/sql/Statement.java b/modules/api/src/main/java/org/apache/ignite/sql/Statement.java
index ec30821a7..e97456330 100644
--- a/modules/api/src/main/java/org/apache/ignite/sql/Statement.java
+++ b/modules/api/src/main/java/org/apache/ignite/sql/Statement.java
@@ -98,6 +98,13 @@ public interface Statement extends AutoCloseable {
          */
         StatementBuilder query(String sql);
 
+        /**
+         * Returns prepared flag.
+         *
+         * @return Prepared flag.
+         */
+        boolean prepared();
+
         /**
          * Marks current statement as prepared.
          */
diff --git a/modules/client/src/main/java/org/apache/ignite/internal/client/sql/ClientStatement.java b/modules/client/src/main/java/org/apache/ignite/internal/client/sql/ClientStatement.java
new file mode 100644
index 000000000..b15eb38c0
--- /dev/null
+++ b/modules/client/src/main/java/org/apache/ignite/internal/client/sql/ClientStatement.java
@@ -0,0 +1,65 @@
+/*
+ * 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.internal.client.sql;
+
+import java.util.concurrent.TimeUnit;
+import org.apache.ignite.sql.Statement;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+class ClientStatement implements Statement {
+    @Override
+    public @NotNull String query() {
+        return null;
+    }
+
+    @Override
+    public long queryTimeout(@NotNull TimeUnit timeUnit) {
+        return 0;
+    }
+
+    @Override
+    public String defaultSchema() {
+        return null;
+    }
+
+    @Override
+    public int pageSize() {
+        return 0;
+    }
+
+    @Override
+    public boolean prepared() {
+        return false;
+    }
+
+    @Override
+    public @Nullable Object property(@NotNull String name) {
+        return null;
+    }
+
+    @Override
+    public StatementBuilder toBuilder() {
+        return null;
+    }
+
+    @Override
+    public void close() throws Exception {
+
+    }
+}
diff --git a/modules/client/src/main/java/org/apache/ignite/internal/client/sql/ClientStatementBuilder.java b/modules/client/src/main/java/org/apache/ignite/internal/client/sql/ClientStatementBuilder.java
new file mode 100644
index 000000000..7eb6afe8d
--- /dev/null
+++ b/modules/client/src/main/java/org/apache/ignite/internal/client/sql/ClientStatementBuilder.java
@@ -0,0 +1,111 @@
+/*
+ * 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.internal.client.sql;
+
+import java.util.concurrent.TimeUnit;
+import org.apache.ignite.sql.Statement;
+import org.apache.ignite.sql.Statement.StatementBuilder;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+class ClientStatementBuilder implements Statement.StatementBuilder {
+    private String query;
+
+    private String defaultSchema;
+
+    private boolean prepared;
+
+    private long queryTimeoutMs;
+
+    private int pageSize;
+
+    @Override
+    public @NotNull String query() {
+        return query;
+    }
+
+    @Override
+    public StatementBuilder query(String sql) {
+        query = sql;
+
+        return this;
+    }
+
+    @Override
+    public boolean prepared() {
+        return prepared;
+    }
+
+    @Override
+    public StatementBuilder prepared(boolean prepared) {
+        this.prepared = prepared;
+
+        return this;
+    }
+
+    @Override
+    public long queryTimeout(@NotNull TimeUnit timeUnit) {
+        return timeUnit.convert(queryTimeoutMs, TimeUnit.MILLISECONDS);
+    }
+
+    @Override
+    public StatementBuilder queryTimeout(long timeout, @NotNull TimeUnit timeUnit) {
+        queryTimeoutMs = TimeUnit.MILLISECONDS.convert(timeout, timeUnit);
+
+        return this;
+    }
+
+    @Override
+    public String defaultSchema() {
+        return defaultSchema;
+    }
+
+    @Override
+    public StatementBuilder defaultSchema(@NotNull String schema) {
+        defaultSchema = schema;
+
+        return this;
+    }
+
+    @Override
+    public int pageSize() {
+        return pageSize;
+    }
+
+    @Override
+    public StatementBuilder pageSize(int pageSize) {
+        this.pageSize = pageSize;
+
+        return this;
+    }
+
+    @Override
+    public @Nullable Object property(@NotNull String name) {
+        return null;
+    }
+
+    @Override
+    public StatementBuilder property(@NotNull String name, @Nullable Object value) {
+        return null;
+    }
+
+    @Override
+    public Statement build() {
+        return null;
+    }
+}