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

Function AR_TOSTRINGLIST

src/arithmetic/list_funcs/list_funcs.c:175–195  ·  view source on GitHub ↗

Convert a list of values to a list of string values. The conversion of each item in list is done using toStringOrNull */

Source from the content-addressed store, hash-verified

173/* Convert a list of values to a list of string values.
174 The conversion of each item in list is done using toStringOrNull */
175SIValue AR_TOSTRINGLIST(SIValue *argv, int argc, void *private_data) {
176 ASSERT(argc == 1);
177 if(SI_TYPE(argv[0]) == T_NULL) {
178 return SI_NullVal();
179 }
180 ASSERT(SI_TYPE(argv[0]) == T_ARRAY);
181 SIValue originalArray = argv[0];
182
183 // get array length
184 uint32_t arrayLen = SIArray_Length(originalArray);
185
186 SIValue array = SI_Array(arrayLen);
187 for(uint i = 0; i < arrayLen; i++) {
188 SIValue v = SIArray_Get(originalArray, i);
189 SIValue vstr = AR_TOSTRING(&v, 1, NULL);
190 SIArray_Append(&array, vstr);
191 SIValue_Free(vstr);
192 SIValue_Free(v);
193 }
194 return array;
195}
196
197// normalize index
198// returns true if 'index' is in range: [0..array_len]

Callers

nothing calls this directly

Calls 7

SI_NullValFunction · 0.85
SIArray_LengthFunction · 0.85
SI_ArrayFunction · 0.85
SIArray_GetFunction · 0.85
AR_TOSTRINGFunction · 0.85
SIArray_AppendFunction · 0.85
SIValue_FreeFunction · 0.85

Tested by

no test coverage detected