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

Function _JsonEncoder_Path

src/util/json_encoder.c:109–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107}
108
109static sds _JsonEncoder_Path(SIValue p, sds s) {
110 // open path with "["
111 s = sdscat(s, "[");
112
113 size_t nodeCount = SIPath_NodeCount(p);
114 for(size_t i = 0; i < nodeCount - 1; i ++) {
115 // write the next value
116 SIValue node = SIPath_GetNode(p, i);
117 s = _JsonEncoder_GraphEntity((GraphEntity *)node.ptrval, s, GETYPE_NODE);
118 s = sdscat(s, ", ");
119 SIValue edge = SIPath_GetRelationship(p, i);
120 s = _JsonEncoder_GraphEntity((GraphEntity *)edge.ptrval, s, GETYPE_EDGE);
121 s = sdscat(s, ", ");
122 }
123 // Handle last node.
124 if(nodeCount > 0) {
125 SIValue node = SIPath_GetNode(p, nodeCount - 1);
126 s = _JsonEncoder_GraphEntity((GraphEntity *)node.ptrval, s, GETYPE_NODE);
127 }
128
129 // close array with "]"
130 s = sdscat(s, "]");
131 return s;
132}
133
134static sds _JsonEncoder_Point(SIValue point, sds s) {
135 ASSERT(SI_TYPE(point) & T_POINT);

Callers 1

_JsonEncoder_SIValueFunction · 0.85

Calls 5

sdscatFunction · 0.85
SIPath_NodeCountFunction · 0.85
SIPath_GetNodeFunction · 0.85
_JsonEncoder_GraphEntityFunction · 0.85
SIPath_GetRelationshipFunction · 0.85

Tested by

no test coverage detected