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

Function _JsonEncoder_Edge

src/util/json_encoder.c:63–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63static sds _JsonEncoder_Edge(Edge *e, sds s) {
64 s = sdscatfmt(s, "\"id\": %U", ENTITY_GET_ID(e));
65 GraphContext *gc = QueryCtx_GetGraphCtx();
66 // Retrieve reltype data.
67 int id = Edge_GetRelationID(e);
68 Schema *schema = GraphContext_GetSchemaByID(gc, id, SCHEMA_EDGE);
69 ASSERT(schema);
70 const char *relationship = Schema_GetName(schema);
71 ASSERT(relationship);
72 s = sdscatfmt(s, ", \"relationship\": \"%s\", ", relationship);
73
74 s = _JsonEncoder_Properties((const GraphEntity *)e, s);
75
76 s = sdscat(s, ", \"start\": {");
77 // Retrieve source node data.
78 Node src;
79 Graph_GetNode(gc->g, e->src_id, &src);
80 s = _JsonEncoder_Node(&src, s);
81
82 s = sdscat(s, "}, \"end\": {");
83 // Retrieve dest node data.
84 Node dest;
85 Graph_GetNode(gc->g, e->dest_id, &dest);
86 s = _JsonEncoder_Node(&dest, s);
87
88 s = sdscat(s, "}");
89 return s;
90}
91
92static sds _JsonEncoder_GraphEntity(GraphEntity *ge, sds s, GraphEntityType type) {
93 switch(type) {

Callers 1

_JsonEncoder_GraphEntityFunction · 0.85

Calls 9

sdscatfmtFunction · 0.85
QueryCtx_GetGraphCtxFunction · 0.85
Edge_GetRelationIDFunction · 0.85
Schema_GetNameFunction · 0.85
_JsonEncoder_PropertiesFunction · 0.85
sdscatFunction · 0.85
Graph_GetNodeFunction · 0.85
_JsonEncoder_NodeFunction · 0.85

Tested by

no test coverage detected