MCPcopy Create free account
hub / github.com/influxdata/influxdb / test_encode_decode

Function test_encode_decode

core/mutable_batch_pb/tests/encode.rs:12–47  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

10
11#[test]
12fn test_encode_decode() {
13 let (_, batch) = mutable_batch_lp::test_helpers::lp_to_mutable_batch(
14 r#"
15 foo,t1=asdf iv=1i,uv=774u,fv=1.0,bv=true,sv="hi" 1
16 foo,t1=bar uv=1u,fv=32.0,bv=true 2
17 foo,t1=bar iv=1i,uv=1u,fv=1.0,sv="bye" 3
18 foo iv=-3405i,uv=566u,bv=false,sv="hi" 4
19 foo,t1=asdf iv=1i,fv=1.23,bv=true,sv="hi" 5
20 "#,
21 );
22
23 let expected = &[
24 "+-------+------+-------+-----+------+--------------------------------+-----+",
25 "| bv | fv | iv | sv | t1 | time | uv |",
26 "+-------+------+-------+-----+------+--------------------------------+-----+",
27 "| true | 1.0 | 1 | hi | asdf | 1970-01-01T00:00:00.000000001Z | 774 |",
28 "| true | 32.0 | | | bar | 1970-01-01T00:00:00.000000002Z | 1 |",
29 "| | 1.0 | 1 | bye | bar | 1970-01-01T00:00:00.000000003Z | 1 |",
30 "| false | | -3405 | hi | | 1970-01-01T00:00:00.000000004Z | 566 |",
31 "| true | 1.23 | 1 | hi | asdf | 1970-01-01T00:00:00.000000005Z | |",
32 "+-------+------+-------+-----+------+--------------------------------+-----+",
33 ];
34
35 assert_batches_eq!(
36 expected,
37 &[batch.clone().try_into_arrow(Projection::All).unwrap()]
38 );
39
40 let encoded = encode_batch(42, &batch);
41 assert_eq!(encoded.table_id, 42);
42
43 let mut batch = MutableBatch::new();
44 write_table_batch(&mut batch, &encoded).unwrap();
45
46 assert_batches_eq!(expected, &[batch.try_into_arrow(Projection::All).unwrap()]);
47}
48
49// This test asserts columns containing no values do not prevent an encoded
50// batch from being deserialize:

Callers

nothing calls this directly

Calls 3

encode_batchFunction · 0.85
write_table_batchFunction · 0.85
lp_to_mutable_batchFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…