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

CritasWang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iotdb-client-rust.git

commit 61f1c729aa1fe24698a06d0c545e60d8ef6ed0ea
Author: CritasWang <[email protected]>
AuthorDate: Fri Jul 10 16:31:56 2026 +0800

    Initial scaffold: session/connection/data/protocol skeleton with Thrift IDL
---
 .gitignore            |   2 +
 Cargo.toml            |  22 ++
 README.md             |  35 +++
 src/client/mod.rs     |   4 +
 src/client/session.rs |  83 +++++++
 src/connection/mod.rs |  37 +++
 src/data/mod.rs       |  21 ++
 src/error.rs          |  33 +++
 src/lib.rs            |  17 ++
 src/protocol/mod.rs   |  11 +
 thrift/client.thrift  | 673 ++++++++++++++++++++++++++++++++++++++++++++++++++
 thrift/common.thrift  | 348 ++++++++++++++++++++++++++
 12 files changed, 1286 insertions(+)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..96ef6c0
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+/target
+Cargo.lock
diff --git a/Cargo.toml b/Cargo.toml
new file mode 100644
index 0000000..2a071d1
--- /dev/null
+++ b/Cargo.toml
@@ -0,0 +1,22 @@
+[package]
+name = "iotdb-client"
+version = "0.1.0"
+edition = "2021"
+rust-version = "1.75"
+description = "Apache IoTDB client for Rust (tree & table model over Thrift 
RPC)"
+license = "Apache-2.0"
+repository = "https://github.com/apache/iotdb-client-rust";
+keywords = ["iotdb", "timeseries", "database", "client"]
+categories = ["database"]
+
+[dependencies]
+thrift = "0.23"
+byteorder = "1.5"
+chrono = "0.4"
+log = "0.4"
+
+[dev-dependencies]
+env_logger = "0.11"
+
+[features]
+default = []
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..52a827e
--- /dev/null
+++ b/README.md
@@ -0,0 +1,35 @@
+# Apache IoTDB Rust Client
+
+Rust client SDK for [Apache IoTDB](https://iotdb.apache.org/), speaking Apache 
Thrift RPC (default port 6667). Supports the **tree model** (`Session`, 
device/timeseries paths) with the **table model** (`TableSession`, SQL dialect) 
planned — mirroring the architecture of the Node.js and C# SDKs.
+
+## Status
+
+Early scaffold. Thrift stubs are not yet generated; session layer is a 
skeleton.
+
+## Build & Test
+
+```sh
+cargo build
+cargo test                 # unit tests
+cargo test test_name       # single test
+cargo fmt && cargo clippy  # format + lint
+```
+
+## Thrift codegen
+
+IDL sources in `thrift/` (`client.thrift`, `common.thrift`) originate from the 
IoTDB repo's `iotdb-protocol/`. Regenerate stubs (requires the `thrift` 
compiler ≥ 0.23):
+
+```sh
+thrift --gen rs -out src/protocol thrift/common.thrift
+thrift --gen rs -out src/protocol thrift/client.thrift
+```
+
+Never hand-edit generated files.
+
+## Layout
+
+- `src/client/` — Session / pool layer (tree & table model)
+- `src/connection/` — low-level Thrift transport (framed + binary protocol)
+- `src/data/` — Tablet, SessionDataSet, TSDataType (official TSFile codes 0–11)
+- `src/protocol/` — generated Thrift stubs
+- `thrift/` — Thrift IDL sources
diff --git a/src/client/mod.rs b/src/client/mod.rs
new file mode 100644
index 0000000..29ec6ac
--- /dev/null
+++ b/src/client/mod.rs
@@ -0,0 +1,4 @@
+//! Session-layer API: tree model (`Session`) and, later, table model
+//! (`TableSession`) plus pooled variants — mirroring the Node.js and C# SDKs.
+
+pub mod session;
diff --git a/src/client/session.rs b/src/client/session.rs
new file mode 100644
index 0000000..c504e25
--- /dev/null
+++ b/src/client/session.rs
@@ -0,0 +1,83 @@
+//! Tree-model session (device/timeseries paths).
+
+use crate::connection::{Connection, Endpoint};
+use crate::error::{Error, Result};
+
+/// Configuration for opening a [`Session`].
+#[derive(Debug, Clone)]
+pub struct SessionConfig {
+    pub endpoints: Vec<Endpoint>,
+    pub username: String,
+    pub password: String,
+    /// `tree` (default) or `table` — sent as `sql_dialect` at open time.
+    pub sql_dialect: String,
+    pub fetch_size: i32,
+    pub zone_id: String,
+}
+
+impl Default for SessionConfig {
+    fn default() -> Self {
+        Self {
+            endpoints: vec![Endpoint::new("localhost", 6667)],
+            username: "root".into(),
+            password: "root".into(),
+            sql_dialect: "tree".into(),
+            fetch_size: 1024,
+            zone_id: "UTC+8".into(),
+        }
+    }
+}
+
+/// A tree-model session against an IoTDB cluster.
+pub struct Session {
+    config: SessionConfig,
+    connection: Option<Connection>,
+}
+
+impl Session {
+    pub fn new(config: SessionConfig) -> Self {
+        Self { config, connection: None }
+    }
+
+    pub fn open(&mut self) -> Result<()> {
+        let endpoint = self
+            .config
+            .endpoints
+            .first()
+            .ok_or_else(|| Error::Client("no endpoints configured".into()))?
+            .clone();
+        self.connection = Some(Connection::open(endpoint)?);
+        // TODO(codegen): call openSession RPC 
(username/password/zoneId/sql_dialect),
+        // store sessionId + statementId.
+        Ok(())
+    }
+
+    pub fn is_open(&self) -> bool {
+        self.connection.is_some()
+    }
+
+    pub fn close(&mut self) -> Result<()> {
+        // TODO(codegen): call closeSession RPC before dropping the connection.
+        self.connection = None;
+        Ok(())
+    }
+}
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+
+    #[test]
+    fn default_config_targets_localhost() {
+        let cfg = SessionConfig::default();
+        assert_eq!(cfg.endpoints[0], Endpoint::new("localhost", 6667));
+        assert_eq!(cfg.sql_dialect, "tree");
+    }
+
+    #[test]
+    fn open_without_endpoints_fails() {
+        let mut session = Session::new(SessionConfig { endpoints: vec![], 
..Default::default() });
+        assert!(session.open().is_err());
+        assert!(!session.is_open());
+    }
+}
diff --git a/src/connection/mod.rs b/src/connection/mod.rs
new file mode 100644
index 0000000..430478d
--- /dev/null
+++ b/src/connection/mod.rs
@@ -0,0 +1,37 @@
+//! Low-level Thrift connection to an IoTDB node.
+//!
+//! Mirrors `src/connection/Connection.ts` (Node.js) and the Thrift client 
setup
+//! in the C# SDK: TCP → TFramedTransport → TBinaryProtocol → 
IClientRPCService client.
+
+use crate::error::Result;
+
+/// A single endpoint `host:port` of an IoTDB DataNode (default port 6667).
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct Endpoint {
+    pub host: String,
+    pub port: u16,
+}
+
+impl Endpoint {
+    pub fn new(host: impl Into<String>, port: u16) -> Self {
+        Self { host: host.into(), port }
+    }
+}
+
+/// Low-level connection wrapper. Owns the Thrift transport/protocol pair
+/// and the generated `IClientRPCService` client once codegen lands.
+pub struct Connection {
+    endpoint: Endpoint,
+    // TODO(codegen): hold IClientRPCServiceSyncClient over TFramedTransport + 
TBinaryProtocol
+}
+
+impl Connection {
+    pub fn open(endpoint: Endpoint) -> Result<Self> {
+        // TODO(codegen): establish TTcpChannel, wrap in framed transport + 
binary protocol
+        Ok(Self { endpoint })
+    }
+
+    pub fn endpoint(&self) -> &Endpoint {
+        &self.endpoint
+    }
+}
diff --git a/src/data/mod.rs b/src/data/mod.rs
new file mode 100644
index 0000000..82a8cab
--- /dev/null
+++ b/src/data/mod.rs
@@ -0,0 +1,21 @@
+//! Data structures: TSDataType codes, Tablet, SessionDataSet, BitMap.
+//! Data-type codes must match the official TSFile spec (0–11), identical
+//! across all IoTDB client SDKs.
+
+/// Official TSFile data type codes.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+#[repr(i32)]
+pub enum TSDataType {
+    Boolean = 0,
+    Int32 = 1,
+    Int64 = 2,
+    Float = 3,
+    Double = 4,
+    Text = 5,
+    Vector = 6,
+    Unknown = 7,
+    Timestamp = 8,
+    Date = 9,
+    Blob = 10,
+    String = 11,
+}
diff --git a/src/error.rs b/src/error.rs
new file mode 100644
index 0000000..6762061
--- /dev/null
+++ b/src/error.rs
@@ -0,0 +1,33 @@
+//! Error types for the IoTDB client.
+
+use std::fmt;
+
+pub type Result<T> = std::result::Result<T, Error>;
+
+#[derive(Debug)]
+pub enum Error {
+    /// Underlying Thrift transport/protocol failure.
+    Thrift(thrift::Error),
+    /// Non-success status code returned by the server (TSStatus).
+    Server { code: i32, message: String },
+    /// Client-side usage or state error (e.g. session not open).
+    Client(String),
+}
+
+impl fmt::Display for Error {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        match self {
+            Error::Thrift(e) => write!(f, "thrift error: {e}"),
+            Error::Server { code, message } => write!(f, "server error {code}: 
{message}"),
+            Error::Client(msg) => write!(f, "client error: {msg}"),
+        }
+    }
+}
+
+impl std::error::Error for Error {}
+
+impl From<thrift::Error> for Error {
+    fn from(e: thrift::Error) -> Self {
+        Error::Thrift(e)
+    }
+}
diff --git a/src/lib.rs b/src/lib.rs
new file mode 100644
index 0000000..bfae2e2
--- /dev/null
+++ b/src/lib.rs
@@ -0,0 +1,17 @@
+//! Apache IoTDB client for Rust.
+//!
+//! Provides two data models over Apache Thrift RPC (default port 6667):
+//! - **Tree model**: [`Session`] / `SessionPool` — device/timeseries paths
+//! - **Table model**: `TableSession` / `TableSessionPool` — SQL dialect
+//!
+//! Architecture mirrors the other IoTDB client SDKs (Node.js, C#):
+//! Pool (round-robin over node urls) → Session → Connection (framed transport 
+ binary protocol).
+
+pub mod client;
+pub mod connection;
+pub mod data;
+pub mod error;
+pub mod protocol;
+
+pub use client::session::Session;
+pub use error::{Error, Result};
diff --git a/src/protocol/mod.rs b/src/protocol/mod.rs
new file mode 100644
index 0000000..0d888ce
--- /dev/null
+++ b/src/protocol/mod.rs
@@ -0,0 +1,11 @@
+//! Generated Thrift RPC stubs.
+//!
+//! Source IDL lives in `thrift/` (copied from the IoTDB repo's 
`iotdb-protocol/`).
+//! Regenerate with:
+//! ```sh
+//! thrift --gen rs -out src/protocol thrift/common.thrift
+//! thrift --gen rs -out src/protocol thrift/client.thrift
+//! ```
+//! Never hand-edit generated files.
+
+// TODO(codegen): `pub mod common;` and `pub mod client;` once stubs are 
generated.
diff --git a/thrift/client.thrift b/thrift/client.thrift
new file mode 100644
index 0000000..48afb89
--- /dev/null
+++ b/thrift/client.thrift
@@ -0,0 +1,673 @@
+/*
+ * 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.
+ */
+
+include "common.thrift"
+namespace java org.apache.iotdb.service.rpc.thrift
+namespace py iotdb.thrift.rpc
+namespace go rpc
+
+struct TSQueryDataSet{
+  // ByteBuffer for time column
+  1: required binary time
+  // ByteBuffer for each column values
+  2: required list<binary> valueList
+  // Bitmap for each column to indicate whether it is a null value
+  3: required list<binary> bitmapList
+}
+
+struct TSQueryNonAlignDataSet{
+  // ByteBuffer for each time column
+  1: required list<binary> timeList
+  // ByteBuffer for each column values
+  2: required list<binary> valueList
+}
+
+struct TSTracingInfo{
+  1: required list<string> activityList
+  2: required list<i64> elapsedTimeList
+  3: optional i32 seriesPathNum
+  4: optional i32 seqFileNum
+  5: optional i32 unSeqFileNum
+  6: optional i32 sequenceChunkNum
+  7: optional i64 sequenceChunkPointNum
+  8: optional i32 unsequenceChunkNum
+  9: optional i64 unsequenceChunkPointNum
+  10: optional i32 totalPageNum
+  11: optional i32 overlappedPageNum
+}
+
+struct TSExecuteStatementResp {
+  1: required common.TSStatus status
+  2: optional i64 queryId
+  // Column names in select statement of SQL
+  3: optional list<string> columns
+  4: optional string operationType
+  5: optional bool ignoreTimeStamp
+  // Data type list of columns in select statement of SQL
+  6: optional list<string> dataTypeList
+  7: optional TSQueryDataSet queryDataSet
+  // for disable align statements, queryDataSet is null and 
nonAlignQueryDataSet is not null
+  8: optional TSQueryNonAlignDataSet nonAlignQueryDataSet
+  9: optional map<string, i32> columnNameIndexMap
+  10: optional list<string> sgColumns
+  11: optional list<byte> aliasColumns
+  12: optional TSTracingInfo tracingInfo
+  13: optional list<binary> queryResult
+  14: optional bool moreData
+  // only be set while executing use XXX successfully
+  15: optional string database
+  16: optional bool tableModel
+  17: optional list<i32> columnIndex2TsBlockColumnIndexList
+}
+
+enum TSProtocolVersion {
+  IOTDB_SERVICE_PROTOCOL_V1,
+  IOTDB_SERVICE_PROTOCOL_V2,//V2 is the first version that we can check 
version compatibility
+  IOTDB_SERVICE_PROTOCOL_V3,//V3 is incompatible with V2
+}
+
+struct TSOpenSessionResp {
+  1: required common.TSStatus status
+
+  // The protocol version that the server is using.
+  2: required TSProtocolVersion serverProtocolVersion = 
TSProtocolVersion.IOTDB_SERVICE_PROTOCOL_V1
+
+  // Session id
+  3: optional i64 sessionId
+
+  // The configuration settings for this session.
+  4: optional map<string, string> configuration
+}
+
+// OpenSession()
+// Open a session (connection) on the server against which operations may be 
executed.
+struct TSOpenSessionReq {
+  1: required TSProtocolVersion client_protocol = 
TSProtocolVersion.IOTDB_SERVICE_PROTOCOL_V3
+  2: required string zoneId
+  3: required string username
+  4: optional string password
+  5: optional map<string, string> configuration
+}
+
+// CloseSession()
+// Closes the specified session and frees any resources currently allocated to 
that session.
+// Any open operations in that session will be canceled.
+struct TSCloseSessionReq {
+  1: required i64 sessionId
+}
+
+// ExecuteStatement()
+//
+// Execute a statement.
+// The returned OperationHandle can be used to check on the status of the 
statement, and to fetch results once the
+// statement has finished executing.
+struct TSExecuteStatementReq {
+  // The session to execute the statement against
+  1: required i64 sessionId
+
+  // The statement to be executed (DML, DDL, SET, etc)
+  2: required string statement
+
+  // statementId
+  3: required i64 statementId
+
+  4: optional i32 fetchSize
+
+  5: optional i64 timeout
+
+  6: optional bool enableRedirectQuery;
+
+  7: optional bool jdbcQuery;
+}
+
+struct TSExecuteBatchStatementReq{
+  // The session to execute the statement against
+  1: required i64 sessionId
+
+  // The statements to be executed (DML, DDL, SET, etc)
+  2: required list<string> statements
+}
+
+struct TSGetOperationStatusReq {
+  1: required i64 sessionId
+  // Session to run this request against
+  2: required i64 queryId
+}
+
+// CancelOperation()
+//
+// Cancels processing on the specified operation handle and frees any 
resources which were allocated.
+struct TSCancelOperationReq {
+  1: required i64 sessionId
+  // Operation to cancel
+  2: required i64 queryId
+}
+
+// CloseOperation()
+struct TSCloseOperationReq {
+  1: required i64 sessionId
+  2: optional i64 queryId
+  3: optional i64 statementId
+  4: optional string preparedStatementName
+}
+
+struct TSFetchResultsReq{
+  1: required i64 sessionId
+  2: required string statement
+  3: required i32 fetchSize
+  4: required i64 queryId
+  5: required bool isAlign
+  6: optional i64 timeout
+  7: optional i64 statementId
+}
+
+struct TSFetchResultsResp{
+  1: required common.TSStatus status
+  2: required bool hasResultSet
+  3: required bool isAlign
+  4: optional TSQueryDataSet queryDataSet
+  5: optional TSQueryNonAlignDataSet nonAlignQueryDataSet
+  6: optional list<binary> queryResult
+  7: optional bool moreData
+}
+
+struct TSFetchMetadataResp{
+  1: required common.TSStatus status
+  2: optional string metadataInJson
+  3: optional list<string> columnsList
+  4: optional string dataType
+}
+
+struct TSFetchMetadataReq{
+  1: required i64 sessionId
+  2: required string type
+  3: optional string columnPath
+}
+
+struct TSGetTimeZoneResp {
+  1: required common.TSStatus status
+  2: required string timeZone
+}
+
+struct TSSetTimeZoneReq {
+  1: required i64 sessionId
+  2: required string timeZone
+}
+
+// for session
+struct TSInsertRecordReq {
+  1: required i64 sessionId
+  2: required string prefixPath
+  3: required list<string> measurements
+  4: required binary values
+  5: required i64 timestamp
+  6: optional bool isAligned
+  7: optional bool isWriteToTable
+  8: optional list<byte> columnCategoryies
+}
+
+struct TSInsertStringRecordReq {
+  1: required i64 sessionId
+  2: required string prefixPath
+  3: required list<string> measurements
+  4: required list<string> values
+  5: required i64 timestamp
+  6: optional bool isAligned
+  7: optional i64 timeout
+}
+
+struct TSInsertTabletReq {
+  1: required i64 sessionId
+  2: required string prefixPath
+  3: required list<string> measurements
+  4: required binary values
+  5: required binary timestamps
+  6: required list<i32> types
+  7: required i32 size
+  8: optional bool isAligned
+  9: optional bool writeToTable
+  10: optional list<byte> columnCategories
+  11: optional bool isCompressed
+  12: optional list<byte> encodingTypes
+  13: optional byte compressType
+}
+
+struct TSInsertTabletsReq {
+  1: required i64 sessionId
+  2: required list<string> prefixPaths
+  3: required list<list<string>> measurementsList
+  4: required list<binary> valuesList
+  5: required list<binary> timestampsList
+  6: required list<list<i32>> typesList
+  7: required list<i32> sizeList
+  8: optional bool isAligned
+}
+
+struct TSInsertRecordsReq {
+  1: required i64 sessionId
+  2: required list<string> prefixPaths
+  3: required list<list<string>> measurementsList
+  4: required list<binary> valuesList
+  5: required list<i64> timestamps
+  6: optional bool isAligned
+}
+
+struct TSInsertRecordsOfOneDeviceReq {
+    1: required i64 sessionId
+    2: required string prefixPath
+    3: required list<list<string>> measurementsList
+    4: required list<binary> valuesList
+    5: required list<i64> timestamps
+    6: optional bool isAligned
+}
+
+struct TSInsertStringRecordsOfOneDeviceReq {
+    1: required i64 sessionId
+    2: required string prefixPath
+    3: required list<list<string>> measurementsList
+    4: required list<list<string>> valuesList
+    5: required list<i64> timestamps
+    6: optional bool isAligned
+}
+
+struct TSInsertStringRecordsReq {
+  1: required i64 sessionId
+  2: required list<string> prefixPaths
+  3: required list<list<string>> measurementsList
+  4: required list<list<string>> valuesList
+  5: required list<i64> timestamps
+  6: optional bool isAligned
+}
+
+struct TSDeleteDataReq {
+  1: required i64 sessionId
+  2: required list<string> paths
+  3: required i64 startTime
+  4: required i64 endTime
+}
+
+struct TSCreateTimeseriesReq {
+  1: required i64 sessionId
+  2: required string path
+  3: required i32 dataType
+  4: required i32 encoding
+  5: required i32 compressor
+  6: optional map<string, string> props
+  7: optional map<string, string> tags
+  8: optional map<string, string> attributes
+  9: optional string measurementAlias
+}
+
+struct TSCreateAlignedTimeseriesReq {
+  1: required i64 sessionId
+  2: required string prefixPath
+  3: required list<string> measurements
+  4: required list<i32> dataTypes
+  5: required list<i32> encodings
+  6: required list<i32> compressors
+  7: optional list<string> measurementAlias
+  8: optional list<map<string, string>> tagsList
+  9: optional list<map<string, string>> attributesList
+}
+
+struct TSRawDataQueryReq {
+  1: required i64 sessionId
+  2: required list<string> paths
+  3: optional i32 fetchSize
+  4: required i64 startTime
+  5: required i64 endTime
+  6: required i64 statementId
+  7: optional bool enableRedirectQuery
+  8: optional bool jdbcQuery
+  9: optional i64 timeout
+  10: optional bool legalPathNodes
+}
+
+struct TSLastDataQueryReq {
+  1: required i64 sessionId
+  2: required list<string> paths
+  3: optional i32 fetchSize
+  4: required i64 time
+  5: required i64 statementId
+  6: optional bool enableRedirectQuery
+  7: optional bool jdbcQuery
+  8: optional i64 timeout
+  9: optional bool legalPathNodes
+}
+
+struct TSFastLastDataQueryForOnePrefixPathReq {
+  1: required i64 sessionId
+  2: required list<string> prefixes
+  3: optional i32 fetchSize
+  4: required i64 statementId
+  5: optional bool enableRedirectQuery
+  6: optional bool jdbcQuery
+  7: optional i64 timeout
+}
+
+struct TSFastLastDataQueryForOneDeviceReq {
+  1: required i64 sessionId
+  2: required string db
+  3: required string deviceId
+  4: required list<string> sensors
+  5: optional i32 fetchSize
+  6: required i64 statementId
+  7: optional bool enableRedirectQuery
+  8: optional bool jdbcQuery
+  9: optional i64 timeout
+  10: optional bool legalPathNodes
+}
+
+struct TSAggregationQueryReq {
+  1: required i64 sessionId
+  2: required i64 statementId
+  3: required list<string> paths
+  4: required list<common.TAggregationType> aggregations
+  5: optional i64 startTime
+  6: optional i64 endTime
+  7: optional i64 interval
+  8: optional i64 slidingStep
+  9: optional i32 fetchSize
+  10: optional i64 timeout
+  11: optional bool legalPathNodes
+}
+
+struct TSCreateMultiTimeseriesReq {
+  1: required i64 sessionId
+  2: required list<string> paths
+  3: required list<i32> dataTypes
+  4: required list<i32> encodings
+  5: required list<i32> compressors
+  6: optional list<map<string, string>> propsList
+  7: optional list<map<string, string>> tagsList
+  8: optional list<map<string, string>> attributesList
+  9: optional list<string> measurementAliasList
+}
+
+struct ServerProperties {
+  1: required string version;
+  2: required list<string> supportedTimeAggregationOperations;
+  3: required string timestampPrecision;
+  4: i32 maxConcurrentClientNum;
+  5: optional i32 thriftMaxFrameSize;
+  6: optional bool isReadOnly;
+  7: optional string buildInfo;
+  8: optional string logo;
+}
+
+struct TSSetSchemaTemplateReq {
+  1: required i64 sessionId
+  2: required string templateName
+  3: required string prefixPath
+}
+
+struct TSCreateSchemaTemplateReq {
+  1: required i64 sessionId
+  2: required string name
+  3: required binary serializedTemplate
+}
+
+struct TSAppendSchemaTemplateReq {
+  1: required i64 sessionId
+  2: required string name
+  3: required bool isAligned
+  4: required list<string> measurements
+  5: required list<i32> dataTypes
+  6: required list<i32> encodings
+  7: required list<i32> compressors
+}
+
+struct TSPruneSchemaTemplateReq {
+  1: required i64 sessionId
+  2: required string name
+  3: required string path
+}
+
+struct TSQueryTemplateReq {
+  1: required i64 sessionId
+  2: required string name
+  3: required i32 queryType
+  4: optional string measurement
+}
+
+struct TSQueryTemplateResp {
+  1: required common.TSStatus status
+  2: required i32 queryType
+  3: optional bool result
+  4: optional i32 count
+  5: optional list<string> measurements
+}
+
+struct TSUnsetSchemaTemplateReq {
+  1: required i64 sessionId
+  2: required string prefixPath
+  3: required string templateName
+}
+
+struct TSDropSchemaTemplateReq {
+  1: required i64 sessionId
+  2: required string templateName
+}
+
+struct TCreateTimeseriesUsingSchemaTemplateReq{
+  1: required i64 sessionId
+  2: required list<string> devicePathList
+}
+
+// The sender and receiver need to check some info to confirm validity
+struct TSyncIdentityInfo{
+  // Sender needs to tell receiver its identity.
+  1:required string pipeName
+  2:required i64 createTime
+  // The version of sender and receiver need to be the same.
+  3:required string version
+  4:required string database
+}
+
+struct TSyncTransportMetaInfo{
+  // The name of the file in sending.
+  1:required string fileName
+  // The start index of the file slice in sending.
+  2:required i64 startIndex
+}
+
+struct TPipeTransferReq {
+  1:required i8 version
+  2:required i16 type
+  3:required binary body
+}
+
+struct TPipeTransferResp {
+  1:required common.TSStatus status
+  2:optional binary body
+}
+
+struct TPipeSubscribeReq {
+  1:required i8 version
+  2:required i16 type
+  3:optional binary body
+}
+
+struct TPipeSubscribeResp {
+  1:required common.TSStatus status
+  2:required i8 version
+  3:required i16 type
+  4:optional list<binary> body
+}
+
+struct TSBackupConfigurationResp {
+  1: required common.TSStatus status
+  2: optional bool enableOperationSync
+  3: optional string secondaryAddress
+  4: optional i32 secondaryPort
+}
+
+enum TSConnectionType {
+  THRIFT_BASED
+  MQTT_BASED
+  INTERNAL
+  REST_BASED
+}
+
+struct TSConnectionInfo {
+  1: required string userName
+  2: required i64 logInTime
+  3: required string connectionId // ip:port for thrift-based service and 
clientId for mqtt-based service
+  4: required TSConnectionType type
+}
+
+struct TSConnectionInfoResp {
+  1: required list<TSConnectionInfo> connectionInfoList
+}
+
+service IClientRPCService {
+
+  TSExecuteStatementResp executeQueryStatementV2(1:TSExecuteStatementReq req);
+
+  TSExecuteStatementResp executeUpdateStatementV2(1:TSExecuteStatementReq req);
+
+  TSExecuteStatementResp executeStatementV2(1:TSExecuteStatementReq req);
+
+  TSExecuteStatementResp executeRawDataQueryV2(1:TSRawDataQueryReq req);
+
+  TSExecuteStatementResp executeLastDataQueryV2(1:TSLastDataQueryReq req);
+
+  TSExecuteStatementResp 
executeFastLastDataQueryForOnePrefixPath(1:TSFastLastDataQueryForOnePrefixPathReq
 req);
+
+  TSExecuteStatementResp 
executeFastLastDataQueryForOneDeviceV2(1:TSFastLastDataQueryForOneDeviceReq 
req);
+
+  TSExecuteStatementResp executeAggregationQueryV2(1:TSAggregationQueryReq 
req);
+
+  TSFetchResultsResp fetchResultsV2(1:TSFetchResultsReq req);
+
+  TSOpenSessionResp openSession(1:TSOpenSessionReq req);
+
+  common.TSStatus closeSession(1:TSCloseSessionReq req);
+
+  TSExecuteStatementResp executeStatement(1:TSExecuteStatementReq req);
+
+  common.TSStatus executeBatchStatement(1:TSExecuteBatchStatementReq req);
+
+  TSExecuteStatementResp executeQueryStatement(1:TSExecuteStatementReq req);
+
+  TSExecuteStatementResp executeUpdateStatement(1:TSExecuteStatementReq req);
+
+  TSFetchResultsResp fetchResults(1:TSFetchResultsReq req);
+
+  TSFetchMetadataResp fetchMetadata(1:TSFetchMetadataReq req);
+
+  common.TSStatus cancelOperation(1:TSCancelOperationReq req);
+
+  common.TSStatus closeOperation(1:TSCloseOperationReq req);
+
+  TSGetTimeZoneResp getTimeZone(1:i64 sessionId);
+
+  common.TSStatus setTimeZone(1:TSSetTimeZoneReq req);
+
+  ServerProperties getProperties();
+
+  common.TSStatus setStorageGroup(1:i64 sessionId, 2:string storageGroup);
+
+  common.TSStatus createTimeseries(1:TSCreateTimeseriesReq req);
+
+  common.TSStatus createAlignedTimeseries(1:TSCreateAlignedTimeseriesReq req);
+
+  common.TSStatus createMultiTimeseries(1:TSCreateMultiTimeseriesReq req);
+
+  common.TSStatus deleteTimeseries(1:i64 sessionId, 2:list<string> path)
+
+  common.TSStatus deleteStorageGroups(1:i64 sessionId, 2:list<string> 
storageGroup);
+
+  common.TSStatus insertRecord(1:TSInsertRecordReq req);
+
+  common.TSStatus insertStringRecord(1:TSInsertStringRecordReq req);
+
+  common.TSStatus insertTablet(1:TSInsertTabletReq req);
+
+  common.TSStatus insertTablets(1:TSInsertTabletsReq req);
+
+  common.TSStatus insertRecords(1:TSInsertRecordsReq req);
+
+  common.TSStatus insertRecordsOfOneDevice(1:TSInsertRecordsOfOneDeviceReq 
req);
+
+  common.TSStatus 
insertStringRecordsOfOneDevice(1:TSInsertStringRecordsOfOneDeviceReq req);
+
+  common.TSStatus insertStringRecords(1:TSInsertStringRecordsReq req);
+
+  common.TSStatus testInsertTablet(1:TSInsertTabletReq req);
+
+  common.TSStatus testInsertTablets(1:TSInsertTabletsReq req);
+
+  common.TSStatus testInsertRecord(1:TSInsertRecordReq req);
+
+  common.TSStatus testInsertStringRecord(1:TSInsertStringRecordReq req);
+
+  common.TSStatus testInsertRecords(1:TSInsertRecordsReq req);
+
+  common.TSStatus testInsertRecordsOfOneDevice(1:TSInsertRecordsOfOneDeviceReq 
req);
+
+  common.TSStatus testInsertStringRecords(1:TSInsertStringRecordsReq req);
+
+  common.TSStatus deleteData(1:TSDeleteDataReq req);
+
+  TSExecuteStatementResp executeRawDataQuery(1:TSRawDataQueryReq req);
+
+  TSExecuteStatementResp executeLastDataQuery(1:TSLastDataQueryReq req);
+
+  TSExecuteStatementResp executeAggregationQuery(1:TSAggregationQueryReq req);
+
+  i64 requestStatementId(1:i64 sessionId);
+
+  common.TSStatus createSchemaTemplate(1:TSCreateSchemaTemplateReq req);
+
+  common.TSStatus appendSchemaTemplate(1:TSAppendSchemaTemplateReq req);
+
+  common.TSStatus pruneSchemaTemplate(1:TSPruneSchemaTemplateReq req);
+
+  TSQueryTemplateResp querySchemaTemplate(1:TSQueryTemplateReq req);
+
+  common.TShowConfigurationTemplateResp showConfigurationTemplate();
+
+  common.TShowConfigurationResp showConfiguration(1:i32 nodeId);
+
+  common.TSStatus setSchemaTemplate(1:TSSetSchemaTemplateReq req);
+
+  common.TSStatus unsetSchemaTemplate(1:TSUnsetSchemaTemplateReq req);
+
+  common.TSStatus dropSchemaTemplate(1:TSDropSchemaTemplateReq req);
+
+  common.TSStatus 
createTimeseriesUsingSchemaTemplate(1:TCreateTimeseriesUsingSchemaTemplateReq 
req);
+
+  common.TSStatus handshake(TSyncIdentityInfo info);
+
+  common.TSStatus sendPipeData(1:binary buff);
+
+  common.TSStatus sendFile(1:TSyncTransportMetaInfo metaInfo, 2:binary buff);
+
+  TPipeTransferResp pipeTransfer(TPipeTransferReq req);
+
+  TPipeSubscribeResp pipeSubscribe(TPipeSubscribeReq req);
+
+  TSBackupConfigurationResp getBackupConfiguration();
+
+  TSConnectionInfoResp fetchAllConnectionsInfo();
+
+  /** For other node's call */
+  common.TSStatus testConnectionEmptyRPC();
+}
\ No newline at end of file
diff --git a/thrift/common.thrift b/thrift/common.thrift
new file mode 100644
index 0000000..d1db4cf
--- /dev/null
+++ b/thrift/common.thrift
@@ -0,0 +1,348 @@
+/*
+ * 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.
+ */
+
+namespace java org.apache.iotdb.common.rpc.thrift
+namespace py iotdb.thrift.common
+namespace go common
+
+// Define a set of ip:port address
+struct TEndPoint {
+  1: required string ip
+  2: required i32 port
+}
+
+// The return status code and message in each response.
+struct TSStatus {
+  1: required i32 code
+  2: optional string message
+  3: optional list<TSStatus> subStatus
+  4: optional TEndPoint redirectNode
+  5: optional bool needRetry
+}
+
+enum TConsensusGroupType {
+  ConfigRegion,
+  DataRegion,
+  SchemaRegion
+}
+
+struct TConsensusGroupId {
+  1: required TConsensusGroupType type
+  2: required i32 id
+}
+
+struct TSeriesPartitionSlot {
+  1: required i32 slotId
+}
+
+struct TTimePartitionSlot {
+  1: required i64 startTime
+}
+
+struct TRegionReplicaSet {
+  1: required TConsensusGroupId regionId
+  2: required list<TDataNodeLocation> dataNodeLocations
+}
+
+struct TNodeResource {
+  1: required i32 cpuCoreNum
+  2: required i64 maxMemory
+}
+
+struct TConfigNodeLocation {
+  1: required i32 configNodeId
+  2: required TEndPoint internalEndPoint
+  3: required TEndPoint consensusEndPoint
+}
+
+struct TDataNodeLocation {
+  1: required i32 dataNodeId
+  // TEndPoint for DataNode's client rpc
+  2: required TEndPoint clientRpcEndPoint
+  // TEndPoint for DataNode's cluster internal rpc
+  3: required TEndPoint internalEndPoint
+  // TEndPoint for exchange data between DataNodes
+  4: required TEndPoint mPPDataExchangeEndPoint
+  // TEndPoint for DataNode's dataRegion consensus protocol
+  5: required TEndPoint dataRegionConsensusEndPoint
+  // TEndPoint for DataNode's schemaRegion consensus protocol
+  6: required TEndPoint schemaRegionConsensusEndPoint
+}
+
+struct TAINodeLocation{
+  1: required i32 aiNodeId
+  2: required TEndPoint internalEndPoint
+}
+
+struct TDataNodeConfiguration {
+  1: required TDataNodeLocation location
+  2: required TNodeResource resource
+}
+
+struct TAINodeConfiguration{
+  1: required TAINodeLocation location
+  2: required TNodeResource resource
+}
+
+enum TRegionMigrateFailedType {
+  AddPeerFailed,
+  RemovePeerFailed,
+  RemoveConsensusGroupFailed,
+  DeleteRegionFailed,
+  CreateRegionFailed,
+  Disconnect,
+}
+
+enum TRegionMaintainTaskStatus {
+  TASK_NOT_EXIST,
+  PROCESSING,
+  SUCCESS,
+  FAIL,
+}
+
+struct TFlushReq {
+   1: optional string isSeq
+   2: optional list<string> storageGroups
+   3: optional list<string> regionIds
+}
+
+struct TSettleReq {
+   1: required list<string> paths
+}
+
+// for node management
+struct TSchemaNode {
+  1: required string nodeName
+  2: required byte nodeType
+}
+
+struct TSetConfigurationReq {
+  1: required map<string,string> configs
+  2: required i32 nodeId
+}
+
+// for TTL
+struct TSetTTLReq {
+  1: required list<string> pathPattern
+  2: required i64 TTL
+  3: required bool isDataBase
+}
+
+struct TShowTTLReq {
+  1: required list<string> pathPattern
+}
+
+// for File
+struct TFile {
+  1: required string fileName
+  2: required binary file
+}
+
+struct TFilesResp {
+  1: required TSStatus status
+  2: required list<TFile> files
+}
+
+// quota
+struct TSpaceQuota {
+  1: optional i64 diskSize
+  2: optional i64 deviceNum
+  3: optional i64 timeserieNum
+}
+
+enum ThrottleType {
+  REQUEST_NUMBER,
+  REQUEST_SIZE,
+  WRITE_NUMBER,
+  WRITE_SIZE,
+  READ_NUMBER,
+  READ_SIZE
+}
+
+struct TTimedQuota {
+  1: required i64 timeUnit
+  2: required i64 softLimit
+}
+
+struct TThrottleQuota {
+  1: optional map<ThrottleType, TTimedQuota> throttleLimit
+  2: optional i64 memLimit
+  3: optional i32 cpuLimit
+}
+
+struct TSetSpaceQuotaReq {
+  1: required list<string> database
+  2: required TSpaceQuota spaceLimit
+}
+
+struct TSetThrottleQuotaReq {
+  1: required string userName
+  2: required TThrottleQuota throttleQuota
+}
+
+struct TPipeHeartbeatResp {
+  1: required list<binary> pipeMetaList
+  2: optional list<bool> pipeCompletedList
+  3: optional list<i64> pipeRemainingEventCountList
+  4: optional list<double> pipeRemainingTimeList
+}
+
+struct TLicense {
+    1: required i64 licenseIssueTimestamp
+    2: required i64 expireTimestamp
+    4: required i16 dataNodeNumLimit
+    5: required i32 cpuCoreNumLimit
+    6: required i64 deviceNumLimit
+    7: required i64 sensorNumLimit
+    8: required i64 disconnectionFromActiveNodeTimeLimit
+    9: required i16 mlNodeNumLimit
+}
+
+struct TLoadSample {
+  // Percentage of occupied cpu in Node
+  1: required double cpuUsageRate
+  // Percentage of occupied memory space in Node
+  2: required double memoryUsageRate
+  // Percentage of occupied disk space in Node
+  3: required double diskUsageRate
+  // The size of free disk space
+  // Unit: Byte
+  4: required double freeDiskSpace
+}
+
+enum TServiceType {
+  ConfigNodeInternalService,
+  DataNodeInternalService,
+  DataNodeMPPService,
+  DataNodeExternalService,
+}
+
+struct TServiceProvider {
+  1: required TEndPoint endPoint
+  2: required TServiceType serviceType
+  3: required i32 nodeId
+}
+
+struct TSender {
+  1: optional TDataNodeLocation dataNodeLocation
+  2: optional TConfigNodeLocation configNodeLocation
+}
+
+struct TTestConnectionResult {
+  1: required TServiceProvider serviceProvider
+  2: required TSender sender
+  3: required bool success
+  4: optional string reason
+}
+
+struct TTestConnectionResp {
+  1: required TSStatus status
+  2: required list<TTestConnectionResult> resultList
+}
+
+struct TNodeLocations {
+  1: optional list<TConfigNodeLocation> configNodeLocations
+  2: optional list<TDataNodeLocation> dataNodeLocations
+}
+
+struct TExternalServiceListResp {
+  1: required TSStatus status
+  2: required list<TExternalServiceEntry> externalServiceInfos
+}
+
+
+struct TExternalServiceEntry {
+  1: required string serviceName
+  2: required string className
+  3: required byte state
+  4: required i32 dataNodeId
+  5: required byte serviceType
+}
+
+enum TAggregationType {
+  COUNT,
+  AVG,
+  SUM,
+  FIRST_VALUE,
+  LAST_VALUE,
+  MAX_TIME,
+  MIN_TIME,
+  MAX_VALUE,
+  MIN_VALUE,
+  EXTREME,
+  COUNT_IF,
+  TIME_DURATION,
+  MODE,
+  COUNT_TIME,
+  STDDEV,
+  STDDEV_POP,
+  STDDEV_SAMP,
+  VARIANCE,
+  VAR_POP,
+  VAR_SAMP,
+  MAX_BY,
+  MIN_BY,
+  UDAF,
+  FIRST,
+  LAST,
+  FIRST_BY,
+  LAST_BY,
+  MIN,
+  MAX,
+  COUNT_ALL,
+  APPROX_COUNT_DISTINCT,
+  APPROX_MOST_FREQUENT,
+  APPROX_PERCENTILE,
+}
+
+struct TShowConfigurationTemplateResp {
+  1: required TSStatus status
+  2: required string content
+}
+
+struct TShowConfigurationResp {
+  1: required TSStatus status
+  2: required string content
+}
+
+struct TShowAppliedConfigurationsResp {
+  1: required TSStatus status
+  2: optional map<string, string> data
+}
+
+// for AINode
+enum TrainingState {
+  PENDING,
+  RUNNING,
+  FINISHED,
+  FAILED,
+  DROPPING
+}
+
+enum Model{
+  TREE=0,
+  TABLE=1
+}
+
+enum FunctionType{
+  NONE=0,
+  SCALAR=1,
+  AGGREGATE=2,
+  TABLE=3
+}
\ No newline at end of file


Reply via email to