Skip to content

Commit

Permalink
[Improve](compile) add __AVX2__ macro for JsonbParser (#28754)
Browse files Browse the repository at this point in the history
* [Improve](compile) add `__AVX2__` macro for JsonbParser

* throw exception instead of CHECK
  • Loading branch information
eldenmoon authored Dec 21, 2023
1 parent 8759bce commit 007f152
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
16 changes: 14 additions & 2 deletions be/src/vec/columns/column_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@
#include "vec/data_types/data_type_nullable.h"
#include "vec/data_types/get_least_supertype.h"

#ifdef __AVX2__
#include "util/jsonb_parser_simd.h"
#else
#include "util/jsonb_parser.h"
#endif

namespace doris::vectorized {
namespace {

Expand Down Expand Up @@ -1155,8 +1161,14 @@ void ColumnObject::merge_sparse_to_root_column() {
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
root.Accept(writer);
bool res = parser.parse(buffer.GetString(), buffer.GetSize());
CHECK(res) << "buffer:" << std::string(buffer.GetString(), buffer.GetSize())
<< ", row_num:" << i;
if (!res) {
throw Exception(ErrorCode::INVALID_ARGUMENT,
"parse json failed, doc: {}"
", row_num:{}"
", error:{}",
std::string(buffer.GetString(), buffer.GetSize()), i,
JsonbErrMsg::getErrMsg(parser.getErrorCode()));
}
result_column_ptr->insert_data(parser.getWriter().getOutput()->getBuffer(),
parser.getWriter().getOutput()->getSize());
result_column_nullable->get_null_map_data().push_back(0);
Expand Down
6 changes: 6 additions & 0 deletions be/src/vec/data_types/serde/data_type_jsonb_serde.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
#include "common/status.h"
#include "exprs/json_functions.h"
#include "runtime/jsonb_value.h"

#ifdef __AVX2__
#include "util/jsonb_parser_simd.h"
#else
#include "util/jsonb_parser.h"
#endif
namespace doris {
namespace vectorized {

Expand Down

0 comments on commit 007f152

Please sign in to comment.