You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/10/07 09:54:31 UTC

[GitHub] [doris] Yukang-Lian commented on a diff in pull request #13056: [Feature](Retention) support retention function

Yukang-Lian commented on code in PR #13056:
URL: https://github.com/apache/doris/pull/13056#discussion_r989910566


##########
be/src/exprs/aggregate_functions.cpp:
##########
@@ -2534,6 +2535,97 @@ IntVal AggregateFunctions::window_funnel_finalize(FunctionContext* ctx, const St
     return doris_udf::IntVal(val);
 }
 
+// Refer to AggregateFunctionRetention.h in https://github.com/ClickHouse/ClickHouse.git
+struct RetentionState {
+    static constexpr size_t max_events = 32;
+    std::bitset<max_events> events;
+
+    RetentionState() {}
+
+    void add(int event) { events.set(event); }
+
+    void merge(RetentionState* other) { events |= other->events; }
+
+    BooleanVal* getRetentionData() {
+        static BooleanVal data_to[max_events];
+        int current_offset = 0;
+
+        const bool first_flag = events.test(0);
+        data_to[current_offset] = first_flag;
+        ++current_offset;
+
+        for (size_t i = 1; i < events.size(); ++i) {
+            data_to[current_offset] = (first_flag && events.test(i));
+            ++current_offset;
+        }
+        return data_to;
+    }
+
+    int64_t serizlized_size() { return sizeof(events); }
+
+    void serialize(uint8_t* buf) {
+        memcpy(buf, &events, sizeof(events));

Review Comment:
   will do.



-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org