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

Function Proc_IndexesInvoke

src/procedures/proc_list_indexes.c:98–156  ·  view source on GitHub ↗

CALL db.indexes()

Source from the content-addressed store, hash-verified

96
97// CALL db.indexes()
98ProcedureResult Proc_IndexesInvoke
99(
100 ProcedureCtx *ctx,
101 const SIValue *args,
102 const char **yield
103) {
104
105 ASSERT(ctx != NULL);
106 ASSERT(args != NULL);
107 ASSERT(yield != NULL);
108
109 // TODO: introduce invoke validation, similar to arithmetic expressions
110 // expecting no arguments
111 uint arg_count = array_len((SIValue *)args);
112 if(arg_count != 0) return PROCEDURE_ERR;
113
114 GraphContext *gc = QueryCtx_GetGraphCtx();
115
116 IndexesContext *pdata = rm_malloc(sizeof(IndexesContext));
117
118 pdata->gc = gc;
119 pdata->out = array_new(SIValue, 8);
120 pdata->indices = array_new(Index, 0);
121
122 //--------------------------------------------------------------------------
123 // collect all indices
124 //--------------------------------------------------------------------------
125
126 unsigned short n; // number of schemas
127 Schema *s; // current schema
128 unsigned short idx_count; // number of indicies in schema
129 Index indicies[4]; // schema indicies
130
131 // collect indices from node schemas
132 n = GraphContext_SchemaCount(gc, SCHEMA_NODE);
133 for(unsigned short i = 0; i < n; i++) {
134 s = GraphContext_GetSchemaByID(gc, i, SCHEMA_NODE);
135 idx_count = Schema_GetIndicies(s, indicies);
136 for(unsigned short j = 0; j < idx_count; j++) {
137 array_append(pdata->indices, indicies[j]);
138 }
139 }
140
141 // collect indices from edge schemas
142 n = GraphContext_SchemaCount(gc, SCHEMA_EDGE);
143 for(unsigned short i = 0; i < n; i++) {
144 s = GraphContext_GetSchemaByID(gc, i, SCHEMA_EDGE);
145 idx_count = Schema_GetIndicies(s, indicies);
146 for(uint j = 0; j < idx_count; j++) {
147 array_append(pdata->indices, indicies[j]);
148 }
149 }
150
151 _process_yield(pdata, yield);
152
153 ctx->privateData = pdata;
154
155 return PROCEDURE_OK;

Callers

nothing calls this directly

Calls 7

array_lenFunction · 0.85
QueryCtx_GetGraphCtxFunction · 0.85
rm_mallocFunction · 0.85
GraphContext_SchemaCountFunction · 0.85
Schema_GetIndiciesFunction · 0.85
_process_yieldFunction · 0.70

Tested by

no test coverage detected