You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2022/12/22 08:41:26 UTC

[iotdb] branch ISessionDataSet1-0 created (now 36145341a8)

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

jackietien pushed a change to branch ISessionDataSet1-0
in repository https://gitbox.apache.org/repos/asf/iotdb.git


      at 36145341a8 Add ISessionDataSet interface

This branch includes the following new commits:

     new 36145341a8 Add ISessionDataSet interface

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.



[iotdb] 01/01: Add ISessionDataSet interface

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

jackietien pushed a commit to branch ISessionDataSet1-0
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 36145341a86d7563f8fb9ff67331dc20ab6ccd63
Author: JackieTien97 <ja...@gmail.com>
AuthorDate: Thu Dec 22 16:39:51 2022 +0800

    Add ISessionDataSet interface
---
 .../org/apache/iotdb/session/SessionDataSet.java   | 32 ++++++++++-
 .../org/apache/iotdb/session/IDataIterator.java    | 67 ++++++++++++++++++++++
 .../org/apache/iotdb/session/ISessionDataSet.java  | 44 ++++++++++++++
 3 files changed, 141 insertions(+), 2 deletions(-)

diff --git a/isession/src/main/java/org/apache/iotdb/session/SessionDataSet.java b/isession/src/main/java/org/apache/iotdb/session/SessionDataSet.java
index 55c6d4b5fb..9299ebecb2 100644
--- a/isession/src/main/java/org/apache/iotdb/session/SessionDataSet.java
+++ b/isession/src/main/java/org/apache/iotdb/session/SessionDataSet.java
@@ -37,7 +37,7 @@ import java.util.Map;
 
 import static org.apache.iotdb.rpc.IoTDBRpcDataSet.START_INDEX;
 
-public class SessionDataSet implements AutoCloseable {
+public class SessionDataSet implements ISessionDataSet {
 
   private final IoTDBRpcDataSet ioTDBRpcDataSet;
 
@@ -100,22 +100,27 @@ public class SessionDataSet implements AutoCloseable {
             timeout);
   }
 
+  @Override
   public int getFetchSize() {
     return ioTDBRpcDataSet.fetchSize;
   }
 
+  @Override
   public void setFetchSize(int fetchSize) {
     ioTDBRpcDataSet.fetchSize = fetchSize;
   }
 
+  @Override
   public List<String> getColumnNames() {
     return new ArrayList<>(ioTDBRpcDataSet.columnNameList);
   }
 
+  @Override
   public List<String> getColumnTypes() {
     return new ArrayList<>(ioTDBRpcDataSet.columnTypeList);
   }
 
+  @Override
   public boolean hasNext() throws StatementExecutionException, IoTDBConnectionException {
     return ioTDBRpcDataSet.next();
   }
@@ -176,6 +181,7 @@ public class SessionDataSet implements AutoCloseable {
     return new RowRecord(ioTDBRpcDataSet.time, outFields);
   }
 
+  @Override
   public RowRecord next() throws StatementExecutionException, IoTDBConnectionException {
     if (!ioTDBRpcDataSet.hasCachedRecord && !hasNext()) {
       return null;
@@ -185,6 +191,7 @@ public class SessionDataSet implements AutoCloseable {
     return constructRowRecordFromValueArray();
   }
 
+  @Override
   public void closeOperationHandle() throws StatementExecutionException, IoTDBConnectionException {
     try {
       ioTDBRpcDataSet.close();
@@ -193,6 +200,7 @@ public class SessionDataSet implements AutoCloseable {
     }
   }
 
+  @Override
   public DataIterator iterator() {
     return new DataIterator();
   }
@@ -202,84 +210,104 @@ public class SessionDataSet implements AutoCloseable {
     closeOperationHandle();
   }
 
-  public class DataIterator {
+  public class DataIterator implements IDataIterator {
 
+    @Override
     public boolean next() throws StatementExecutionException, IoTDBConnectionException {
       return ioTDBRpcDataSet.next();
     }
 
+    @Override
     public boolean isNull(int columnIndex) throws StatementExecutionException {
       return ioTDBRpcDataSet.isNull(columnIndex);
     }
 
+    @Override
     public boolean isNull(String columnName) throws StatementExecutionException {
       return ioTDBRpcDataSet.isNull(columnName);
     }
 
+    @Override
     public boolean getBoolean(int columnIndex) throws StatementExecutionException {
       return ioTDBRpcDataSet.getBoolean(columnIndex);
     }
 
+    @Override
     public boolean getBoolean(String columnName) throws StatementExecutionException {
       return ioTDBRpcDataSet.getBoolean(columnName);
     }
 
+    @Override
     public double getDouble(int columnIndex) throws StatementExecutionException {
       return ioTDBRpcDataSet.getDouble(columnIndex);
     }
 
+    @Override
     public double getDouble(String columnName) throws StatementExecutionException {
       return ioTDBRpcDataSet.getDouble(columnName);
     }
 
+    @Override
     public float getFloat(int columnIndex) throws StatementExecutionException {
       return ioTDBRpcDataSet.getFloat(columnIndex);
     }
 
+    @Override
     public float getFloat(String columnName) throws StatementExecutionException {
       return ioTDBRpcDataSet.getFloat(columnName);
     }
 
+    @Override
     public int getInt(int columnIndex) throws StatementExecutionException {
       return ioTDBRpcDataSet.getInt(columnIndex);
     }
 
+    @Override
     public int getInt(String columnName) throws StatementExecutionException {
       return ioTDBRpcDataSet.getInt(columnName);
     }
 
+    @Override
     public long getLong(int columnIndex) throws StatementExecutionException {
       return ioTDBRpcDataSet.getLong(columnIndex);
     }
 
+    @Override
     public long getLong(String columnName) throws StatementExecutionException {
       return ioTDBRpcDataSet.getLong(columnName);
     }
 
+    @Override
     public Object getObject(int columnIndex) throws StatementExecutionException {
       return ioTDBRpcDataSet.getObject(columnIndex);
     }
 
+    @Override
     public Object getObject(String columnName) throws StatementExecutionException {
       return ioTDBRpcDataSet.getObject(columnName);
     }
 
+    @Override
     public String getString(int columnIndex) throws StatementExecutionException {
       return ioTDBRpcDataSet.getString(columnIndex);
     }
 
+    @Override
     public String getString(String columnName) throws StatementExecutionException {
       return ioTDBRpcDataSet.getString(columnName);
     }
 
+    @Override
     public Timestamp getTimestamp(int columnIndex) throws StatementExecutionException {
       return ioTDBRpcDataSet.getTimestamp(columnIndex);
     }
 
+    @Override
     public Timestamp getTimestamp(String columnName) throws StatementExecutionException {
       return ioTDBRpcDataSet.getTimestamp(columnName);
     }
 
+    @Override
     public int findColumn(String columnName) {
       return ioTDBRpcDataSet.findColumn(columnName);
     }
diff --git a/session/src/main/java/org/apache/iotdb/session/IDataIterator.java b/session/src/main/java/org/apache/iotdb/session/IDataIterator.java
new file mode 100644
index 0000000000..7d17f390af
--- /dev/null
+++ b/session/src/main/java/org/apache/iotdb/session/IDataIterator.java
@@ -0,0 +1,67 @@
+/*
+ * 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.iotdb.session;
+
+import org.apache.iotdb.rpc.IoTDBConnectionException;
+import org.apache.iotdb.rpc.StatementExecutionException;
+
+import java.sql.Timestamp;
+
+public interface IDataIterator {
+
+  boolean next() throws StatementExecutionException, IoTDBConnectionException;
+
+  boolean isNull(int columnIndex) throws StatementExecutionException;
+
+  boolean isNull(String columnName) throws StatementExecutionException;
+
+  boolean getBoolean(int columnIndex) throws StatementExecutionException;
+
+  boolean getBoolean(String columnName) throws StatementExecutionException;
+
+  double getDouble(int columnIndex) throws StatementExecutionException;
+
+  double getDouble(String columnName) throws StatementExecutionException;
+
+  float getFloat(int columnIndex) throws StatementExecutionException;
+
+  float getFloat(String columnName) throws StatementExecutionException;
+
+  int getInt(int columnIndex) throws StatementExecutionException;
+
+  int getInt(String columnName) throws StatementExecutionException;
+
+  long getLong(int columnIndex) throws StatementExecutionException;
+
+  long getLong(String columnName) throws StatementExecutionException;
+
+  Object getObject(int columnIndex) throws StatementExecutionException;
+
+  Object getObject(String columnName) throws StatementExecutionException;
+
+  String getString(int columnIndex) throws StatementExecutionException;
+
+  String getString(String columnName) throws StatementExecutionException;
+
+  Timestamp getTimestamp(int columnIndex) throws StatementExecutionException;
+
+  Timestamp getTimestamp(String columnName) throws StatementExecutionException;
+
+  int findColumn(String columnName);
+}
diff --git a/session/src/main/java/org/apache/iotdb/session/ISessionDataSet.java b/session/src/main/java/org/apache/iotdb/session/ISessionDataSet.java
new file mode 100644
index 0000000000..75d232fa4d
--- /dev/null
+++ b/session/src/main/java/org/apache/iotdb/session/ISessionDataSet.java
@@ -0,0 +1,44 @@
+/*
+ * 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.iotdb.session;
+
+import org.apache.iotdb.rpc.IoTDBConnectionException;
+import org.apache.iotdb.rpc.StatementExecutionException;
+import org.apache.iotdb.tsfile.read.common.RowRecord;
+
+import java.util.List;
+
+public interface ISessionDataSet extends AutoCloseable {
+
+  int getFetchSize();
+
+  void setFetchSize(int fetchSize);
+
+  List<String> getColumnNames();
+
+  List<String> getColumnTypes();
+
+  boolean hasNext() throws StatementExecutionException, IoTDBConnectionException;
+
+  RowRecord next() throws StatementExecutionException, IoTDBConnectionException;
+
+  void closeOperationHandle() throws StatementExecutionException, IoTDBConnectionException;
+
+  IDataIterator iterator();
+}