Skip to content

Commit

Permalink
[Feat](json) Support json_search function
Browse files Browse the repository at this point in the history
  • Loading branch information
liutang123 committed Sep 18, 2024
1 parent 538817a commit 37f1dc0
Show file tree
Hide file tree
Showing 11 changed files with 853 additions and 107 deletions.
31 changes: 31 additions & 0 deletions be/src/util/jsonb_document.h
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,22 @@ struct leg_info {

///type: 0 is member 1 is array
unsigned int type;

bool to_string(std::string* str) const {
if (type == MEMBER_CODE) {
str->push_back(BEGIN_MEMBER);
str->append(leg_ptr, leg_len);
return true;
} else if (type == ARRAY_CODE) {
str->push_back(BEGIN_ARRAY);
std::string int_str = std::to_string(array_index);
str->append(int_str);
str->push_back(END_ARRAY);
return true;
} else {
return false;
}
}
};

class JsonbPath {
Expand All @@ -362,6 +378,21 @@ class JsonbPath {
leg_vector.emplace_back(leg.release());
}

void pop_leg_from_leg_vector() {
leg_vector.pop_back();
}

bool to_string(std::string* res) const {
res->push_back(SCOPE);
for (const auto& leg : leg_vector) {
auto valid = leg->to_string(res);
if (!valid) {
return false;
}
}
return true;
}

size_t get_leg_vector_size() { return leg_vector.size(); }

leg_info* get_leg_from_leg_vector(size_t i) { return leg_vector[i].get(); }
Expand Down
Loading

0 comments on commit 37f1dc0

Please sign in to comment.