github-actions[bot] commented on code in PR #62520:
URL: https://github.com/apache/doris/pull/62520#discussion_r3085604403
##########
be/src/exprs/aggregate/aggregate_function_percentile.h:
##########
@@ -323,112 +319,191 @@ class
AggregateFunctionPercentileApproxWeightedFourParams final
};
template <PrimitiveType T>
-struct PercentileState {
- mutable std::vector<Counts<typename PrimitiveTypeTraits<T>::CppType>>
vec_counts;
- std::vector<double> vec_quantile {-1};
- bool inited_flag = false;
+class PercentileState {
+public:
+ using ValueType = typename PrimitiveTypeTraits<T>::CppType;
+ static constexpr size_t bytes_in_arena = 64 - sizeof(PODArray<ValueType>);
+ using Array = PODArrayWithStackMemory<ValueType, bytes_in_arena>;
+
+ void add_single_range(const ValueType* data, size_t count, double
quantile) {
+ if (!inited_flag) {
+ _set_single_level(quantile);
+ inited_flag = true;
+ }
+ _append(data, count);
+ }
+
+ void add_many_range(const ValueType* data, size_t count,
+ const PaddedPODArray<Float64>& quantiles_data, const
NullMap& null_maps,
+ size_t start, int64_t arg_size) {
+ if (!inited_flag) {
+ _set_many_levels(quantiles_data, null_maps, start, arg_size);
+ inited_flag = true;
+ }
+ if (levels.empty()) {
+ return;
+ }
+ _append(data, count);
+ }
void write(BufferWritable& buf) const {
buf.write_binary(inited_flag);
if (!inited_flag) {
return;
}
- int size_num = cast_set<int>(vec_quantile.size());
- buf.write_binary(size_num);
- for (const auto& quantile : vec_quantile) {
- buf.write_binary(quantile);
- }
- for (auto& counts : vec_counts) {
- counts.serialize(buf);
+
+ levels.write(buf);
+ size_t size = values.size();
Review Comment:
This changes the serialized layout of `PercentileState` in a
backward-incompatible way.
Before this PR, the state was encoded as:
`inited_flag + quantile list + serialized Counts objects`
After this PR, it becomes:
`inited_flag + quantile list + raw value count + raw values`
`percentile` / `percentile_array` states are not just transient in-memory
objects. They are also persisted and reloaded through `AggState`
(`DataTypeAggState` -> storage reader -> `deserialize()`), and can be exchanged
between BEs as serialized aggregate states. With the new `read()`
implementation, any previously stored state bytes will interpret the old
`Counts` payload as the new `size_t size` field and then read the wrong number
of bytes into `values`.
I don't see any `be_exec_version` bump/gate, dual-format reader, or other
compatibility path here, so this looks like a storage / wire-format break
rather than a pure internal refactor. Please either preserve the old format, or
add explicit versioned compatibility handling plus tests that cover reading old
serialized percentile states.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]