bugfix json_storage_size for scalar
This commit is contained in:
@ -4827,14 +4827,14 @@ int ObIJsonBase::get_used_size(uint64_t &size)
|
||||
|
||||
if (is_bin()) {
|
||||
const ObJsonBin *j_bin = static_cast<const ObJsonBin *>(this);
|
||||
size = j_bin->get_used_bytes();
|
||||
size = j_bin->get_serialize_size();
|
||||
} else { // is tree
|
||||
ObArenaAllocator allocator;
|
||||
ObIJsonBase *j_bin = NULL;
|
||||
if (OB_FAIL(ObJsonBaseFactory::transform(&allocator, this, ObJsonInType::JSON_BIN, j_bin))) {
|
||||
LOG_WARN("fail to transform to tree", K(ret));
|
||||
} else {
|
||||
size = static_cast<const ObJsonBin *>(j_bin)->get_used_bytes();
|
||||
size = static_cast<const ObJsonBin *>(j_bin)->get_serialize_size();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
14
deps/oblib/src/lib/json_type/ob_json_bin.cpp
vendored
14
deps/oblib/src/lib/json_type/ob_json_bin.cpp
vendored
@ -4009,6 +4009,20 @@ int ObJsonBin::rebuild(ObJsonBuffer &result)
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint64_t ObJsonBin::get_serialize_size() const
|
||||
{
|
||||
uint64_t size = 0;
|
||||
ObJBVerType ver_type = get_vertype();
|
||||
if (ObJsonVerType::is_array(ver_type)
|
||||
|| ObJsonVerType::is_object(ver_type)
|
||||
|| ObJsonVerType::is_opaque_or_string(ver_type)) {
|
||||
size = get_used_bytes();
|
||||
} else {
|
||||
size = 1 /*vertype byte*/ + get_used_bytes();
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
void ObJsonBin::destroy()
|
||||
{
|
||||
result_.reset();
|
||||
|
||||
1
deps/oblib/src/lib/json_type/ob_json_bin.h
vendored
1
deps/oblib/src/lib/json_type/ob_json_bin.h
vendored
@ -185,6 +185,7 @@ public:
|
||||
OB_INLINE ObJsonInType get_internal_type() const override { return ObJsonInType::JSON_BIN; }
|
||||
OB_INLINE uint64_t element_count() const override { return element_count_; }
|
||||
OB_INLINE uint64_t get_used_bytes() const { return bytes_; } // return acutal used bytes for curr iter
|
||||
uint64_t get_serialize_size() const;
|
||||
OB_INLINE ObJsonNodeType json_type() const override
|
||||
{
|
||||
return static_cast<ObJsonNodeType>(ObJsonVerType::get_json_type(get_vertype()));
|
||||
|
||||
Reference in New Issue
Block a user