From 167afb38e111ae87e220b476ac821d39c3961758 Mon Sep 17 00:00:00 2001 From: xiangjinwu <17769960+xiangjinwu@users.noreply.github.com> Date: Mon, 6 Feb 2023 12:11:40 +0800 Subject: [PATCH] refactor(DataType): cleanup outdated helpers (#7685) The following 2 helpers are no longer used in any place: `is_type_encodable`, `mem_cmp_eq_value_enc`. Note: right now all DataTypes are encodable in memcomparable format. We will reintroduce the difference and disallow certain types from being used as memcomparable later. Approved-By: liurenjie1024 --- src/common/src/types/mod.rs | 12 ------------ src/common/src/util/encoding_for_comparison.rs | 17 +---------------- 2 files changed, 1 insertion(+), 28 deletions(-) diff --git a/src/common/src/types/mod.rs b/src/common/src/types/mod.rs index 696d96399ff7d..b8461c29d8625 100644 --- a/src/common/src/types/mod.rs +++ b/src/common/src/types/mod.rs @@ -342,18 +342,6 @@ impl DataType { } } - /// Checks if memcomparable encoding of datatype is equivalent to its value encoding. - pub fn mem_cmp_eq_value_enc(&self) -> bool { - use DataType::*; - match self { - Boolean | Int16 | Int32 | Int64 => true, - Float32 | Float64 | Decimal | Date | Varchar | Time | Timestamp | Timestamptz - | Interval | Bytea => false, - Struct(t) => t.fields.iter().all(|dt| dt.mem_cmp_eq_value_enc()), - List { datatype } => datatype.mem_cmp_eq_value_enc(), - } - } - pub fn new_struct(fields: Vec, field_names: Vec) -> Self { Self::Struct( StructType { diff --git a/src/common/src/util/encoding_for_comparison.rs b/src/common/src/util/encoding_for_comparison.rs index 1682f6eb3b992..415bd47993244 100644 --- a/src/common/src/util/encoding_for_comparison.rs +++ b/src/common/src/util/encoding_for_comparison.rs @@ -17,24 +17,9 @@ use itertools::Itertools; use crate::array::{ArrayImpl, DataChunk}; use crate::error::Result; use crate::row::OwnedRow; -use crate::types::{memcmp_serialize_datum_into, DataType, ScalarRefImpl}; +use crate::types::{memcmp_serialize_datum_into, ScalarRefImpl}; use crate::util::sort_util::{OrderPair, OrderType}; -/// This function is used to check whether we can perform encoding on this type. -/// TODO: based on `memcomparable`, we may support more data type in the future. -pub fn is_type_encodable(t: DataType) -> bool { - matches!( - t, - DataType::Boolean - | DataType::Int16 - | DataType::Int32 - | DataType::Int64 - | DataType::Float32 - | DataType::Float64 - | DataType::Varchar - ) -} - fn encode_value(value: Option>, order: &OrderType) -> Result> { let mut serializer = memcomparable::Serializer::new(vec![]); serializer.set_reverse(order == &OrderType::Descending);