retrieves group under which given record belongs to creates group if it doesn't exists
| 136 | // retrieves group under which given record belongs to |
| 137 | // creates group if it doesn't exists |
| 138 | static 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 | |
| 173 | static void _aggregateRecord |
| 174 | ( |
no test coverage detected