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

Function _PopulateReduceCtx

src/arithmetic/list_funcs/list_funcs.c:67–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65}
66
67static void _PopulateReduceCtx
68(
69 ListReduceCtx *ctx,
70 Record outer_record
71) {
72 rax *record_map = raxClone(outer_record->mapping);
73
74 //--------------------------------------------------------------------------
75 // map variable name
76 //--------------------------------------------------------------------------
77
78 intptr_t id = raxSize(record_map);
79 raxTryInsert(record_map, (unsigned char *)ctx->variable,
80 strlen(ctx->variable), (void *)id, NULL);
81
82 //--------------------------------------------------------------------------
83 // map accumulator name
84 //--------------------------------------------------------------------------
85
86 id++;
87 raxTryInsert(record_map, (unsigned char *)ctx->accumulator,
88 strlen(ctx->accumulator), (void *)id, NULL);
89
90 ctx->record = Record_New(record_map);
91
92 // this could just be assigned to 'id'
93 // but for safety we'll use a Record lookup
94 ctx->variable_idx = Record_GetEntryIdx(ctx->record, ctx->variable);
95 ctx->accumulator_idx = Record_GetEntryIdx(ctx->record, ctx->accumulator);
96 ASSERT(ctx->variable_idx != INVALID_INDEX);
97 ASSERT(ctx->accumulator_idx != INVALID_INDEX);
98}
99
100// forward declaration of property function
101SIValue AR_PROPERTY(SIValue *argv, int argc, void *private_data);

Callers 1

AR_REDUCEFunction · 0.85

Calls 3

raxCloneFunction · 0.85
Record_NewFunction · 0.85
Record_GetEntryIdxFunction · 0.85

Tested by

no test coverage detected