Skip to content

Commit 37fb31d

Browse files
committed
release 0.3.9
1 parent c81c506 commit 37fb31d

File tree

6 files changed

+106
-48
lines changed

6 files changed

+106
-48
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ keywords = ["iotdb", "iotdb-client-rust", "apache-iotdb"]
2323
license = "Apache-2.0"
2424
name = "iotdb-client-rs"
2525
readme = "README.md"
26-
repository = "https://github.com/manlge/iotdb-client-rs.git"
27-
version = "0.3.8"
26+
repository = "https://github.com/iotdb-lab/iotdb-client-rs.git"
27+
version = "0.3.9"
2828

2929
[lib]
3030
name = "iotdb"

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Put this in your `Cargo.toml`:
6161

6262
```toml
6363
[dependencies]
64-
iotdb-client-rs="^0.3.8"
64+
iotdb-client-rs="^0.3.9"
6565
```
6666

6767
## Example
@@ -70,7 +70,7 @@ Put this in your example's `Cargo.toml`:
7070

7171
```toml
7272
[dependencies]
73-
iotdb-client-rs="^0.3.8"
73+
iotdb-client-rs="^0.3.9"
7474
chrono="0.4.19"
7575
prettytable-rs="0.8.0"
7676
structopt = "0.3.25"

src/client/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ pub trait Session<'a> {
362362

363363
fn insert_records(
364364
&mut self,
365-
device_ids: Vec<&str>,
365+
prefix_path: Vec<&str>,
366366
measurements: Vec<Vec<&str>>,
367367
values: Vec<Vec<Value>>,
368368
timestamps: Vec<i64>,

src/client/remote.rs

Lines changed: 36 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
//
1919

2020
use std::collections::{BTreeMap, HashMap};
21+
use std::error::Error;
2122
use std::vec;
2223
use thrift::transport::TIoChannel;
2324

@@ -94,38 +95,38 @@ impl<'a> RpcSession {
9495
pub fn new(config: &Config) -> Result<Self> {
9596
let mut tcp_channel = TTcpChannel::new();
9697
let endpint = format!("{}:{}", config.host, config.port);
97-
match tcp_channel.open(&endpint) {
98-
Ok(_) => {
99-
let (i_chan, o_chan) = tcp_channel.split()?;
100-
101-
let (i_prot, o_prot) = (
102-
TFramedReadTransport::new(i_chan),
103-
TFramedWriteTransport::new(o_chan),
104-
);
105-
106-
let (input_protocol, output_protocol): (
107-
Box<dyn TInputProtocol>,
108-
Box<dyn TOutputProtocol>,
109-
) = match config.enable_compression {
110-
false => (
111-
Box::new(TBinaryInputProtocol::new(i_prot, true)),
112-
Box::new(TBinaryOutputProtocol::new(o_prot, true)),
113-
),
114-
true => (
115-
Box::new(TCompactInputProtocol::new(i_prot)),
116-
Box::new(TCompactOutputProtocol::new(o_prot)),
117-
),
118-
};
11998

120-
Ok(Self {
121-
config: config.clone(),
122-
session_id: None,
123-
statement_id: -1,
124-
client: TSIServiceSyncClient::new(input_protocol, output_protocol),
125-
})
126-
}
127-
Err(err) => Err(format!("failed to connect to {}, {:?}", endpint, err).into()),
128-
}
99+
tcp_channel.open(&endpint).map_err(|err| {
100+
Box::<dyn Error>::from(
101+
format!("failed to connect to {}, {:?}", endpint, err).to_string(),
102+
)
103+
})?;
104+
105+
let (i_chan, o_chan) = tcp_channel.split()?;
106+
107+
let (i_prot, o_prot) = (
108+
TFramedReadTransport::new(i_chan),
109+
TFramedWriteTransport::new(o_chan),
110+
);
111+
112+
let (input_protocol, output_protocol): (Box<dyn TInputProtocol>, Box<dyn TOutputProtocol>) =
113+
match config.enable_compression {
114+
false => (
115+
Box::new(TBinaryInputProtocol::new(i_prot, true)),
116+
Box::new(TBinaryOutputProtocol::new(o_prot, true)),
117+
),
118+
true => (
119+
Box::new(TCompactInputProtocol::new(i_prot)),
120+
Box::new(TCompactOutputProtocol::new(o_prot)),
121+
),
122+
};
123+
124+
Ok(Self {
125+
config: config.clone(),
126+
session_id: None,
127+
statement_id: -1,
128+
client: TSIServiceSyncClient::new(input_protocol, output_protocol),
129+
})
129130
}
130131
}
131132

@@ -237,6 +238,7 @@ pub struct RpcDataSet<'a> {
237238
}
238239

239240
impl<'a> RpcDataSet<'a> {
241+
#[allow(dead_code)]
240242
fn is_null(&self, column_index: usize, row_index: usize) -> bool {
241243
let bitmap = self.bitmaps[column_index];
242244
let shift = row_index % 8;
@@ -838,7 +840,7 @@ impl<'a> Session<'a> for RpcSession {
838840

839841
fn insert_records(
840842
&mut self,
841-
device_ids: Vec<&str>,
843+
prefix_path: Vec<&str>,
842844
measurements: Vec<Vec<&str>>,
843845
values: Vec<Vec<super::Value>>,
844846
timestamps: Vec<i64>,
@@ -857,7 +859,7 @@ impl<'a> Session<'a> for RpcSession {
857859
.collect();
858860
let status = self.client.insert_records(TSInsertRecordsReq {
859861
session_id: session_id,
860-
prefix_paths: device_ids.iter().map(ToString::to_string).collect(),
862+
prefix_paths: prefix_path.iter().map(ToString::to_string).collect(),
861863
measurements_list: measurements
862864
.iter()
863865
.map(|ms| ms.iter().map(ToString::to_string).collect())
@@ -919,13 +921,7 @@ impl<'a> Session<'a> for RpcSession {
919921
.collect()
920922
})
921923
.collect(),
922-
values_list: tablets
923-
.iter()
924-
.map(|tablet| {
925-
let values: Vec<u8> = (*tablet).into();
926-
values
927-
})
928-
.collect(),
924+
values_list: tablets.iter().map(|tablet| Into::into(*tablet)).collect(),
929925
timestamps_list: tablets
930926
.iter()
931927
.map(|tablet| {

src/client/rpc.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#![allow(unused_extern_crates)]
2525
#![allow(clippy::too_many_arguments, clippy::type_complexity, clippy::vec_box)]
2626
#![cfg_attr(rustfmt, rustfmt_skip)]
27+
#![allow(dead_code)]
2728

2829
use std::cell::RefCell;
2930
use std::collections::{BTreeMap, BTreeSet};

src/lib.rs

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,70 @@ pub mod protocal;
2121

2222
#[cfg(test)]
2323
mod tests {
24+
use crate::client::Value;
25+
use std::vec::Vec;
26+
27+
#[test]
28+
fn test_value_to_string() {
29+
let values = vec![
30+
Value::Bool(true),
31+
Value::Int32(1),
32+
Value::Int64(2),
33+
Value::Float(3.1),
34+
Value::Double(4.1),
35+
Value::Text(String::from("iotdb")),
36+
Value::Null,
37+
];
38+
39+
let strings = vec!["true", "1", "2", "3.1", "4.1", "iotdb", "null"];
40+
41+
for (v, s) in values.into_iter().zip(strings.into_iter()) {
42+
assert_eq!(v.to_string(), s);
43+
}
44+
}
45+
2446
#[test]
25-
fn it_works() {
26-
let result = 2 + 2;
27-
assert_eq!(result, 4);
47+
fn test_value_into() {
48+
let values = vec![
49+
Value::Bool(true),
50+
Value::Int32(1),
51+
Value::Int64(2),
52+
Value::Float(3.1),
53+
Value::Double(4.1),
54+
Value::Text(String::from("iotdb")),
55+
];
56+
57+
let bytes = vec![
58+
vec![0u8, 1u8],
59+
vec![vec![1u8], 1_i32.to_be_bytes().to_vec()]
60+
.into_iter()
61+
.flatten()
62+
.collect(),
63+
vec![vec![2u8], 2_i64.to_be_bytes().to_vec()]
64+
.into_iter()
65+
.flatten()
66+
.collect(),
67+
vec![vec![3u8], 3.1_f32.to_be_bytes().to_vec()]
68+
.into_iter()
69+
.flatten()
70+
.collect(),
71+
vec![vec![4u8], 4.1_f64.to_be_bytes().to_vec()]
72+
.into_iter()
73+
.flatten()
74+
.collect(),
75+
vec![
76+
vec![5u8], //datatype text
77+
5_i32.to_be_bytes().to_vec(), //len of iotdb
78+
"iotdb".to_string().as_bytes().to_vec(),
79+
]
80+
.into_iter()
81+
.flatten()
82+
.collect(),
83+
];
84+
85+
for (v, bys) in values.into_iter().zip(bytes.into_iter()) {
86+
let value_bys: Vec<u8> = (&v).into();
87+
assert_eq!(value_bys, bys);
88+
}
2889
}
2990
}

0 commit comments

Comments
 (0)