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

Function _GetGroup

src/execution_plan/ops/op_aggregate.c:138–171  ·  view source on GitHub ↗

retrieves group under which given record belongs to creates group if it doesn't exists

Source from the content-addressed store, hash-verified

136// retrieves group under which given record belongs to
137// creates group if it doesn't exists
138static Group *_GetGroup
139(
140 OpAggregate *op,
141 Record r
142) {
143 // construct group key
144 // evaluate non-aggregated fields
145
146 SIValue keys[op->key_count];
147 XXH64_hash_t hash = _ComputeGroupKey(keys, op, r);
148
149 // lookup group by hashed key
150 Group *g;
151 dictEntry *existing;
152 dictEntry *entry = HashTableAddRaw(op->groups, (void *)hash, &existing);
153 if(entry == NULL) {
154 // group exists
155 ASSERT(existing != NULL);
156
157 // free computed keys
158 for(uint i = 0; i < op->key_count; i++) {
159 SIValue_Free(keys[i]);
160 }
161
162 g = HashTableGetVal(existing);
163 } else {
164 // entry missing
165 // group does not exists, create it
166 g = _CreateGroup(op, keys);
167 HashTableSetVal(op->groups, entry, g);
168 }
169
170 return g;
171}
172
173static void _aggregateRecord
174(

Callers 2

_aggregateRecordFunction · 0.85
AggregateConsumeFunction · 0.85

Calls 6

_ComputeGroupKeyFunction · 0.85
HashTableAddRawFunction · 0.85
SIValue_FreeFunction · 0.85
HashTableGetValFunction · 0.85
_CreateGroupFunction · 0.85
HashTableSetValFunction · 0.85

Tested by

no test coverage detected