Skip to content

Commit 94cb8c5

Browse files
committed
tablet.into performance optimization
1 parent 56f8b11 commit 94cb8c5

File tree

3 files changed

+28
-15
lines changed

3 files changed

+28
-15
lines changed

Cargo.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,26 @@
1414
# under the License.
1515

1616
[package]
17-
name = "iotdb-client-rs"
18-
version = "0.3.7"
1917
authors = ["Mark Liu <[email protected]>"]
18+
categories = ["database"]
19+
description = "Rust client library for Apache IoTDB"
20+
documentation = "https://docs.rs/iotdb-client-rs"
2021
edition = "2021"
22+
keywords = ["iotdb", "iotdb-client-rust", "apache-iotdb"]
2123
license = "Apache-2.0"
24+
name = "iotdb-client-rs"
2225
readme = "README.md"
23-
description = "Rust client library for Apache IoTDB"
24-
keywords = ["iotdb", "iotdb-client-rust", "apache-iotdb"]
2526
repository = "https://github.com/manlge/iotdb-client-rs.git"
26-
categories = ["database"]
27-
documentation = "https://docs.rs/iotdb-client-rs"
27+
version = "0.3.8"
2828

2929
[lib]
3030
name = "iotdb"
3131

3232
[dev-dependencies]
33-
chrono="0.4.19"
33+
chrono = "0.4.19"
3434
prettytable-rs = "0.8.0"
3535
structopt = "0.3.25"
3636

3737
[dependencies]
38-
thrift="0.15.0"
39-
permutation = "0.2.5"
38+
permutation = "0.2.5"
39+
thrift = "0.15.0"

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.7"
64+
iotdb-client-rs="^0.3.8"
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.7"
73+
iotdb-client-rs="^0.3.8"
7474
chrono="0.4.19"
7575
prettytable-rs="0.8.0"
7676
structopt = "0.3.25"

src/client/mod.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,23 @@ impl Into<Vec<u8>> for &Tablet {
6767
fn into(self) -> Vec<u8> {
6868
let mut buffer: Vec<u8> = Vec::with_capacity(self.get_row_count()*self.get_column_count()*8);
6969
self.columns.iter().for_each(|column| {
70-
column.iter().for_each(|v| {
71-
let mut value_data: Vec<u8> = v.into();
72-
value_data.remove(0); //first item is datatype, remove it.
73-
buffer.append(&mut value_data);
70+
column.iter().for_each(|value| {
71+
match value{
72+
Value::Bool(v) => match v {
73+
true => buffer.push(1),
74+
false => buffer.push(0),
75+
},
76+
Value::Int32(v) => buffer.append(&mut v.to_be_bytes().to_vec()),
77+
Value::Int64(v) => buffer.append(&mut v.to_be_bytes().to_vec()),
78+
Value::Float(v) => buffer.append(&mut v.to_be_bytes().to_vec()),
79+
Value::Double(v) => buffer.append(&mut v.to_be_bytes().to_vec()),
80+
Value::Text(t) => {
81+
let len = t.len() as i32;
82+
buffer.append(&mut len.to_be_bytes().to_vec());
83+
buffer.append(&mut t.as_bytes().to_vec());
84+
},
85+
Value::Null => unimplemented!("null value doesn't implemented for tablet"),
86+
}
7487
});
7588
});
7689
buffer

0 commit comments

Comments
 (0)