BiteTheDDDDt commented on code in PR #9859:
URL: https://github.com/apache/incubator-doris/pull/9859#discussion_r884652515
##########
be/src/vec/functions/function_bitmap.cpp:
##########
@@ -39,24 +39,47 @@ struct BitmapEmpty {
struct ToBitmap {
static constexpr auto name = "to_bitmap";
+ using ReturnType = DataTypeBitMap;
- static Status vector(const ColumnString::Chars& data, const
ColumnString::Offsets& offsets,
- std::vector<BitmapValue>& res, NullMap& null_map) {
- auto size = offsets.size();
- res.reserve(size);
- for (size_t i = 0; i < size; ++i) {
- res.emplace_back();
+ static void vector(const ColumnString::Chars& data, const
ColumnString::Offsets& offsets,
+ MutableColumnPtr& col_res) {
+ auto* res_column = reinterpret_cast<ColumnBitmap*>(col_res.get());
+ auto& res_data = res_column->get_data();
+ size_t size = offsets.size();
+ for (size_t i = 0; i < size; ++i) {
const char* raw_str = reinterpret_cast<const
char*>(&data[offsets[i - 1]]);
size_t str_size = offsets[i] - offsets[i - 1] - 1;
StringParser::ParseResult parse_result =
StringParser::PARSE_SUCCESS;
uint64_t int_value =
StringParser::string_to_unsigned_int<uint64_t>(raw_str, str_size,
&parse_result);
if (LIKELY(parse_result == StringParser::PARSE_SUCCESS)) {
- res.back().add(int_value);
+ res_data[i].add(int_value);
+ }
+ }
+ }
+
+ static void vector_nullable(const ColumnString::Chars& data,
+ const ColumnString::Offsets& offsets, const
NullMap& nullmap,
+ MutableColumnPtr& col_res) {
+ auto* res_column = reinterpret_cast<ColumnBitmap*>(col_res.get());
+ auto& res_data = res_column->get_data();
+ size_t size = offsets.size();
+
+ for (size_t i = 0; i < size; ++i) {
+ if (nullmap[i]) {
+ continue;
+ } else {
+ const char* raw_str = reinterpret_cast<const
char*>(&data[offsets[i - 1]]);
Review Comment:
A layer of abstraction can be added here to allow the same code to be reused
--
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]