MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / Index_Clone

Function Index_Clone

src/index/index.c:305–341  ·  view source on GitHub ↗

clone index

Source from the content-addressed store, hash-verified

303
304// clone index
305Index 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
344int Index_PendingChanges

Callers 3

Schema_AddFullTextIndexFunction · 0.85

Calls 5

Index_EnabledFunction · 0.85
rm_mallocFunction · 0.85
rm_strdupFunction · 0.85
array_lenFunction · 0.85
IndexField_NewFunction · 0.85

Tested by

no test coverage detected