create a new result set
| 58 | |
| 59 | // create a new result set |
| 60 | ResultSet *NewResultSet |
| 61 | ( |
| 62 | RedisModuleCtx *ctx, |
| 63 | ResultSetFormatterType format // resultset format |
| 64 | ) { |
| 65 | ResultSet *set = rm_malloc(sizeof(ResultSet)); |
| 66 | |
| 67 | set->gc = QueryCtx_GetGraphCtx(); |
| 68 | set->ctx = ctx; |
| 69 | set->cells = NULL; |
| 70 | set->format = format; |
| 71 | set->columns = NULL; |
| 72 | set->formatter = ResultSetFormatter_GetFormatter(format); |
| 73 | set->column_count = 0; |
| 74 | set->cells_allocation = M_NONE; |
| 75 | set->columns_record_map = NULL; |
| 76 | |
| 77 | // init resultset statistics |
| 78 | ResultSetStat_init(&set->stats); |
| 79 | |
| 80 | // create resultset columns |
| 81 | if(set->format != FORMATTER_NOP) { |
| 82 | _ResultSet_SetColumns(set); |
| 83 | } |
| 84 | |
| 85 | // allocate space for resultset entries only if data is expected |
| 86 | if(set->column_count > 0) { |
| 87 | // none empty result-set |
| 88 | // allocate enough space for at least 10 rows |
| 89 | uint64_t nrows = set->column_count * 10; |
| 90 | set->cells = DataBlock_New(16384, nrows, sizeof(SIValue), NULL); |
| 91 | } |
| 92 | |
| 93 | return set; |
| 94 | } |
| 95 | |
| 96 | // map each column to a record index |
| 97 | // such that when resolving resultset row i column j we'll extract |
no test coverage detected