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

Function SIPath_Compare

src/datatypes/path/sipath.c:148–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

146}
147
148int SIPath_Compare(SIValue p1, SIValue p2) {
149
150 size_t p1NodeCount = SIPath_NodeCount(p1);
151 size_t p2NodeCount = SIPath_NodeCount(p2);
152 // Get minimal length
153 size_t nodeCount = p1NodeCount <= p2NodeCount ? p1NodeCount : p2NodeCount;
154 int res = 0;
155 for(size_t i = 0; i < nodeCount - 1 ; i++) {
156 SIValue p1node = SIPath_GetNode(p1, i);
157 SIValue p2node = SIPath_GetNode(p2, i);
158 res = SIValue_Compare(p1node, p2node, NULL);
159 if(res) return res;
160 SIValue p1edge = SIPath_GetRelationship(p1, i);
161 SIValue p2edge = SIPath_GetRelationship(p2, i);
162 res = SIValue_Compare(p1edge, p2edge, NULL);
163 if(res) return res;
164 }
165 // Handle last node.
166 if(nodeCount > 0) {
167 SIValue p1node = SIPath_GetNode(p1, nodeCount - 1);
168 SIValue p2node = SIPath_GetNode(p2, nodeCount - 1);
169 res = SIValue_Compare(p1node, p2node, NULL);
170 if(res) return res;
171 }
172 return p1NodeCount - p2NodeCount;
173}
174
175void SIPath_Free(SIValue p) {
176 if(p.allocation == M_SELF) {

Callers 1

SIValue_CompareFunction · 0.85

Calls 4

SIPath_NodeCountFunction · 0.85
SIPath_GetNodeFunction · 0.85
SIValue_CompareFunction · 0.85
SIPath_GetRelationshipFunction · 0.85

Tested by

no test coverage detected