|
| 1 | +// Copyright 2023 Datafuse Labs. |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +use databend_common_meta_app::schema::TableStatistics; |
| 16 | +use fastrace::func_name; |
| 17 | + |
| 18 | +use crate::common; |
| 19 | + |
| 20 | +// These bytes are built when a new version in introduced, |
| 21 | +// and are kept for backward compatibility test. |
| 22 | +// |
| 23 | +// ************************************************************* |
| 24 | +// * These messages should never be updated, * |
| 25 | +// * only be added when a new version is added, * |
| 26 | +// * or be removed when an old version is no longer supported. * |
| 27 | +// ************************************************************* |
| 28 | +// |
| 29 | +// The message bytes are built from the output of `test_pb_from_to()` |
| 30 | +#[test] |
| 31 | +fn test_decode_v138_table_statistics() -> anyhow::Result<()> { |
| 32 | + let bytes = vec![ |
| 33 | + 8, 100, 16, 128, 8, 24, 128, 6, 32, 128, 8, 40, 1, 48, 2, 56, 128, 2, 64, 128, 1, 72, 128, |
| 34 | + 1, 80, 128, 4, 160, 6, 138, 1, 168, 6, 24, |
| 35 | + ]; |
| 36 | + let want = || TableStatistics { |
| 37 | + number_of_rows: 100, |
| 38 | + data_bytes: 1024, |
| 39 | + compressed_data_bytes: 768, |
| 40 | + index_data_bytes: 1024, |
| 41 | + bloom_index_size: Some(256), |
| 42 | + ngram_index_size: Some(128), |
| 43 | + inverted_index_size: Some(128), |
| 44 | + vector_index_size: Some(512), |
| 45 | + virtual_column_size: None, |
| 46 | + number_of_segments: Some(1), |
| 47 | + number_of_blocks: Some(2), |
| 48 | + }; |
| 49 | + |
| 50 | + common::test_pb_from_to(func_name!(), want())?; |
| 51 | + common::test_load_old(func_name!(), bytes.as_slice(), 138, want()) |
| 52 | +} |
0 commit comments