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

Function Proc_FulltextQueryNodeInvoke

src/procedures/proc_fulltext_query.c:57–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55}
56
57ProcedureResult Proc_FulltextQueryNodeInvoke
58(
59 ProcedureCtx *ctx,
60 const SIValue *args,
61 const char **yield
62) {
63 if(array_len((SIValue *)args) != 2) return PROCEDURE_ERR;
64 if(!(SI_TYPE(args[0]) & SI_TYPE(args[1]) & T_STRING)) return PROCEDURE_ERR;
65
66 ctx->privateData = NULL;
67 GraphContext *gc = QueryCtx_GetGraphCtx();
68
69 // see if there's a full-text index for given label
70 char *err = NULL;
71 const char *label = args[0].stringval;
72 const char *query = args[1].stringval;
73
74 // get full-text index from schema
75 Index idx = GraphContext_GetIndex(gc, label, NULL, 0, IDX_FULLTEXT,
76 SCHEMA_NODE);
77 if(!idx) return PROCEDURE_ERR; // TODO: this should cause an error to be emitted
78
79 ctx->privateData = rm_malloc(sizeof(QueryNodeContext));
80 QueryNodeContext *pdata = ctx->privateData;
81
82 pdata->g = gc->g;
83 pdata->n = GE_NEW_NODE();
84 pdata->idx = idx;
85 pdata->output = array_new(SIValue, 2);
86
87 _process_yield(pdata, yield);
88
89 // execute query
90 pdata->iter = Index_Query(pdata->idx, query, &err);
91
92 // raise runtime exception if err != NULL
93 if(err) {
94 // RediSearch error message is allocated using `rm_strdup`
95 // QueryCtx is expecting to free `error` using `free`
96 // in which case we have no option but to clone error
97 ErrorCtx_SetError("RediSearch: %s", err);
98 rm_free(err);
99 // raise the exception, we expect an exception handler to be set
100 // as procedure invocation is done at runtime
101 ErrorCtx_RaiseRuntimeException(NULL);
102 }
103
104 ASSERT(pdata->iter != NULL);
105
106 return PROCEDURE_OK;
107}
108
109SIValue *Proc_FulltextQueryNodeStep
110(

Callers

nothing calls this directly

Calls 9

array_lenFunction · 0.85
QueryCtx_GetGraphCtxFunction · 0.85
GraphContext_GetIndexFunction · 0.85
rm_mallocFunction · 0.85
Index_QueryFunction · 0.85
ErrorCtx_SetErrorFunction · 0.85
rm_freeFunction · 0.85
_process_yieldFunction · 0.70

Tested by

no test coverage detected