-
Notifications
You must be signed in to change notification settings - Fork 153
Expand file tree
/
Copy pathlegacy.rs
More file actions
34 lines (30 loc) · 1.34 KB
/
legacy.rs
File metadata and controls
34 lines (30 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright the Vortex contributors
//! Compatibility helpers for stats still stored under the legacy [`Stat`] enum.
use crate::aggregate_fn::AggregateFnRef;
use crate::aggregate_fn::fns::nan_count::NanCount;
use crate::aggregate_fn::fns::sum::Sum;
use crate::aggregate_fn::fns::uncompressed_size_in_bytes::UncompressedSizeInBytes;
use crate::expr::stats::Stat;
/// Maps an aggregate function to its legacy [`Stat`] slot, if one exists.
///
/// Used while we still cache some aggregates under the legacy [`Stat`] enum rather than keyed
/// directly by aggregate function. New aggregates (e.g. `min_max`, `is_constant`, `is_sorted`,
/// `count`) intentionally have no mapping and return `None`; callers will see the `trace!`
/// below when they ask for an aggregate that isn't backed by a legacy slot.
pub(crate) fn legacy_stat_for_aggregate(aggregate_fn: &AggregateFnRef) -> Option<Stat> {
if aggregate_fn.is::<Sum>() {
return Some(Stat::Sum);
}
if aggregate_fn.is::<NanCount>() {
return Some(Stat::NaNCount);
}
if aggregate_fn.is::<UncompressedSizeInBytes>() {
return Some(Stat::UncompressedSizeInBytes);
}
tracing::trace!(
"No legacy Stat slot for aggregate {}; stat expression will resolve to null",
aggregate_fn
);
None
}