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

Function SIValue_ConcatList

src/value.c:450–475  ·  view source on GitHub ↗

assumption: either a or b is a list - static function, the caller validate types

Source from the content-addressed store, hash-verified

448
449// assumption: either a or b is a list - static function, the caller validate types
450static SIValue SIValue_ConcatList(const SIValue a, const SIValue b) {
451 uint a_len = (a.type == T_ARRAY) ? SIArray_Length(a) : 1;
452 uint b_len = (b.type == T_ARRAY) ? SIArray_Length(b) : 1;
453 SIValue resultArray = SI_Array(a_len + b_len);
454
455 // Append a to resultArray
456 if(a.type == T_ARRAY) {
457 // in thae case of a is an array
458 for(uint i = 0; i < a_len; i++) SIArray_Append(&resultArray, SIArray_Get(a, i));
459 } else {
460 // in thae case of a is not an array
461 SIArray_Append(&resultArray, a);
462 }
463
464 if(b.type == T_ARRAY) {
465 // b is an array
466 uint bArrayLen = SIArray_Length(b);
467 for(uint i = 0; i < bArrayLen; i++) {
468 SIArray_Append(&resultArray, SIArray_Get(b, i));
469 }
470 } else {
471 // b is not an array
472 SIArray_Append(&resultArray, b);
473 }
474 return resultArray;
475}
476
477SIValue SIValue_Add(const SIValue a, const SIValue b) {
478 if(a.type == T_NULL || b.type == T_NULL) return SI_NullVal();

Callers 1

SIValue_AddFunction · 0.85

Calls 4

SIArray_LengthFunction · 0.85
SI_ArrayFunction · 0.85
SIArray_AppendFunction · 0.85
SIArray_GetFunction · 0.85

Tested by

no test coverage detected