rpc.thrift 8.5 KB
Newer Older
1
/*
2 3 4 5 6 7 8
 * 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
9 10 11
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
12 13 14 15 16 17
 * 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.
18
 */
19
namespace java org.apache.iotdb.service.rpc.thrift
20

21
// The return status code and message in each response.
22
struct TSStatusType {
23 24
  1: required i32 code
  2: required string message
25 26 27
}

// The return status of a remote request
28 29
struct TSStatus {
  1: required TSStatusType statusType
30
  2: optional list<string> infoMessages
31
  3: optional string sqlState  // as defined in the ISO/IEF CLIENT specification
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
}

struct TSHandleIdentifier {
  // 16 byte globally unique identifier This is the public ID of the handle and can be used for reporting.
  // In current version, it is not used.
  1: required binary guid,

  // 16 byte secret generated by the server and used to verify that the handle is not being hijacked by another user.
  // In current version, it is not used.
  2: required binary secret,
}

// Client-side reference to a task running asynchronously on the server.
struct TSOperationHandle {
  1: required TSHandleIdentifier operationId

  // If hasResultSet = TRUE, then this operation
  // generates a result set that can be fetched.
  // Note that the result set may be empty.
  //
  // If hasResultSet = FALSE, then this operation
  // does not generate a result set, and calling
  // GetResultSetMetadata or FetchResults against
  // this OperationHandle will generate an error.
  2: required bool hasResultSet
}

struct TSExecuteStatementResp {
60
	1: required TSStatus status
61 62 63 64
	2: optional TSOperationHandle operationHandle
  // Column names in select statement of SQL
	3: optional list<string> columns
	4: optional string operationType
65
	5: optional bool ignoreTimeStamp
66 67
  // Data type list of columns in select statement of SQL
  6: optional list<string> dataTypeList
68 69 70
}

enum TSProtocolVersion {
Q
qiaojialin 已提交
71
  IOTDB_SERVICE_PROTOCOL_V1,
72 73 74 75 76 77 78 79 80 81
}

// Client-side handle to persistent session information on the server-side.
// In current version, it is not used.
struct TS_SessionHandle {
  1: required TSHandleIdentifier sessionId
}


struct TSOpenSessionResp {
82
  1: required TSStatus status
83 84

  // The protocol version that the server is using.
Q
qiaojialin 已提交
85
  2: required TSProtocolVersion serverProtocolVersion = TSProtocolVersion.IOTDB_SERVICE_PROTOCOL_V1
86 87 88 89 90 91 92 93 94 95 96

  // Session Handle
  3: optional TS_SessionHandle sessionHandle

  // 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 {
Q
qiaojialin 已提交
97
  1: required TSProtocolVersion client_protocol = TSProtocolVersion.IOTDB_SERVICE_PROTOCOL_V1
98 99 100 101 102 103
  2: optional string username
  3: optional string password
  4: optional map<string, string> configuration
}

// CloseSession()
104
// Closes the specified session and frees any resources currently allocated to that session.
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
// Any open operations in that session will be canceled.
struct TSCloseSessionReq {
  1: required TS_SessionHandle sessionHandle
}

// 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 TS_SessionHandle sessionHandle

  // The statement to be executed (DML, DDL, SET, etc)
  2: required string statement
}


struct TSExecuteBatchStatementResp{
125 126
	1: required TSStatus status
  // For each value in result, Statement.SUCCESS_NO_INFO represents success, Statement.EXECUTE_FAILED represents fail otherwise.
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
	2: optional list<i32> result
}

struct TSExecuteBatchStatementReq{
  // The session to execute the statement against
  1: required TS_SessionHandle sessionHandle

  // The statements to be executed (DML, DDL, SET, etc)
  2: required list<string> statements
}


struct TSGetOperationStatusReq {
  // Session to run this request against
  1: required TSOperationHandle operationHandle
}

// CancelOperation()
//
// Cancels processing on the specified operation handle and frees any resources which were allocated.
struct TSCancelOperationReq {
  // Operation to cancel
  1: required TSOperationHandle operationHandle
}

// CloseOperation()
struct TSCloseOperationReq {
  1: required TSOperationHandle operationHandle
155
  2: required i64 queryId
J
Jialin Qiao 已提交
156
  3: optional i64 stmtId
157 158 159 160 161 162 163 164 165 166
}

struct TSDataValue{
  1: required bool is_empty
  2: optional bool bool_val
  3: optional i32 int_val
  4: optional i64 long_val
  5: optional double float_val
  6: optional double double_val
  7: optional binary binary_val
167
  8: optional string type
Q
qiaojialin 已提交
168 169
}

170 171 172
struct TSRowRecord{
  1: required i64 timestamp
  // column values
173
  2: required list<TSDataValue> values
174 175 176 177 178 179 180 181 182
}

struct TSQueryDataSet{
	1: required list<TSRowRecord> records
}

struct TSFetchResultsReq{
	1: required string statement
	2: required i32 fetch_size
183
	3: required i64 queryId
184 185 186
}

struct TSFetchResultsResp{
187
	1: required TSStatus status
188 189 190 191 192
	2: required bool hasResultSet
	3: optional TSQueryDataSet queryDataSet
}

struct TSFetchMetadataResp{
193
		1: required TSStatus status
194 195 196 197 198
		2: optional string metadataInJson
		3: optional list<string> ColumnsList
		4: optional string dataType
		5: optional list<list<string>> showTimeseriesList
		7: optional set<string> showStorageGroups
199 200
		8: optional list<string> nodesList
		9: optional map<string, string> nodeTimeseriesNum
201 202 203 204 205
}

struct TSFetchMetadataReq{
		1: required string type
		2: optional string columnPath
206
		3: optional string nodeLevel
207 208 209 210 211 212 213 214 215 216
}

struct TSColumnSchema{
	1: optional string name;
	2: optional string dataType;
	3: optional string encoding;
	4: optional map<string, string> otherArgs;
}

struct TSGetTimeZoneResp {
217
    1: required TSStatus status
218 219 220 221 222 223 224
    2: required string timeZone
}

struct TSSetTimeZoneReq {
    1: required string timeZone
}

J
Jialin Qiao 已提交
225 226 227 228 229 230 231 232
struct TSInsertionReq {
    1: optional string deviceId
    2: optional list<string> measurements
    3: optional list<string> values
    4: optional i64 timestamp
    5: required i64 stmtId
}

Q
qiaojialin 已提交
233 234 235
struct TSBatchInsertionReq {
    1: required string deviceId
    2: required list<string> measurements
236 237
    3: required binary values
    4: required binary timestamps
238
    5: required list<i32> types
239
    6: required i32 size
Q
qiaojialin 已提交
240 241
}

Q
qiaojialin 已提交
242 243 244 245 246 247 248
struct TSInsertReq {
    1: required string deviceId
    2: required list<string> measurements
    3: required list<string> values
    4: required i64 timestamp
}

Q
qiaojialin 已提交
249 250
struct TSDeleteDataReq {
    1: required list<string> paths
251 252 253
    2: required i64 timestamp
}

254 255 256 257
struct TSCreateTimeseriesReq {
  1: required string path
  2: required i32 dataType
  3: required i32 encoding
258
  4: required i32 compressor
259 260
}

X
XuYi 已提交
261 262 263
struct ServerProperties {
	1: required string version;
	2: required list<string> supportedTimeAggregationOperations;
264
	3: required string timestampPrecision;
X
XuYi 已提交
265 266
}

267 268 269
service TSIService {
	TSOpenSessionResp openSession(1:TSOpenSessionReq req);

270
	TSStatus closeSession(1:TSCloseSessionReq req);
271 272 273 274 275 276 277 278 279 280 281 282 283

	TSExecuteStatementResp executeStatement(1:TSExecuteStatementReq req);

	TSExecuteBatchStatementResp executeBatchStatement(1:TSExecuteBatchStatementReq req);

	TSExecuteStatementResp executeQueryStatement(1:TSExecuteStatementReq req);

	TSExecuteStatementResp executeUpdateStatement(1:TSExecuteStatementReq req);

	TSFetchResultsResp fetchResults(1:TSFetchResultsReq req)

	TSFetchMetadataResp fetchMetadata(1:TSFetchMetadataReq req)

284
	TSStatus cancelOperation(1:TSCancelOperationReq req);
285

286
	TSStatus closeOperation(1:TSCloseOperationReq req);
287 288 289

	TSGetTimeZoneResp getTimeZone();

290 291
	TSStatus setTimeZone(1:TSSetTimeZoneReq req);

X
XuYi 已提交
292
	ServerProperties getProperties();
J
Jialin Qiao 已提交
293

Q
qiaojialin 已提交
294 295 296
	TSExecuteStatementResp insert(1:TSInsertionReq req);

	TSExecuteBatchStatementResp insertBatch(1:TSBatchInsertionReq req);
J
Jialin Qiao 已提交
297

298
	TSStatus setStorageGroup(1:string storageGroup);
299

300
	TSStatus createTimeseries(1:TSCreateTimeseriesReq req);
301

Q
qiaojialin 已提交
302 303
  TSStatus deleteTimeseries(1:list<string> path)

304
	TSStatus insertRow(1:TSInsertReq req);
Q
qiaojialin 已提交
305

Q
qiaojialin 已提交
306
	TSStatus deleteData(1:TSDeleteDataReq req);
307

J
Jialin Qiao 已提交
308
	i64 requestStatementId();
309
}