You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ha...@apache.org on 2022/12/23 01:44:37 UTC
[iotdb] branch rel/0.13 updated: Add ISessionDataSet interface (#8582)
This is an automated email from the ASF dual-hosted git repository.
haonan pushed a commit to branch rel/0.13
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/rel/0.13 by this push:
new 6e2ff51fbb Add ISessionDataSet interface (#8582)
6e2ff51fbb is described below
commit 6e2ff51fbb80836bfb5813a955f5a9d5c8c2053d
Author: Jackie Tien <ja...@gmail.com>
AuthorDate: Fri Dec 23 09:44:32 2022 +0800
Add ISessionDataSet interface (#8582)
---
.../org/apache/iotdb/session/IDataIterator.java | 67 ++++++++++++++++++++++
.../org/apache/iotdb/session/ISessionDataSet.java | 44 ++++++++++++++
.../org/apache/iotdb/session/SessionDataSet.java | 32 ++++++++++-
3 files changed, 141 insertions(+), 2 deletions(-)
diff --git a/isession/src/main/java/org/apache/iotdb/session/IDataIterator.java b/isession/src/main/java/org/apache/iotdb/session/IDataIterator.java
new file mode 100644
index 0000000000..7d17f390af
--- /dev/null
+++ b/isession/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/isession/src/main/java/org/apache/iotdb/session/ISessionDataSet.java b/isession/src/main/java/org/apache/iotdb/session/ISessionDataSet.java
new file mode 100644
index 0000000000..75d232fa4d
--- /dev/null
+++ b/isession/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();
+}
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 3c1f6c7b96..abb933d9a4 100644
--- a/isession/src/main/java/org/apache/iotdb/session/SessionDataSet.java
+++ b/isession/src/main/java/org/apache/iotdb/session/SessionDataSet.java
@@ -39,7 +39,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;
@@ -98,22 +98,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();
}
@@ -175,6 +180,7 @@ public class SessionDataSet implements AutoCloseable {
return new RowRecord(BytesUtils.bytesToLong(ioTDBRpcDataSet.time), outFields);
}
+ @Override
public RowRecord next() throws StatementExecutionException, IoTDBConnectionException {
if (!ioTDBRpcDataSet.hasCachedRecord && !hasNext()) {
return null;
@@ -184,6 +190,7 @@ public class SessionDataSet implements AutoCloseable {
return constructRowRecordFromValueArray();
}
+ @Override
public void closeOperationHandle() throws StatementExecutionException, IoTDBConnectionException {
try {
ioTDBRpcDataSet.close();
@@ -192,6 +199,7 @@ public class SessionDataSet implements AutoCloseable {
}
}
+ @Override
public DataIterator iterator() {
return new DataIterator();
}
@@ -201,84 +209,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);
}