1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 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
 76
 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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
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
252
253
254
255
256
257
258
259
260
261
262
263
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
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
// Generated from OmniSciDB commit efe1d864d6804d67e796fa4213219a2df2e49901
// Autogenerated by Thrift Compiler (0.13.0)
// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING

#![allow(unused_imports)]
#![allow(unused_extern_crates)]
#![cfg_attr(feature = "cargo-clippy", allow(clippy::too_many_arguments, clippy::type_complexity))]
#![cfg_attr(rustfmt, rustfmt_skip)]

extern crate thrift;

use thrift::OrderedFloat;
use std::cell::RefCell;
use std::collections::{BTreeMap, BTreeSet};
use std::convert::{From, TryFrom};
use std::default::Default;
use std::error::Error;
use std::fmt;
use std::fmt::{Display, Formatter};
use std::rc::Rc;

use thrift::{ApplicationError, ApplicationErrorKind, ProtocolError, ProtocolErrorKind, TThriftClient};
use thrift::protocol::{TFieldIdentifier, TListIdentifier, TMapIdentifier, TMessageIdentifier, TMessageType, TInputProtocol, TOutputProtocol, TSetIdentifier, TStructIdentifier, TType};
use thrift::protocol::field_id;
use thrift::protocol::verify_expected_message_type;
use thrift::protocol::verify_expected_sequence_number;
use thrift::protocol::verify_expected_service_call;
use thrift::protocol::verify_required_field_exists;
use thrift::server::TProcessor;

#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum TDeviceType {
  Cpu = 0,
  Gpu = 1,
}

impl TDeviceType {
  pub fn write_to_out_protocol(&self, o_prot: &mut dyn TOutputProtocol) -> thrift::Result<()> {
    o_prot.write_i32(*self as i32)
  }
  pub fn read_from_in_protocol(i_prot: &mut dyn TInputProtocol) -> thrift::Result<TDeviceType> {
    let enum_value = i_prot.read_i32()?;
    TDeviceType::try_from(enum_value)  }
}

impl TryFrom<i32> for TDeviceType {
  type Error = thrift::Error;  fn try_from(i: i32) -> Result<Self, Self::Error> {
    match i {
      0 => Ok(TDeviceType::Cpu),
      1 => Ok(TDeviceType::Gpu),
      _ => {
        Err(
          thrift::Error::Protocol(
            ProtocolError::new(
              ProtocolErrorKind::InvalidData,
              format!("cannot convert enum constant {} to TDeviceType", i)
            )
          )
        )
      },
    }
  }
}

#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum TDatumType {
  Smallint = 0,
  Int = 1,
  Bigint = 2,
  Float = 3,
  Decimal = 4,
  Double = 5,
  Str = 6,
  Time = 7,
  Timestamp = 8,
  Date = 9,
  Bool = 10,
  IntervalDayTime = 11,
  IntervalYearMonth = 12,
  Point = 13,
  Linestring = 14,
  Polygon = 15,
  Multipolygon = 16,
  Tinyint = 17,
  Geometry = 18,
  Geography = 19,
}

impl TDatumType {
  pub fn write_to_out_protocol(&self, o_prot: &mut dyn TOutputProtocol) -> thrift::Result<()> {
    o_prot.write_i32(*self as i32)
  }
  pub fn read_from_in_protocol(i_prot: &mut dyn TInputProtocol) -> thrift::Result<TDatumType> {
    let enum_value = i_prot.read_i32()?;
    TDatumType::try_from(enum_value)  }
}

impl TryFrom<i32> for TDatumType {
  type Error = thrift::Error;  fn try_from(i: i32) -> Result<Self, Self::Error> {
    match i {
      0 => Ok(TDatumType::Smallint),
      1 => Ok(TDatumType::Int),
      2 => Ok(TDatumType::Bigint),
      3 => Ok(TDatumType::Float),
      4 => Ok(TDatumType::Decimal),
      5 => Ok(TDatumType::Double),
      6 => Ok(TDatumType::Str),
      7 => Ok(TDatumType::Time),
      8 => Ok(TDatumType::Timestamp),
      9 => Ok(TDatumType::Date),
      10 => Ok(TDatumType::Bool),
      11 => Ok(TDatumType::IntervalDayTime),
      12 => Ok(TDatumType::IntervalYearMonth),
      13 => Ok(TDatumType::Point),
      14 => Ok(TDatumType::Linestring),
      15 => Ok(TDatumType::Polygon),
      16 => Ok(TDatumType::Multipolygon),
      17 => Ok(TDatumType::Tinyint),
      18 => Ok(TDatumType::Geometry),
      19 => Ok(TDatumType::Geography),
      _ => {
        Err(
          thrift::Error::Protocol(
            ProtocolError::new(
              ProtocolErrorKind::InvalidData,
              format!("cannot convert enum constant {} to TDatumType", i)
            )
          )
        )
      },
    }
  }
}

#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum TEncodingType {
  None = 0,
  Fixed = 1,
  Rl = 2,
  Diff = 3,
  Dict = 4,
  Sparse = 5,
  Geoint = 6,
  DateInDays = 7,
}

impl TEncodingType {
  pub fn write_to_out_protocol(&self, o_prot: &mut dyn TOutputProtocol) -> thrift::Result<()> {
    o_prot.write_i32(*self as i32)
  }
  pub fn read_from_in_protocol(i_prot: &mut dyn TInputProtocol) -> thrift::Result<TEncodingType> {
    let enum_value = i_prot.read_i32()?;
    TEncodingType::try_from(enum_value)  }
}

impl TryFrom<i32> for TEncodingType {
  type Error = thrift::Error;  fn try_from(i: i32) -> Result<Self, Self::Error> {
    match i {
      0 => Ok(TEncodingType::None),
      1 => Ok(TEncodingType::Fixed),
      2 => Ok(TEncodingType::Rl),
      3 => Ok(TEncodingType::Diff),
      4 => Ok(TEncodingType::Dict),
      5 => Ok(TEncodingType::Sparse),
      6 => Ok(TEncodingType::Geoint),
      7 => Ok(TEncodingType::DateInDays),
      _ => {
        Err(
          thrift::Error::Protocol(
            ProtocolError::new(
              ProtocolErrorKind::InvalidData,
              format!("cannot convert enum constant {} to TEncodingType", i)
            )
          )
        )
      },
    }
  }
}

//
// TTypeInfo
//

#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct TTypeInfo {
  pub type_: Option<TDatumType>,
  pub nullable: Option<bool>,
  pub is_array: Option<bool>,
  pub encoding: Option<TEncodingType>,
  pub precision: Option<i32>,
  pub scale: Option<i32>,
  pub comp_param: Option<i32>,
  pub size: Option<i32>,
}

impl TTypeInfo {
  pub fn new<F1, F2, F3, F4, F5, F6, F7, F8>(type_: F1, nullable: F2, is_array: F3, encoding: F4, precision: F5, scale: F6, comp_param: F7, size: F8) -> TTypeInfo where F1: Into<Option<TDatumType>>, F2: Into<Option<bool>>, F3: Into<Option<bool>>, F4: Into<Option<TEncodingType>>, F5: Into<Option<i32>>, F6: Into<Option<i32>>, F7: Into<Option<i32>>, F8: Into<Option<i32>> {
    TTypeInfo {
      type_: type_.into(),
      nullable: nullable.into(),
      is_array: is_array.into(),
      encoding: encoding.into(),
      precision: precision.into(),
      scale: scale.into(),
      comp_param: comp_param.into(),
      size: size.into(),
    }
  }
  pub fn read_from_in_protocol(i_prot: &mut dyn TInputProtocol) -> thrift::Result<TTypeInfo> {
    i_prot.read_struct_begin()?;
    let mut f_1: Option<TDatumType> = None;
    let mut f_2: Option<bool> = Some(false);
    let mut f_3: Option<bool> = Some(false);
    let mut f_4: Option<TEncodingType> = None;
    let mut f_5: Option<i32> = Some(0);
    let mut f_6: Option<i32> = Some(0);
    let mut f_7: Option<i32> = Some(0);
    let mut f_8: Option<i32> = None;
    loop {
      let field_ident = i_prot.read_field_begin()?;
      if field_ident.field_type == TType::Stop {
        break;
      }
      let field_id = field_id(&field_ident)?;
      match field_id {
        1 => {
          let val = TDatumType::read_from_in_protocol(i_prot)?;
          f_1 = Some(val);
        },
        2 => {
          let val = i_prot.read_bool()?;
          f_2 = Some(val);
        },
        3 => {
          let val = i_prot.read_bool()?;
          f_3 = Some(val);
        },
        4 => {
          let val = TEncodingType::read_from_in_protocol(i_prot)?;
          f_4 = Some(val);
        },
        5 => {
          let val = i_prot.read_i32()?;
          f_5 = Some(val);
        },
        6 => {
          let val = i_prot.read_i32()?;
          f_6 = Some(val);
        },
        7 => {
          let val = i_prot.read_i32()?;
          f_7 = Some(val);
        },
        8 => {
          let val = i_prot.read_i32()?;
          f_8 = Some(val);
        },
        _ => {
          i_prot.skip(field_ident.field_type)?;
        },
      };
      i_prot.read_field_end()?;
    }
    i_prot.read_struct_end()?;
    let ret = TTypeInfo {
      type_: f_1,
      nullable: f_2,
      is_array: f_3,
      encoding: f_4,
      precision: f_5,
      scale: f_6,
      comp_param: f_7,
      size: f_8,
    };
    Ok(ret)
  }
  pub fn write_to_out_protocol(&self, o_prot: &mut dyn TOutputProtocol) -> thrift::Result<()> {
    let struct_ident = TStructIdentifier::new("TTypeInfo");
    o_prot.write_struct_begin(&struct_ident)?;
    if let Some(ref fld_var) = self.type_ {
      o_prot.write_field_begin(&TFieldIdentifier::new("type", TType::I32, 1))?;
      fld_var.write_to_out_protocol(o_prot)?;
      o_prot.write_field_end()?;
      ()
    } else {
      ()
    }
    if let Some(fld_var) = self.nullable {
      o_prot.write_field_begin(&TFieldIdentifier::new("nullable", TType::Bool, 2))?;
      o_prot.write_bool(fld_var)?;
      o_prot.write_field_end()?;
      ()
    } else {
      ()
    }
    if let Some(fld_var) = self.is_array {
      o_prot.write_field_begin(&TFieldIdentifier::new("is_array", TType::Bool, 3))?;
      o_prot.write_bool(fld_var)?;
      o_prot.write_field_end()?;
      ()
    } else {
      ()
    }
    if let Some(ref fld_var) = self.encoding {
      o_prot.write_field_begin(&TFieldIdentifier::new("encoding", TType::I32, 4))?;
      fld_var.write_to_out_protocol(o_prot)?;
      o_prot.write_field_end()?;
      ()
    } else {
      ()
    }
    if let Some(fld_var) = self.precision {
      o_prot.write_field_begin(&TFieldIdentifier::new("precision", TType::I32, 5))?;
      o_prot.write_i32(fld_var)?;
      o_prot.write_field_end()?;
      ()
    } else {
      ()
    }
    if let Some(fld_var) = self.scale {
      o_prot.write_field_begin(&TFieldIdentifier::new("scale", TType::I32, 6))?;
      o_prot.write_i32(fld_var)?;
      o_prot.write_field_end()?;
      ()
    } else {
      ()
    }
    if let Some(fld_var) = self.comp_param {
      o_prot.write_field_begin(&TFieldIdentifier::new("comp_param", TType::I32, 7))?;
      o_prot.write_i32(fld_var)?;
      o_prot.write_field_end()?;
      ()
    } else {
      ()
    }
    if let Some(fld_var) = self.size {
      o_prot.write_field_begin(&TFieldIdentifier::new("size", TType::I32, 8))?;
      o_prot.write_i32(fld_var)?;
      o_prot.write_field_end()?;
      ()
    } else {
      ()
    }
    o_prot.write_field_stop()?;
    o_prot.write_struct_end()
  }
}

impl Default for TTypeInfo {
  fn default() -> Self {
    TTypeInfo{
      type_: None,
      nullable: Some(false),
      is_array: Some(false),
      encoding: None,
      precision: Some(0),
      scale: Some(0),
      comp_param: Some(0),
      size: Some(0),
    }
  }
}