This is an automated email from the ASF dual-hosted git repository.

gabriellee pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new a763af77968 [fix](compile) Enable compile checking for function_jsonb 
(#42305)
a763af77968 is described below

commit a763af77968fcb063f1800677a4f1b2809f96b63
Author: Gabriel <[email protected]>
AuthorDate: Wed Oct 23 15:35:51 2024 +0800

    [fix](compile) Enable compile checking for function_jsonb (#42305)
---
 be/src/util/jsonb_document.h            |  4 ++--
 be/src/vec/functions/function_jsonb.cpp | 24 +++++++++++++-----------
 be/src/vec/functions/function_string.h  |  9 +++++----
 3 files changed, 20 insertions(+), 17 deletions(-)

diff --git a/be/src/util/jsonb_document.h b/be/src/util/jsonb_document.h
index 2a9cf8a8191..016da3142cd 100644
--- a/be/src/util/jsonb_document.h
+++ b/be/src/util/jsonb_document.h
@@ -177,7 +177,7 @@ public:
     static JsonbDocument* makeDocument(char* pb, uint32_t size, const 
JsonbValue* rval);
 
     // create an JsonbDocument object from JSONB packed bytes
-    static JsonbDocument* createDocument(const char* pb, uint32_t size);
+    static JsonbDocument* createDocument(const char* pb, size_t size);
 
     // create an JsonbValue from JSONB packed bytes
     static JsonbValue* createValue(const char* pb, uint32_t size);
@@ -1138,7 +1138,7 @@ inline JsonbDocument* JsonbDocument::makeDocument(char* 
pb, uint32_t size, const
     return doc;
 }
 
-inline JsonbDocument* JsonbDocument::createDocument(const char* pb, uint32_t 
size) {
+inline JsonbDocument* JsonbDocument::createDocument(const char* pb, size_t 
size) {
     if (!pb || size < sizeof(JsonbHeader) + sizeof(JsonbValue)) {
         return nullptr;
     }
diff --git a/be/src/vec/functions/function_jsonb.cpp 
b/be/src/vec/functions/function_jsonb.cpp
index 3bfcec38ba0..3da8d514402 100644
--- a/be/src/vec/functions/function_jsonb.cpp
+++ b/be/src/vec/functions/function_jsonb.cpp
@@ -67,6 +67,7 @@
 #include "vec/utils/util.hpp"
 
 namespace doris::vectorized {
+#include "common/compile_check_begin.h"
 
 enum class NullalbeMode {
     NULLABLE = 0,
@@ -168,11 +169,12 @@ public:
 
                 JsonbErrType error = JsonbErrType::E_NONE;
                 if (scope == 
FunctionContext::FunctionStateScope::FRAGMENT_LOCAL) {
-                    FunctionJsonbParseState* state = 
reinterpret_cast<FunctionJsonbParseState*>(
+                    auto* state = reinterpret_cast<FunctionJsonbParseState*>(
                             
context->get_function_state(FunctionContext::FRAGMENT_LOCAL));
 
-                    if (!state->default_value_parser.parse(default_value.data,
-                                                           
default_value.size)) {
+                    if (!state->default_value_parser.parse(
+                                default_value.data,
+                                static_cast<unsigned 
int>(default_value.size))) {
                         error = state->default_value_parser.getErrorCode();
                         return Status::InvalidArgument(
                                 "invalid default json value: {} , error: {}",
@@ -250,7 +252,7 @@ public:
             }
 
             const auto& val = col_from_string->get_data_at(i);
-            if (parser.parse(val.data, val.size)) {
+            if (parser.parse(val.data, static_cast<unsigned int>(val.size))) {
                 // insert jsonb format data
                 
col_to->insert_data(parser.getWriter().getOutput()->getBuffer(),
                                     
(size_t)parser.getWriter().getOutput()->getSize());
@@ -279,8 +281,8 @@ public:
                                         .getOutput()
                                         ->getSize());
                     } else {
-                        auto val = 
block.get_by_position(arguments[1]).column->get_data_at(i);
-                        if (parser.parse(val.data, val.size)) {
+                        auto value = 
block.get_by_position(arguments[1]).column->get_data_at(i);
+                        if (parser.parse(value.data, static_cast<unsigned 
int>(value.size))) {
                             // insert jsonb format data
                             
col_to->insert_data(parser.getWriter().getOutput()->getBuffer(),
                                                 
(size_t)parser.getWriter().getOutput()->getSize());
@@ -288,7 +290,7 @@ public:
                             return Status::InvalidArgument(
                                     "json parse error: {} for default value: 
{}",
                                     JsonbErrMsg::getErrMsg(error),
-                                    std::string_view(val.data, val.size));
+                                    std::string_view(value.data, value.size));
                         }
                     }
                     continue;
@@ -663,7 +665,7 @@ public:
 
 private:
     static ALWAYS_INLINE void inner_loop_impl(size_t i, Container& res, const 
char* l_raw_str,
-                                              int l_str_size, JsonbPath& path) 
{
+                                              size_t l_str_size, JsonbPath& 
path) {
         // doc is NOT necessary to be deleted since JsonbDocument will not 
allocate memory
         JsonbDocument* doc = JsonbDocument::createDocument(l_raw_str, 
l_str_size);
         if (UNLIKELY(!doc || !doc->getValue())) {
@@ -753,7 +755,7 @@ private:
                                               ColumnString::Offsets& 
res_offsets, NullMap& null_map,
                                               const 
std::unique_ptr<JsonbWriter>& writer,
                                               std::unique_ptr<JsonbToJson>& 
formater,
-                                              const char* l_raw, int l_size, 
JsonbPath& path) {
+                                              const char* l_raw, size_t 
l_size, JsonbPath& path) {
         if (null_map[i]) {
             StringOP::push_null_string(i, res_data, res_offsets, null_map);
             return;
@@ -1019,7 +1021,7 @@ struct JsonbExtractImpl {
 
 private:
     static ALWAYS_INLINE void inner_loop_impl(size_t i, Container& res, 
NullMap& null_map,
-                                              const char* l_raw_str, int 
l_str_size,
+                                              const char* l_raw_str, size_t 
l_str_size,
                                               JsonbPath& path) {
         if (null_map[i]) {
             res[i] = 0;
@@ -1093,7 +1095,7 @@ private:
                 res[i] = ((const JsonbDoubleVal*)value)->val();
             } else if (value->isInt8() || value->isInt16() || value->isInt32() 
||
                        value->isInt64()) {
-                res[i] = ((const JsonbIntVal*)value)->val();
+                res[i] = static_cast<typename ValueType::T>(((const 
JsonbIntVal*)value)->val());
             } else {
                 null_map[i] = 1;
                 res[i] = 0;
diff --git a/be/src/vec/functions/function_string.h 
b/be/src/vec/functions/function_string.h
index ff9b3f9e4ac..daff415893c 100644
--- a/be/src/vec/functions/function_string.h
+++ b/be/src/vec/functions/function_string.h
@@ -109,18 +109,18 @@
 namespace doris::vectorized {
 
 struct StringOP {
-    static void push_empty_string(int index, ColumnString::Chars& chars,
+    static void push_empty_string(size_t index, ColumnString::Chars& chars,
                                   ColumnString::Offsets& offsets) {
         offsets[index] = chars.size();
     }
 
-    static void push_null_string(int index, ColumnString::Chars& chars,
+    static void push_null_string(size_t index, ColumnString::Chars& chars,
                                  ColumnString::Offsets& offsets, NullMap& 
null_map) {
         null_map[index] = 1;
         push_empty_string(index, chars, offsets);
     }
 
-    static void push_value_string(const std::string_view& string_value, int 
index,
+    static void push_value_string(const std::string_view& string_value, size_t 
index,
                                   ColumnString::Chars& chars, 
ColumnString::Offsets& offsets) {
         ColumnString::check_chars_length(chars.size() + string_value.size(), 
offsets.size());
 
@@ -129,7 +129,8 @@ struct StringOP {
     }
 
     static void push_value_string_reserved_and_allow_overflow(const 
std::string_view& string_value,
-                                                              int index, 
ColumnString::Chars& chars,
+                                                              size_t index,
+                                                              
ColumnString::Chars& chars,
                                                               
ColumnString::Offsets& offsets) {
         chars.insert_assume_reserved_and_allow_overflow(string_value.data(),
                                                         string_value.data() + 
string_value.size());


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to