iotdb/protocal/
mod.rs

1//
2// Licensed to the Apache Software Foundation (ASF) under one
3// or more contributor license agreements.  See the NOTICE file
4// distributed with this work for additional information
5// regarding copyright ownership.  The ASF licenses this file
6// to you under the Apache License, Version 2.0 (the
7// "License"); you may not use this file except in compliance
8// with the License.  You may obtain a copy of the License at
9//
10//  http://www.apache.org/licenses/LICENSE-2.0
11//
12// Unless required by applicable law or agreed to in writing,
13// software distributed under the License is distributed on an
14// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15// KIND, either express or implied.  See the License for the
16// specific language governing permissions and limitations
17// under the License.
18//
19
20pub const FLAG: u8 = 0x80;
21
22pub const SUCCESS_STATUS: i32 = 200;
23pub const STILL_EXECUTING_STATUS: i32 = 201;
24pub const INVALID_HANDLE_STATUS: i32 = 202;
25pub const INCOMPATIBLE_VERSION: i32 = 203;
26pub const NODE_DELETE_FAILED_ERROR: i32 = 298;
27pub const ALIAS_ALREADY_EXIST_ERROR: i32 = 299;
28pub const PATH_ALREADY_EXIST_ERROR: i32 = 300;
29pub const PATH_NOT_EXIST_ERROR: i32 = 301;
30pub const UNSUPPORTED_FETCH_METADATA_OPERATION_ERROR: i32 = 302;
31pub const METADATA_ERROR: i32 = 303;
32pub const TIMESERIES_NOT_EXIST: i32 = 304;
33pub const OUT_OF_TTLERROR: i32 = 305;
34pub const CONFIG_ADJUSTER: i32 = 306;
35pub const MERGE_ERROR: i32 = 307;
36pub const SYSTEM_CHECK_ERROR: i32 = 308;
37pub const SYNC_DEVICE_OWNER_CONFLICT_ERROR: i32 = 309;
38pub const SYNC_CONNECTION_EXCEPTION: i32 = 310;
39pub const STORAGE_GROUP_PROCESSOR_ERROR: i32 = 311;
40pub const STORAGE_GROUP_ERROR: i32 = 312;
41pub const STORAGE_ENGINE_ERROR: i32 = 313;
42pub const TSFILE_PROCESSOR_ERROR: i32 = 314;
43pub const PATH_ILLEGAL: i32 = 315;
44pub const LOAD_FILE_ERROR: i32 = 316;
45pub const STORAGE_GROUP_NOT_READY: i32 = 317;
46
47pub const EXECUTE_STATEMENT_ERROR: i32 = 400;
48pub const SQLPARSE_ERROR: i32 = 401;
49pub const GENERATE_TIME_ZONE_ERROR: i32 = 402;
50pub const SET_TIME_ZONE_ERROR: i32 = 403;
51pub const NOT_STORAGE_GROUP_ERROR: i32 = 404;
52pub const QUERY_NOT_ALLOWED: i32 = 405;
53pub const AST_FORMAT_ERROR: i32 = 406;
54pub const LOGICAL_OPERATOR_ERROR: i32 = 407;
55pub const LOGICAL_OPTIMIZE_ERROR: i32 = 408;
56pub const UNSUPPORTED_FILL_TYPE_ERROR: i32 = 409;
57pub const PATH_ERRO_R: i32 = 410;
58pub const QUERY_PROCESS_ERROR: i32 = 411;
59pub const WRITE_PROCESS_ERROR: i32 = 412;
60pub const WRITE_PROCESS_REJECT: i32 = 413;
61
62pub const UNSUPPORTED_INDEX_FUNC_ERROR: i32 = 421;
63pub const UNSUPPORTED_INDEX_TYPE_ERROR: i32 = 422;
64
65pub const INTERNAL_SERVER_ERROR: i32 = 500;
66pub const CLOSE_OPERATION_ERROR: i32 = 501;
67pub const READ_ONLY_SYSTEM_ERROR: i32 = 502;
68pub const DISK_SPACE_INSUFFICIENT_ERROR: i32 = 503;
69pub const START_UP_ERROR: i32 = 504;
70pub const SHUT_DOWN_ERROROR: i32 = 505;
71pub const MULTIPLE_ERROR: i32 = 506;
72
73pub const WRONG_LOGIN_PASSWORD_ERROR: i32 = 600;
74pub const NOT_LOGIN_ERROR: i32 = 601;
75pub const NO_PERMISSION_ERROR: i32 = 602;
76pub const UNINITIALIZED_AUTH_ERROR: i32 = 603;
77
78pub const PARTITION_NOT_READY: i32 = 700;
79pub const TIME_OUT: i32 = 701;
80pub const NO_LEADER: i32 = 702;
81pub const UNSUPPORTED_OPERATION: i32 = 703;
82pub const NODE_READ_ONLY: i32 = 704;
83pub const CONSISTENCY_FAILURE: i32 = 705;
84pub const NO_CONNECTION: i32 = 706;
85pub const NEED_REDIRECTION: i32 = 707;
86
87#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
88pub enum TSDataType {
89    Boolean = 0,
90    Int32 = 1,
91    Int64 = 2,
92    Float = 3,
93    Double = 4,
94    Text = 5,
95}
96
97impl From<TSDataType> for i32 {
98    fn from(t: TSDataType) -> i32 {
99        match t {
100            TSDataType::Boolean => 0,
101            TSDataType::Int32 => 1,
102            TSDataType::Int64 => 2,
103            TSDataType::Float => 3,
104            TSDataType::Double => 4,
105            TSDataType::Text => 5,
106        }
107    }
108}
109
110impl From<&String> for TSDataType {
111    fn from(t: &String) -> Self {
112        match t.as_str() {
113            "BOOLEAN" => TSDataType::Boolean,
114            "INT32" => TSDataType::Int32,
115            "INT64" => TSDataType::Int64,
116            "FLOAT" => TSDataType::Float,
117            "DOUBLE" => TSDataType::Double,
118            "TEXT" => TSDataType::Text,
119            _ => panic!("Illegal datatype {}", t),
120        }
121    }
122}
123
124#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
125pub enum TSEncoding {
126    Plain = 0,
127    PlainDictionary = 1,
128    RLE = 2,
129    Diff = 3,
130    Ts2diff = 4,
131    Bitmap = 5,
132    GorillaV1 = 6,
133    Regular = 7,
134    Gorilla = 8,
135}
136
137impl From<TSEncoding> for i32 {
138    fn from(t: TSEncoding) -> i32 {
139        match t {
140            TSEncoding::Plain => 0,
141            TSEncoding::PlainDictionary => 1,
142            TSEncoding::RLE => 2,
143            TSEncoding::Diff => 3,
144            TSEncoding::Ts2diff => 4,
145            TSEncoding::Bitmap => 5,
146            TSEncoding::GorillaV1 => 6,
147            TSEncoding::Regular => 7,
148            TSEncoding::Gorilla => 8,
149        }
150    }
151}
152
153#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
154pub enum TSCompressionType {
155    UNCOMPRESSED = 0,
156    SNAPPY = 1,
157    GZIP = 2,
158    LZO = 3,
159    SDT = 4,
160    PAA = 5,
161    PLA = 6,
162    LZ4 = 7,
163}
164
165impl From<TSCompressionType> for i32 {
166    fn from(t: TSCompressionType) -> i32 {
167        match t {
168            TSCompressionType::UNCOMPRESSED => 0,
169            TSCompressionType::SNAPPY => 1,
170            TSCompressionType::GZIP => 2,
171            TSCompressionType::LZO => 3,
172            TSCompressionType::SDT => 4,
173            TSCompressionType::PAA => 5,
174            TSCompressionType::PLA => 6,
175            TSCompressionType::LZ4 => 7,
176        }
177    }
178}