Commit e42a0b6
authored
Refactor distinct aggregate implementations to use common buffer (#18348)
## Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases.
You can link an issue to this PR using the GitHub syntax. For example
`Closes #123` indicates that this PR will close issue #123.
-->
- Relates to #2406
## Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly
in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand
your changes and offer better suggestions for fixes.
-->
Make it easier to write distinct variations of aggregate functions be
refactoring some of the common code together; specifically how they
handle maintaining the complete set of distinct primitive values, as
this code was duplicated across different functions.
## What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it
is sometimes worth providing a summary of the individual changes in this
PR.
-->
Introduce new `GenericDistinctBuffer` which has methods similar to
`Accumulator` to manage an internal `HashSet` of values, so
implementations like `percentile_cont` and `sum` can use it internally
and only implement their own evaluate functions.
## Are these changes tested?
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example,
are they covered by existing tests)?
-->
Existing tests.
## Are there any user-facing changes?
<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.
-->
No.
<!--
If there are any breaking changes to public APIs, please add the `api
change` label.
-->1 parent e29009f commit e42a0b6
File tree
5 files changed
+150
-229
lines changed- datafusion
- functions-aggregate-common/src
- aggregate
- count_distinct
- sum_distinct
- functions-aggregate/src
5 files changed
+150
-229
lines changedLines changed: 12 additions & 58 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
| 127 | + | |
| 128 | + | |
132 | 129 | | |
133 | 130 | | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
| 131 | + | |
138 | 132 | | |
139 | 133 | | |
140 | | - | |
| 134 | + | |
141 | 135 | | |
142 | 136 | | |
143 | 137 | | |
144 | 138 | | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
| 139 | + | |
149 | 140 | | |
150 | 141 | | |
151 | 142 | | |
152 | 143 | | |
153 | 144 | | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
| 145 | + | |
158 | 146 | | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
| 147 | + | |
163 | 148 | | |
164 | 149 | | |
165 | 150 | | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
| 151 | + | |
178 | 152 | | |
179 | 153 | | |
180 | 154 | | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
| 155 | + | |
199 | 156 | | |
200 | 157 | | |
201 | 158 | | |
202 | | - | |
| 159 | + | |
203 | 160 | | |
204 | 161 | | |
205 | 162 | | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
| 163 | + | |
210 | 164 | | |
211 | 165 | | |
Lines changed: 19 additions & 59 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | 20 | | |
22 | | - | |
| 21 | + | |
23 | 22 | | |
24 | | - | |
25 | | - | |
26 | 23 | | |
27 | 24 | | |
28 | 25 | | |
29 | | - | |
30 | 26 | | |
31 | 27 | | |
32 | 28 | | |
33 | 29 | | |
34 | 30 | | |
35 | 31 | | |
36 | 32 | | |
37 | | - | |
| 33 | + | |
38 | 34 | | |
39 | 35 | | |
| 36 | + | |
40 | 37 | | |
41 | | - | |
| 38 | + | |
42 | 39 | | |
43 | 40 | | |
44 | 41 | | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | 42 | | |
52 | 43 | | |
53 | 44 | | |
54 | | - | |
| 45 | + | |
55 | 46 | | |
56 | 47 | | |
57 | 48 | | |
58 | 49 | | |
59 | 50 | | |
60 | | - | |
| 51 | + | |
61 | 52 | | |
62 | 53 | | |
63 | 54 | | |
64 | | - | |
| 55 | + | |
65 | 56 | | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
| 57 | + | |
83 | 58 | | |
84 | 59 | | |
85 | 60 | | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
| 61 | + | |
102 | 62 | | |
103 | 63 | | |
104 | 64 | | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
| 65 | + | |
109 | 66 | | |
110 | 67 | | |
111 | 68 | | |
112 | | - | |
113 | | - | |
114 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
115 | 77 | | |
116 | | - | |
117 | | - | |
118 | 78 | | |
119 | 79 | | |
120 | 80 | | |
121 | | - | |
| 81 | + | |
122 | 82 | | |
123 | 83 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
19 | 22 | | |
20 | 23 | | |
21 | 24 | | |
22 | 25 | | |
23 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
24 | 32 | | |
25 | 33 | | |
26 | 34 | | |
| |||
167 | 175 | | |
168 | 176 | | |
169 | 177 | | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
0 commit comments