Skip to content

Commit

Permalink
chore(query): remove old aggregate codes (#17025)
Browse files Browse the repository at this point in the history
* chore(query): remove old agg

* chore(query): remove old agg

* chore(query): remove old agg

* chore(query): remove old agg

* chore(query): merge group_by into aggregate

* chore(query): remove old codes
  • Loading branch information
sundy-li authored Dec 11, 2024
1 parent 8646b77 commit 88c78cc
Show file tree
Hide file tree
Showing 43 changed files with 319 additions and 5,595 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 4 additions & 18 deletions src/query/expression/src/kernels/group_by.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,11 @@ use super::group_by_hash::HashMethodSerializer;
use super::group_by_hash::HashMethodSingleBinary;
use crate::types::DataType;
use crate::DataBlock;
use crate::HashMethodDictionarySerializer;
use crate::HashMethodKeysU128;
use crate::HashMethodKeysU256;

impl DataBlock {
pub fn choose_hash_method(
chunk: &DataBlock,
indices: &[usize],
efficiently_memory: bool,
) -> Result<HashMethodKind> {
pub fn choose_hash_method(chunk: &DataBlock, indices: &[usize]) -> Result<HashMethodKind> {
let hash_key_types = indices
.iter()
.map(|&offset| {
Expand All @@ -42,13 +37,10 @@ impl DataBlock {
.collect::<Result<Vec<_>>>();

let hash_key_types = hash_key_types?;
Self::choose_hash_method_with_types(&hash_key_types, efficiently_memory)
Self::choose_hash_method_with_types(&hash_key_types)
}

pub fn choose_hash_method_with_types(
hash_key_types: &[DataType],
efficiently_memory: bool,
) -> Result<HashMethodKind> {
pub fn choose_hash_method_with_types(hash_key_types: &[DataType]) -> Result<HashMethodKind> {
if hash_key_types.len() == 1
&& matches!(
hash_key_types[0],
Expand All @@ -74,14 +66,8 @@ impl DataBlock {
if hash_key_type.is_nullable() {
group_key_len += 1;
}
} else if !efficiently_memory || hash_key_types.len() == 1 {
return Ok(HashMethodKind::Serializer(HashMethodSerializer::default()));
} else {
return Ok(HashMethodKind::DictionarySerializer(
HashMethodDictionarySerializer {
dict_keys: hash_key_types.len(),
},
));
return Ok(HashMethodKind::Serializer(HashMethodSerializer::default()));
}
}

Expand Down
25 changes: 1 addition & 24 deletions src/query/expression/src/kernels/group_by_hash/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ use crate::types::DecimalDataType;
use crate::types::NumberDataType;
use crate::types::StringColumn;
use crate::Column;
use crate::HashMethodDictionarySerializer;
use crate::HashMethodKeysU128;
use crate::HashMethodKeysU16;
use crate::HashMethodKeysU256;
Expand Down Expand Up @@ -91,7 +90,6 @@ pub trait HashMethod: Clone + Sync + Send + 'static {
#[derive(Clone, Debug)]
pub enum HashMethodKind {
Serializer(HashMethodSerializer),
DictionarySerializer(HashMethodDictionarySerializer),
SingleBinary(HashMethodSingleBinary),
KeysU8(HashMethodKeysU8),
KeysU16(HashMethodKeysU16),
Expand All @@ -106,7 +104,7 @@ macro_rules! with_hash_method {
( | $t:tt | $($tail:tt)* ) => {
match_template::match_template! {
$t = [Serializer, SingleBinary, KeysU8, KeysU16,
KeysU32, KeysU64, KeysU128, KeysU256, DictionarySerializer],
KeysU32, KeysU64, KeysU128, KeysU256],
$($tail)*
}
}
Expand All @@ -123,26 +121,6 @@ macro_rules! with_join_hash_method {
}
}

#[macro_export]
macro_rules! with_mappedhash_method {
( | $t:tt | $($tail:tt)* ) => {
match_template::match_template! {
$t = [
Serializer => HashMethodSerializer,
SingleBinary => HashMethodSingleBinary,
KeysU8 => HashMethodKeysU8,
KeysU16 => HashMethodKeysU16,
KeysU32 => HashMethodKeysU32,
KeysU64 => HashMethodKeysU64,
KeysU128 => HashMethodKeysU128,
KeysU256 => HashMethodKeysU256,
DictionarySerializer => HashMethodDictionarySerializer
],
$($tail)*
}
}
}

impl HashMethodKind {
pub fn name(&self) -> String {
with_hash_method!(|T| match self {
Expand All @@ -164,7 +142,6 @@ impl HashMethodKind {
HashMethodKind::KeysU256(_) => {
DataType::Decimal(DecimalDataType::Decimal256(i256::default_decimal_size()))
}
HashMethodKind::DictionarySerializer(_) => DataType::Binary,
}
}
}

This file was deleted.

2 changes: 0 additions & 2 deletions src/query/expression/src/kernels/group_by_hash/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@
// limitations under the License.

mod method;
mod method_dict_serializer;
mod method_fixed_keys;
mod method_serializer;
mod method_single_string;
mod utils;

pub use method::*;
pub use method_dict_serializer::*;
pub use method_fixed_keys::*;
pub use method_serializer::*;
pub use method_single_string::*;
4 changes: 2 additions & 2 deletions src/query/expression/tests/it/group_by.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ fn test_group_by_hash() -> Result<()> {
StringType::from_data(vec!["x1", "x1", "x2", "x1", "x2", "x3"]),
]);

let method = DataBlock::choose_hash_method(&block, &[0, 3], false)?;
let method = DataBlock::choose_hash_method(&block, &[0, 3])?;
assert_eq!(method.name(), HashMethodSerializer::default().name(),);

let method = DataBlock::choose_hash_method(&block, &[0, 1, 2], false)?;
let method = DataBlock::choose_hash_method(&block, &[0, 1, 2])?;

assert_eq!(method.name(), HashMethodKeysU32::default().name());

Expand Down
1 change: 0 additions & 1 deletion src/query/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ serde_urlencoded = { workspace = true }
sha2 = { workspace = true }
socket2 = { workspace = true }
sqlx = { workspace = true }
strength_reduce = { workspace = true }
sysinfo = { workspace = true }
tempfile = { workspace = true }
tokio = { workspace = true }
Expand Down
Loading

0 comments on commit 88c78cc

Please sign in to comment.