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

Function AR_LABELS

src/arithmetic/entity_funcs/entity_funcs.c:28–46  ·  view source on GitHub ↗

returns an array of string representations of each label of a node

Source from the content-addressed store, hash-verified

26
27// returns an array of string representations of each label of a node
28SIValue AR_LABELS(SIValue *argv, int argc, void *private_data) {
29 if(SI_TYPE(argv[0]) == T_NULL) return SI_NullVal();
30
31 Node *node = argv[0].ptrval;
32 GraphContext *gc = QueryCtx_GetGraphCtx();
33 // retrieve node labels
34 uint label_count;
35 NODE_GET_LABELS(gc->g, node, label_count);
36 SIValue res = SI_Array(label_count);
37
38 for(uint i = 0; i < label_count; i++) {
39 Schema *s = GraphContext_GetSchemaByID(gc, labels[i], SCHEMA_NODE);
40 ASSERT(s != NULL);
41 const char *name = Schema_GetName(s);
42 SIArray_Append(&res, SI_ConstStringVal(name));
43 }
44
45 return res;
46}
47
48// returns true if input node contains all specified labels, otherwise false
49SIValue AR_HAS_LABELS(SIValue *argv, int argc, void *private_data) {

Callers

nothing calls this directly

Calls 7

SI_NullValFunction · 0.85
QueryCtx_GetGraphCtxFunction · 0.85
SI_ArrayFunction · 0.85
Schema_GetNameFunction · 0.85
SIArray_AppendFunction · 0.85
SI_ConstStringValFunction · 0.85

Tested by

no test coverage detected