rpc.thrift 8.1 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 22 23 24 25 26 27 28 29 30 31 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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75


// The return status code contained in each response.
enum TS_StatusCode {
  SUCCESS_STATUS,
  SUCCESS_WITH_INFO_STATUS,
  STILL_EXECUTING_STATUS,
  ERROR_STATUS,
  INVALID_HANDLE_STATUS
}

// The return status of a remote request
struct TS_Status {
  1: required TS_StatusCode statusCode

  // If status is SUCCESS_WITH_INFO, info_msgs may be populated with
  // additional diagnostic information.
  2: optional list<string> infoMessages

  // If status is ERROR, then the following fields may be set
  3: optional string sqlState  // as defined in the ISO/IEF CLI specification
  4: optional i32 errorCode    // internal error code
  5: optional string errorMessage
}

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 {
	1: required TS_Status status
	2: optional TSOperationHandle operationHandle
  // Column names in select statement of SQL
	3: optional list<string> columns
	4: optional string operationType
76
	5: optional bool ignoreTimeStamp
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 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 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
}

enum TSProtocolVersion {
  TSFILE_SERVICE_PROTOCOL_V1,
}

// 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 {
  1: required TS_Status status

  // The protocol version that the server is using.
  2: required TSProtocolVersion serverProtocolVersion = TSProtocolVersion.TSFILE_SERVICE_PROTOCOL_V1

  // 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 {
  1: required TSProtocolVersion client_protocol = TSProtocolVersion.TSFILE_SERVICE_PROTOCOL_V1
  2: optional string username
  3: optional string password
  4: optional map<string, string> configuration
}

struct TSCloseSessionResp {
  1: required TS_Status status
}

// 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 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{
	1: required TS_Status status
  // For each value in result, Statement.SUCCESS_NO_INFO represents success, Statement.EXECUTE_FAILED represents fail otherwise.  
	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
}

struct TSGetOperationStatusResp {
  1: required TS_Status status
}

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

struct TSCancelOperationResp {
  1: required TS_Status status
}


// CloseOperation()
struct TSCloseOperationReq {
  1: required TSOperationHandle operationHandle
177
  2: required i64 queryId
J
Jialin Qiao 已提交
178
  3: optional i64 stmtId
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
}

struct TSCloseOperationResp {
  1: required TS_Status status
}

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
  8: optional string type;
}

struct TSRowRecord{
  1: required i64 timestamp
  // column values
199
  2: required list<TSDataValue> values
200 201 202 203 204 205 206 207 208
}

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

struct TSFetchResultsReq{
	1: required string statement
	2: required i32 fetch_size
209
	3: required i64 queryId
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251
}

struct TSFetchResultsResp{
	1: required TS_Status status
	2: required bool hasResultSet
	3: optional TSQueryDataSet queryDataSet
}

struct TSFetchMetadataResp{
		1: required TS_Status status
		2: optional string metadataInJson
		3: optional list<string> ColumnsList
		4: optional string dataType
		5: optional list<list<string>> showTimeseriesList
		7: optional set<string> showStorageGroups
}

struct TSFetchMetadataReq{
		1: required string type
		2: optional string columnPath
}

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

struct TSGetTimeZoneResp {
    1: required TS_Status status
    2: required string timeZone
}

struct TSSetTimeZoneReq {
    1: required string timeZone
}

struct TSSetTimeZoneResp {
    1: required TS_Status status
}

J
Jialin Qiao 已提交
252 253 254 255 256 257 258 259
struct TSInsertionReq {
    1: optional string deviceId
    2: optional list<string> measurements
    3: optional list<string> values
    4: optional i64 timestamp
    5: required i64 stmtId
}

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

266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289
service TSIService {
	TSOpenSessionResp openSession(1:TSOpenSessionReq req);

	TSCloseSessionResp closeSession(1:TSCloseSessionReq req);

	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)

	TSCancelOperationResp cancelOperation(1:TSCancelOperationReq req);

	TSCloseOperationResp closeOperation(1:TSCloseOperationReq req);

	TSGetTimeZoneResp getTimeZone();

	TSSetTimeZoneResp setTimeZone(1:TSSetTimeZoneReq req);
X
XuYi 已提交
290 291
	
	ServerProperties getProperties();
J
Jialin Qiao 已提交
292 293 294 295

	TSExecuteStatementResp executeInsertion(1:TSInsertionReq req);

	i64 requestStatementId();
X
XuYi 已提交
296
	}