map each column to a record index such that when resolving resultset row i column j we'll extract data from record at position columns_record_map[j]
| 97 | // such that when resolving resultset row i column j we'll extract |
| 98 | // data from record at position columns_record_map[j] |
| 99 | void ResultSet_MapProjection |
| 100 | ( |
| 101 | ResultSet *set, // resultset to init mappings for |
| 102 | rax *mapping // mapping |
| 103 | ) { |
| 104 | ASSERT(set != NULL); |
| 105 | ASSERT(mapping != NULL); |
| 106 | |
| 107 | if(set->columns_record_map == NULL) { |
| 108 | set->columns_record_map = rm_malloc(sizeof(uint) * set->column_count); |
| 109 | } |
| 110 | |
| 111 | for(uint i = 0; i < set->column_count; i++) { |
| 112 | const char *column = set->columns[i]; |
| 113 | void *idx = raxFind(mapping, (unsigned char *)column, strlen(column)); |
| 114 | ASSERT(idx != raxNotFound); |
| 115 | set->columns_record_map[i] = (intptr_t)idx; |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | // returns number of rows in result-set |
| 120 | uint64_t ResultSet_RowCount |
no test coverage detected