returns true if input node contains all specified labels, otherwise false
| 47 | |
| 48 | // returns true if input node contains all specified labels, otherwise false |
| 49 | SIValue AR_HAS_LABELS(SIValue *argv, int argc, void *private_data) { |
| 50 | if(SI_TYPE(argv[0]) == T_NULL) return SI_NullVal(); |
| 51 | |
| 52 | bool res = true; |
| 53 | Node *node = argv[0].ptrval; |
| 54 | SIValue labels = argv[1]; |
| 55 | EntityID id = ENTITY_GET_ID(node); |
| 56 | GraphContext *gc = QueryCtx_GetGraphCtx(); |
| 57 | Graph *g = gc->g; |
| 58 | |
| 59 | // iterate over given labels |
| 60 | uint32_t labels_length = SIArray_Length(labels); |
| 61 | for (uint32_t i = 0; i < labels_length; i++) { |
| 62 | SIValue label_value = SIArray_Get(labels, i); |
| 63 | if(SI_TYPE(label_value) != T_STRING) { |
| 64 | Error_SITypeMismatch(label_value, T_STRING); |
| 65 | return SI_NullVal(); |
| 66 | } |
| 67 | char *label = label_value.stringval; |
| 68 | Schema *s = GraphContext_GetSchema(gc, label, SCHEMA_NODE); |
| 69 | |
| 70 | // validate schema exists |
| 71 | if(!s) { |
| 72 | res = false; |
| 73 | break; |
| 74 | } |
| 75 | |
| 76 | // validate label is set |
| 77 | bool x; |
| 78 | RG_Matrix M = Graph_GetLabelMatrix(g, Schema_GetID(s)); |
| 79 | ASSERT(M != NULL); |
| 80 | |
| 81 | if(RG_Matrix_extractElement_BOOL(&x, M, id, id) == GrB_NO_VALUE) { |
| 82 | res = false; |
| 83 | break; |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | return SI_BoolVal(res); |
| 88 | } |
| 89 | |
| 90 | /* returns a string representation of the type of a relation. */ |
| 91 | SIValue AR_TYPE(SIValue *argv, int argc, void *private_data) { |
nothing calls this directly
no test coverage detected