Skip to content

Commit a8da519

Browse files
authored
chore(query): revert #16192 (#16271)
1 parent b32117a commit a8da519

File tree

5 files changed

+5
-173
lines changed

5 files changed

+5
-173
lines changed

src/query/storages/common/table_meta/src/meta/v2/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,11 @@ pub mod statistics;
1818
mod table_snapshot_statistics;
1919

2020
pub use segment::BlockMeta;
21-
pub use segment::BlockMetaMessagePack;
2221
pub use segment::ColumnMeta;
2322
pub use segment::SegmentInfo;
2423
pub use snapshot::TableSnapshot;
2524
pub use statistics::ClusterStatistics;
2625
pub use statistics::ColumnStatistics;
2726
pub use statistics::Statistics;
28-
pub use statistics::StatisticsMessagePack;
2927
pub use table_snapshot_statistics::MetaHLL;
3028
pub use table_snapshot_statistics::TableSnapshotStatistics;

src/query/storages/common/table_meta/src/meta/v2/segment.rs

-44
Original file line numberDiff line numberDiff line change
@@ -84,50 +84,6 @@ pub struct BlockMeta {
8484
pub create_on: Option<DateTime<Utc>>,
8585
}
8686

87-
/// An exact copy of `BlockMeta` with specific `deserialize_with` implementation that
88-
/// can correctly deserialize legacy MessagePack format.
89-
#[derive(Clone, Deserialize)]
90-
pub struct BlockMetaMessagePack {
91-
row_count: u64,
92-
block_size: u64,
93-
file_size: u64,
94-
#[serde(deserialize_with = "crate::meta::v2::statistics::default_on_error")]
95-
col_stats: HashMap<ColumnId, ColumnStatistics>,
96-
col_metas: HashMap<ColumnId, ColumnMeta>,
97-
cluster_stats: Option<ClusterStatistics>,
98-
/// location of data block
99-
location: Location,
100-
/// location of bloom filter index
101-
bloom_filter_index_location: Option<Location>,
102-
103-
#[serde(default)]
104-
bloom_filter_index_size: u64,
105-
inverted_index_size: Option<u64>,
106-
compression: Compression,
107-
108-
// block create_on
109-
create_on: Option<DateTime<Utc>>,
110-
}
111-
112-
impl From<BlockMetaMessagePack> for BlockMeta {
113-
fn from(b: BlockMetaMessagePack) -> Self {
114-
Self {
115-
row_count: b.row_count,
116-
block_size: b.block_size,
117-
file_size: b.file_size,
118-
col_stats: b.col_stats,
119-
col_metas: b.col_metas,
120-
cluster_stats: b.cluster_stats,
121-
location: b.location,
122-
bloom_filter_index_location: b.bloom_filter_index_location,
123-
bloom_filter_index_size: b.bloom_filter_index_size,
124-
inverted_index_size: b.inverted_index_size,
125-
compression: b.compression,
126-
create_on: b.create_on,
127-
}
128-
}
129-
}
130-
13187
impl BlockMeta {
13288
#[allow(clippy::too_many_arguments)]
13389
pub fn new(

src/query/storages/common/table_meta/src/meta/v2/statistics.rs

-57
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ use databend_common_expression::Scalar;
2525
use databend_common_expression::TableDataType;
2626
use databend_common_expression::TableField;
2727
use serde::de::Error;
28-
use serde::Deserialize;
2928

3029
use crate::meta::v0;
3130

@@ -84,38 +83,6 @@ pub struct Statistics {
8483
pub cluster_stats: Option<ClusterStatistics>,
8584
}
8685

87-
/// An exact copy of `Statistics` with specific `deserialize_with` implementation that can
88-
/// correctly deserialize legacy MessagePack format.
89-
#[derive(serde::Deserialize)]
90-
pub struct StatisticsMessagePack {
91-
row_count: u64,
92-
block_count: u64,
93-
perfect_block_count: u64,
94-
95-
uncompressed_byte_size: u64,
96-
compressed_byte_size: u64,
97-
index_size: u64,
98-
99-
#[serde(deserialize_with = "crate::meta::v2::statistics::default_on_error")]
100-
col_stats: HashMap<ColumnId, ColumnStatistics>,
101-
cluster_stats: Option<ClusterStatistics>,
102-
}
103-
104-
impl From<StatisticsMessagePack> for Statistics {
105-
fn from(v: StatisticsMessagePack) -> Self {
106-
Self {
107-
row_count: v.row_count,
108-
block_count: v.block_count,
109-
perfect_block_count: v.perfect_block_count,
110-
uncompressed_byte_size: v.uncompressed_byte_size,
111-
compressed_byte_size: v.compressed_byte_size,
112-
index_size: v.index_size,
113-
col_stats: v.col_stats,
114-
cluster_stats: v.cluster_stats,
115-
}
116-
}
117-
}
118-
11986
// conversions from old meta data
12087
// ----------------------------------------------------------------
12188
// ----------------------------------------------------------------
@@ -437,27 +404,3 @@ where
437404
Ok(map)
438405
}
439406
}
440-
441-
/// Deserializes `T`, falling back to `Default::default()` on error.
442-
///
443-
/// This function is designed to handle legacy `ColumnStatistics` items that incorrectly
444-
/// include unsupported `min` and `max` index types. In the new `IndexScalar` type, these
445-
/// unsupported index types cannot be deserialized correctly.
446-
pub fn default_on_error<'de, T, D>(deserializer: D) -> Result<T, D::Error>
447-
where
448-
T: Default + serde::Deserialize<'de>,
449-
D: serde::Deserializer<'de>,
450-
{
451-
#[derive(Deserialize)]
452-
#[serde(untagged)]
453-
enum DefaultOnError<T> {
454-
Success(T),
455-
Error(serde::de::IgnoredAny),
456-
}
457-
458-
let v = DefaultOnError::<T>::deserialize(deserializer);
459-
match v {
460-
Ok(DefaultOnError::Success(v)) => Ok(v),
461-
_ => Ok(T::default()),
462-
}
463-
}

src/query/storages/common/table_meta/src/meta/v4/segment.rs

+4-24
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ use crate::meta::format::MetaCompression;
3131
use crate::meta::format::SegmentHeader;
3232
use crate::meta::format::MAX_SEGMENT_BLOCK_NUMBER;
3333
use crate::meta::v2::BlockMeta;
34-
use crate::meta::v2::BlockMetaMessagePack;
35-
use crate::meta::v2::StatisticsMessagePack;
3634
use crate::meta::FormatVersion;
3735
use crate::meta::MetaEncoding;
3836
use crate::meta::Statistics;
@@ -188,28 +186,10 @@ impl SegmentInfo {
188186
summary_size,
189187
} = decode_segment_header(&mut cursor)?;
190188

191-
let (blocks, summary): (Vec<Arc<BlockMeta>>, Statistics) = match encoding {
192-
MetaEncoding::MessagePack => {
193-
let blocks: Vec<Arc<BlockMetaMessagePack>> =
194-
read_and_deserialize(&mut cursor, blocks_size, &encoding, &compression)?;
195-
let summary: StatisticsMessagePack =
196-
read_and_deserialize(&mut cursor, summary_size, &encoding, &compression)?;
197-
(
198-
blocks
199-
.into_iter()
200-
.map(|v| Arc::new(v.as_ref().clone().into()))
201-
.collect(),
202-
summary.into(),
203-
)
204-
}
205-
MetaEncoding::Bincode | MetaEncoding::Json => {
206-
let blocks: Vec<Arc<BlockMeta>> =
207-
read_and_deserialize(&mut cursor, blocks_size, &encoding, &compression)?;
208-
let summary: Statistics =
209-
read_and_deserialize(&mut cursor, summary_size, &encoding, &compression)?;
210-
(blocks, summary)
211-
}
212-
};
189+
let blocks: Vec<Arc<BlockMeta>> =
190+
read_and_deserialize(&mut cursor, blocks_size, &encoding, &compression)?;
191+
let summary: Statistics =
192+
read_and_deserialize(&mut cursor, summary_size, &encoding, &compression)?;
213193

214194
let mut segment = Self::new(blocks, summary);
215195

src/query/storages/common/table_meta/src/meta/v4/snapshot.rs

+1-46
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ use crate::meta::format::MetaCompression;
3131
use crate::meta::monotonically_increased_timestamp;
3232
use crate::meta::trim_timestamp_to_micro_second;
3333
use crate::meta::v2;
34-
use crate::meta::v2::StatisticsMessagePack;
3534
use crate::meta::v3;
3635
use crate::meta::ClusterKey;
3736
use crate::meta::FormatVersion;
@@ -90,39 +89,6 @@ pub struct TableSnapshot {
9089
pub table_statistics_location: Option<String>,
9190
}
9291

93-
/// An exact copy of `TableSnapshot` with specific `deserialize_with` implementation
94-
/// in `summary` that can correctly deserialize legacy MessagePack format.
95-
#[derive(Deserialize)]
96-
pub struct TableSnapshotMessagePack {
97-
format_version: FormatVersion,
98-
snapshot_id: SnapshotId,
99-
timestamp: Option<DateTime<Utc>>,
100-
prev_table_seq: Option<u64>,
101-
prev_snapshot_id: Option<(SnapshotId, FormatVersion)>,
102-
schema: TableSchema,
103-
summary: StatisticsMessagePack,
104-
segments: Vec<Location>,
105-
cluster_key_meta: Option<ClusterKey>,
106-
table_statistics_location: Option<String>,
107-
}
108-
109-
impl From<TableSnapshotMessagePack> for TableSnapshot {
110-
fn from(v: TableSnapshotMessagePack) -> Self {
111-
Self {
112-
format_version: v.format_version,
113-
snapshot_id: v.snapshot_id,
114-
timestamp: v.timestamp,
115-
prev_table_seq: v.prev_table_seq,
116-
prev_snapshot_id: v.prev_snapshot_id,
117-
schema: v.schema,
118-
summary: v.summary.into(),
119-
segments: v.segments,
120-
cluster_key_meta: v.cluster_key_meta,
121-
table_statistics_location: v.table_statistics_location,
122-
}
123-
}
124-
}
125-
12692
impl TableSnapshot {
12793
pub fn new(
12894
snapshot_id: SnapshotId,
@@ -243,18 +209,7 @@ impl TableSnapshot {
243209
let compression = MetaCompression::try_from(r.read_scalar::<u8>()?)?;
244210
let snapshot_size: u64 = r.read_scalar::<u64>()?;
245211

246-
match encoding {
247-
MetaEncoding::MessagePack => {
248-
let snapshot: TableSnapshotMessagePack =
249-
read_and_deserialize(&mut r, snapshot_size, &encoding, &compression)?;
250-
Ok(snapshot.into())
251-
}
252-
MetaEncoding::Bincode | MetaEncoding::Json => {
253-
let snapshot: TableSnapshot =
254-
read_and_deserialize(&mut r, snapshot_size, &encoding, &compression)?;
255-
Ok(snapshot)
256-
}
257-
}
212+
read_and_deserialize(&mut r, snapshot_size, &encoding, &compression)
258213
}
259214

260215
#[inline]

0 commit comments

Comments
 (0)