HappenLee commented on code in PR #51300: URL: https://github.com/apache/doris/pull/51300#discussion_r2115188873
########## be/src/runtime/jsonb_value.h: ########## @@ -14,31 +14,50 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. - -#ifndef DORIS_BE_RUNTIME_JSON_VALUE_H -#define DORIS_BE_RUNTIME_JSON_VALUE_H - -#include <glog/logging.h> - +#pragma once #include <cstddef> -#include <ostream> #include <string> #include "common/status.h" -#include "util/hash_util.hpp" #include "util/jsonb_parser_simd.h" +#include "util/jsonb_utils.h" namespace doris { +#include "common/compile_check_begin.h" + +// JsonBinaryValue wraps a Doris jsonb object. +// The jsonb object is written using JsonbWriter. +// JsonBinaryValue is non-movable and non-copyable; it is only a simple wrapper. +// To parse a string to a jsonb object, use it like this: +// JsonBinaryValue jsonb_value; +// RETURN_IF_ERROR(jsonb_value.from_json_string(slice.data, slice.size)); +// insert_data(jsonb_value.value(), jsonb_value.size()); +// insert_data should use copy semantics. +// +// from_json_string can be called multiple times. +// Example: +// JsonBinaryValue jsonb_value; +// for (;;) { +// RETURN_IF_ERROR(jsonb_value.from_json_string(slice.data, slice.size)); +// insert_data(jsonb_value.value(), jsonb_value.size()); +// } -struct JsonBinaryValue { - static const int MAX_LENGTH = (1 << 30); - - // default nullprt and size 0 for invalid or NULL value - const char* ptr = nullptr; - size_t len = 0; - JsonbParser parser; +struct JsonBinaryValue final { + static constexpr int MAX_LENGTH = (1 << 30); JsonBinaryValue() = default; + + JsonBinaryValue(const JsonBinaryValue&) = delete; + JsonBinaryValue& operator=(const JsonBinaryValue&) = delete; + JsonBinaryValue(JsonBinaryValue&&) = delete; + JsonBinaryValue& operator=(JsonBinaryValue&&) = delete; + + /// TODO: The constructor here calls from_json_string and ignores its return value. + // If an error occurs, ptr = nullptr and len = 0. + // Previously, since the column was nullable, insert_data would handle ptr being null like this: + // /// Will insert null value if pos=nullptr + // void insert_data(const char* pos, size_t length) override; + // However, this approach should not be used. JsonBinaryValue(char* ptr, size_t len) { Review Comment: why just del the constuctor ? -- 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