yiguolei commented on code in PR #23759:
URL: https://github.com/apache/doris/pull/23759#discussion_r1312857582


##########
be/src/vec/functions/function_bitmap.cpp:
##########
@@ -250,6 +252,59 @@ struct BitmapFromString {
     }
 };
 
+struct NameBitmapFromBase64 {
+    static constexpr auto name = "bitmap_from_base64";
+};
+struct BitmapFromBase64 {
+    using ArgumentType = DataTypeString;
+
+    static constexpr auto name = "bitmap_from_base64";
+
+    static Status vector(const ColumnString::Chars& data, const 
ColumnString::Offsets& offsets,
+                         std::vector<BitmapValue>& res, NullMap& null_map,
+                         size_t input_rows_count) {
+        res.reserve(input_rows_count);
+        if (offsets.size() == 0 && input_rows_count == 1) {
+            // For NULL constant
+            res.emplace_back();
+            null_map[0] = 1;
+            return Status::OK();
+        }
+        std::unique_ptr<char[]> decode_buff;
+        int last_decode_buff_len = 0;
+        int curr_decode_buff_len = 0;
+        for (size_t i = 0; i < input_rows_count; ++i) {
+            const char* src_str = reinterpret_cast<const 
char*>(&data[offsets[i - 1]]);
+            int64_t src_size = offsets[i] - offsets[i - 1];
+            if (0 != src_size % 4) {
+                // return Status::InvalidArgument(
+                //         fmt::format("invalid base64: {}", 
std::string(src_str, src_size)));
+                res.emplace_back();
+                null_map[i] = 1;
+                continue;
+            }
+            curr_decode_buff_len = src_size + 3;
+            if (curr_decode_buff_len > last_decode_buff_len) {
+                decode_buff.reset(new char[curr_decode_buff_len]);

Review Comment:
   reuse the buffer



-- 
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-unsubscr...@doris.apache.org

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


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

Reply via email to