| 35 | } |
| 36 | |
| 37 | void |
| 38 | HGraphParameter::FromJson(const JsonType& json) { |
| 39 | InnerIndexParameter::FromJson(json); |
| 40 | |
| 41 | if (json.Contains(HGRAPH_USE_ELP_OPTIMIZER_KEY)) { |
| 42 | this->use_elp_optimizer = json[HGRAPH_USE_ELP_OPTIMIZER_KEY].GetBool(); |
| 43 | } |
| 44 | |
| 45 | if (json.Contains(HGRAPH_IGNORE_REORDER_KEY)) { |
| 46 | this->ignore_reorder = json[HGRAPH_IGNORE_REORDER_KEY].GetBool(); |
| 47 | } |
| 48 | |
| 49 | if (json.Contains(HGRAPH_BUILD_BY_BASE_QUANTIZATION_KEY)) { |
| 50 | this->build_by_base = json[HGRAPH_BUILD_BY_BASE_QUANTIZATION_KEY].GetBool(); |
| 51 | } |
| 52 | |
| 53 | CHECK_ARGUMENT(json.Contains(BASE_CODES_KEY), |
| 54 | fmt::format("hgraph parameters must contains {}", BASE_CODES_KEY)); |
| 55 | const auto& base_codes_json = json[BASE_CODES_KEY]; |
| 56 | this->base_codes_param = CreateFlattenParam(base_codes_json); |
| 57 | |
| 58 | if (use_reorder) { |
| 59 | CHECK_ARGUMENT(json.Contains(PRECISE_CODES_KEY), |
| 60 | fmt::format("hgraph parameters must contains {}", PRECISE_CODES_KEY)); |
| 61 | const auto& precise_codes_json = json[PRECISE_CODES_KEY]; |
| 62 | this->precise_codes_param = CreateFlattenParam(precise_codes_json); |
| 63 | } |
| 64 | |
| 65 | CHECK_ARGUMENT(json.Contains(GRAPH_KEY), |
| 66 | fmt::format("hgraph parameters must contains {}", GRAPH_KEY)); |
| 67 | const auto& graph_json = json[GRAPH_KEY]; |
| 68 | |
| 69 | GraphStorageTypes graph_storage_type = GraphStorageTypes::GRAPH_STORAGE_TYPE_VALUE_FLAT; |
| 70 | if (graph_json.Contains(GRAPH_STORAGE_TYPE_KEY)) { |
| 71 | const auto graph_storage_type_str = graph_json[GRAPH_STORAGE_TYPE_KEY].GetString(); |
| 72 | if (graph_storage_type_str == GRAPH_STORAGE_TYPE_VALUE_COMPRESSED) { |
| 73 | graph_storage_type = GraphStorageTypes::GRAPH_STORAGE_TYPE_VALUE_COMPRESSED; |
| 74 | } |
| 75 | |
| 76 | if (graph_storage_type_str != GRAPH_STORAGE_TYPE_VALUE_COMPRESSED && |
| 77 | graph_storage_type_str != GRAPH_STORAGE_TYPE_VALUE_FLAT) { |
| 78 | throw VsagException( |
| 79 | ErrorType::INVALID_ARGUMENT, |
| 80 | fmt::format("invalid graph_storage_type: {}", graph_storage_type_str)); |
| 81 | } |
| 82 | } |
| 83 | this->bottom_graph_param = |
| 84 | GraphInterfaceParameter::GetGraphParameterByJson(graph_storage_type, graph_json); |
| 85 | |
| 86 | hierarchical_graph_param = std::make_shared<SparseGraphDatacellParameter>(); |
| 87 | hierarchical_graph_param->max_degree_ = this->bottom_graph_param->max_degree_ / 2; |
| 88 | if (graph_storage_type == GraphStorageTypes::GRAPH_STORAGE_TYPE_VALUE_FLAT) { |
| 89 | auto graph_param = |
| 90 | std::dynamic_pointer_cast<GraphDataCellParameter>(this->bottom_graph_param); |
| 91 | if (graph_param != nullptr) { |
| 92 | hierarchical_graph_param->remove_flag_bit_ = graph_param->remove_flag_bit_; |
| 93 | hierarchical_graph_param->support_delete_ = graph_param->support_remove_; |
| 94 | } else { |
no test coverage detected