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

Function SIPath_HashCode

src/datatypes/path/sipath.c:97–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95}
96
97XXH64_hash_t SIPath_HashCode(SIValue p) {
98 SIType t = SI_TYPE(p);
99 XXH64_hash_t hashCode = XXH64(&t, sizeof(t), 0);
100 size_t nodeCount = SIPath_NodeCount(p);
101 for(size_t i = 0; i < nodeCount - 1 ; i++) {
102 SIValue node = SIPath_GetNode(p, i);
103 hashCode = 31 * hashCode + SIValue_HashCode(node);
104 SIValue edge = SIPath_GetRelationship(p, i);
105 hashCode = 31 * hashCode + SIValue_HashCode(edge);
106 }
107 // Handle last node.
108 if(nodeCount > 0) {
109 SIValue node = SIPath_GetNode(p, nodeCount - 1);
110 hashCode = 31 * hashCode + SIValue_HashCode(node);
111 }
112 return hashCode;
113}
114
115void SIPath_ToString(SIValue p, char **buf, size_t *bufferLen, size_t *bytesWritten) {
116 // 64 is defiend arbitrarily.

Callers 1

SIValue_HashUpdateFunction · 0.85

Calls 4

SIPath_NodeCountFunction · 0.85
SIPath_GetNodeFunction · 0.85
SIValue_HashCodeFunction · 0.85
SIPath_GetRelationshipFunction · 0.85

Tested by

no test coverage detected