| 262 | } |
| 263 | |
| 264 | int Framework::bg_load_patch(const std::string& v_path) { |
| 265 | int ret = bg_unload(); |
| 266 | if (ret != 0) { |
| 267 | LOG(WARNING) << "unload background dict failed"; |
| 268 | } |
| 269 | |
| 270 | VirtualDict* bg_dict = create_dict(); |
| 271 | |
| 272 | if (!bg_dict) { |
| 273 | LOG(ERROR) << "create Dict failed"; |
| 274 | return -1; |
| 275 | } |
| 276 | |
| 277 | _status = Status::F_LOADING; |
| 278 | if (_dict[_dict_idx]) { |
| 279 | bg_dict->set_base_dict(_dict[_dict_idx]); |
| 280 | LOG(INFO) << "set base dict from current dict " << _dict_idx; |
| 281 | } |
| 282 | |
| 283 | if (_dict_split > 1) { |
| 284 | ret = bg_dict->load(_dict_set_path, _in_mem, v_path); |
| 285 | } else { |
| 286 | ret = bg_dict->load(_dict_path, _in_mem, v_path); |
| 287 | } |
| 288 | _status = Status::F_RUNNING; |
| 289 | if (ret != 0) { |
| 290 | LOG(WARNING) << "load background dict failed"; |
| 291 | delete bg_dict; |
| 292 | bg_dict = NULL; |
| 293 | return ret; |
| 294 | } else { |
| 295 | LOG(INFO) << "load background dict succ"; |
| 296 | set_bg_dict(bg_dict); |
| 297 | } |
| 298 | return ret; |
| 299 | } |
| 300 | |
| 301 | int Framework::bg_unload() { |
| 302 | VirtualDict* bg_dict = get_bg_dict(); |
no test coverage detected