Skip to content

Commit

Permalink
refactor(interactive): Replace CHECK with std::runtime_error in `sc…
Browse files Browse the repository at this point in the history
…hema.cc` (#4107)

We previously used `CHECK` to verify schema operations, but its lack of
robustness could lead to server downtime. We have replaced glog CHECK
with exception throwing.
  • Loading branch information
zhanglei1949 authored Aug 6, 2024
1 parent 01857c0 commit 34f25ea
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 92 deletions.
14 changes: 10 additions & 4 deletions flex/engines/hqps_db/core/base_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -828,9 +828,11 @@ class BaseEngine {
auto& head_y = ctx_y.GetMutableHead();
auto left_repeat_array = ctx_x.ObtainOffsetFromTag(real_alias_x - 1);
auto right_repeat_array = ctx_y.ObtainOffsetFromTag(real_alias_y - 1);
CHECK(left_repeat_array.size() == right_repeat_array.size())
<< "left size " << left_repeat_array.size() << " right size "
<< right_repeat_array.size();
if (left_repeat_array.size() != right_repeat_array.size()) {
throw std::runtime_error("The two context has different repeat size.: " +
std::to_string(left_repeat_array.size()) + ", " +
std::to_string(right_repeat_array.size()));
}

std::vector<size_t> active_indices, new_offsets;
std::tie(active_indices, new_offsets) =
Expand Down Expand Up @@ -867,7 +869,11 @@ class BaseEngine {
}
grape::Bitset bitset;
bitset.init(max_vid + 1);
CHECK(left_repeat_array.size() == right_repeat_array.size());
if (left_repeat_array.size() != right_repeat_array.size()) {
throw std::runtime_error("The two context has different repeat size.: " +
std::to_string(left_repeat_array.size()) + ", " +
std::to_string(right_repeat_array.size()));
}
for (size_t i = 0; i + 1 < left_repeat_array.size(); ++i) {
auto x_start = left_repeat_array[i];
auto x_end = left_repeat_array[i + 1];
Expand Down
10 changes: 7 additions & 3 deletions flex/engines/hqps_db/core/operator/get_v.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,10 @@ class GetVertex {
const GRAPH_INTERFACE& graph, const SET_T& set,
const GetVOpt<LabelT, num_labels, EXPRESSION, T...>& get_v_opt) {
auto v_opt = get_v_opt.v_opt_;
CHECK(v_opt == VOpt::Itself)
<< "Can only get v from vertex set with v_opt == vopt::Itself";
if (v_opt != VOpt::Itself) {
throw std::runtime_error(
"Can only get v from vertex set with v_opt == vopt::Itself");
}
auto v_labels = get_v_opt.v_labels_;
auto props = get_v_opt.props_;
auto expr = get_v_opt.expr_;
Expand Down Expand Up @@ -236,7 +238,9 @@ class GetVertex {
std::sort(labels.begin(), labels.end());
labels.erase(std::unique(labels.begin(), labels.end()), labels.end());
// Can only be one label.
CHECK(labels.size() == 1);
if (labels.size() != 1) {
throw std::runtime_error("Path set should have only one label");
}
// if req_labels is empty, then use the label from path set.
if (req_label_vec.empty()) {
req_label_vec.push_back(labels[0]);
Expand Down
1 change: 0 additions & 1 deletion flex/engines/hqps_db/core/operator/group_by.h
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,6 @@ class GroupByOp {
}
auto data_ele = gs::get_from_tuple<GROUP_KEY::col_id>(data_tuple);
int32_t ind = insert_to_keyed_set(keyed_set_builder, key_ele, data_ele);
// CHECK(ind != -1);
if (ind != -1) {
insert_to_value_set_builder(value_set_builder_tuple, ele_tuple,
data_tuple, ind);
Expand Down
Loading

0 comments on commit 34f25ea

Please sign in to comment.