/Users/andrewlamb/Software/datafusion/datafusion/functions-aggregate-common/src/order.rs
Line | Count | Source (jump to first uncovered line) |
1 | | // Licensed to the Apache Software Foundation (ASF) under one |
2 | | // or more contributor license agreements. See the NOTICE file |
3 | | // distributed with this work for additional information |
4 | | // regarding copyright ownership. The ASF licenses this file |
5 | | // to you under the Apache License, Version 2.0 (the |
6 | | // "License"); you may not use this file except in compliance |
7 | | // with the License. You may obtain a copy of the License at |
8 | | // |
9 | | // http://www.apache.org/licenses/LICENSE-2.0 |
10 | | // |
11 | | // Unless required by applicable law or agreed to in writing, |
12 | | // software distributed under the License is distributed on an |
13 | | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
14 | | // KIND, either express or implied. See the License for the |
15 | | // specific language governing permissions and limitations |
16 | | // under the License. |
17 | | |
18 | | /// Represents the sensitivity of an aggregate expression to ordering. |
19 | | #[derive(Debug, PartialEq, Eq, Clone, Copy)] |
20 | | pub enum AggregateOrderSensitivity { |
21 | | /// Indicates that the aggregate expression is insensitive to ordering. |
22 | | /// Ordering at the input is not important for the result of the aggregator. |
23 | | Insensitive, |
24 | | /// Indicates that the aggregate expression has a hard requirement on ordering. |
25 | | /// The aggregator can not produce a correct result unless its ordering |
26 | | /// requirement is satisfied. |
27 | | HardRequirement, |
28 | | /// Indicates that ordering is beneficial for the aggregate expression in terms |
29 | | /// of evaluation efficiency. The aggregator can produce its result efficiently |
30 | | /// when its required ordering is satisfied; however, it can still produce the |
31 | | /// correct result (albeit less efficiently) when its required ordering is not met. |
32 | | Beneficial, |
33 | | } |
34 | | |
35 | | impl AggregateOrderSensitivity { |
36 | 41 | pub fn is_insensitive(&self) -> bool { |
37 | 41 | self.eq(&AggregateOrderSensitivity::Insensitive) |
38 | 41 | } |
39 | | |
40 | 0 | pub fn is_beneficial(&self) -> bool { |
41 | 0 | self.eq(&AggregateOrderSensitivity::Beneficial) |
42 | 0 | } |
43 | | |
44 | 54 | pub fn hard_requires(&self) -> bool { |
45 | 54 | self.eq(&AggregateOrderSensitivity::HardRequirement) |
46 | 54 | } |
47 | | } |