clone index
| 303 | |
| 304 | // clone index |
| 305 | Index Index_Clone |
| 306 | ( |
| 307 | const Index idx // index to clone |
| 308 | ) { |
| 309 | ASSERT(idx != NULL); |
| 310 | ASSERT(Index_Enabled(idx)); |
| 311 | |
| 312 | //-------------------------------------------------------------------------- |
| 313 | // clone index |
| 314 | //-------------------------------------------------------------------------- |
| 315 | |
| 316 | Index clone = rm_malloc(sizeof(_Index)); |
| 317 | memcpy(clone, idx, sizeof(_Index)); |
| 318 | |
| 319 | clone->rsIdx = NULL; |
| 320 | clone->label = rm_strdup(idx->label); |
| 321 | clone->pending_changes = ATOMIC_VAR_INIT(0); |
| 322 | |
| 323 | if(clone->stopwords != NULL) { |
| 324 | array_clone_with_cb(clone->stopwords, idx->stopwords, rm_strdup); |
| 325 | } |
| 326 | |
| 327 | //-------------------------------------------------------------------------- |
| 328 | // clone index fields |
| 329 | //-------------------------------------------------------------------------- |
| 330 | |
| 331 | int n = array_len(idx->fields); |
| 332 | clone->fields = array_new(IndexField, 1); |
| 333 | for(int i = 0; i < n; i++) { |
| 334 | IndexField _f; |
| 335 | IndexField *f = idx->fields + i; |
| 336 | IndexField_New(&_f, f->id, f->name, f->weight, f->nostem, f->phonetic); |
| 337 | array_append(clone->fields, _f); |
| 338 | } |
| 339 | |
| 340 | return clone; |
| 341 | } |
| 342 | |
| 343 | // returns number of pending changes |
| 344 | int Index_PendingChanges |
no test coverage detected