Expand fixed-length (1-hop) relationship edges */
| 3230 | |
| 3231 | /* Expand fixed-length (1-hop) relationship edges */ |
| 3232 | static void expand_fixed_length(cbm_store_t *store, cbm_rel_pattern_t *rel, |
| 3233 | cbm_node_pattern_t *target_node, binding_t *b, cbm_node_t *src, |
| 3234 | const char *to_var, binding_t *new_bindings, int *new_count, |
| 3235 | int max_new, int *match_count) { |
| 3236 | bool is_inbound = rel->direction && strcmp(rel->direction, "inbound") == 0; |
| 3237 | bool is_any = rel->direction && strcmp(rel->direction, "any") == 0; |
| 3238 | const char *rel_var = rel->variable; |
| 3239 | |
| 3240 | if (rel->type_count > 0) { |
| 3241 | for (int ti = 0; ti < rel->type_count; ti++) { |
| 3242 | cbm_edge_t *edges = NULL; |
| 3243 | int edge_count = 0; |
| 3244 | if (is_inbound) { |
| 3245 | cbm_store_find_edges_by_target_type(store, src->id, rel->types[ti], &edges, |
| 3246 | &edge_count); |
| 3247 | } else { |
| 3248 | cbm_store_find_edges_by_source_type(store, src->id, rel->types[ti], &edges, |
| 3249 | &edge_count); |
| 3250 | } |
| 3251 | process_edges(store, edges, edge_count, is_inbound, target_node, b, to_var, rel_var, |
| 3252 | new_bindings, new_count, max_new, match_count); |
| 3253 | cbm_store_free_edges(edges, edge_count); |
| 3254 | } |
| 3255 | if (is_any) { |
| 3256 | for (int ti = 0; ti < rel->type_count; ti++) { |
| 3257 | cbm_edge_t *edges = NULL; |
| 3258 | int edge_count = 0; |
| 3259 | cbm_store_find_edges_by_target_type(store, src->id, rel->types[ti], &edges, |
| 3260 | &edge_count); |
| 3261 | process_edges(store, edges, edge_count, true, target_node, b, to_var, rel_var, |
| 3262 | new_bindings, new_count, max_new, match_count); |
| 3263 | cbm_store_free_edges(edges, edge_count); |
| 3264 | } |
| 3265 | } |
| 3266 | } else { |
| 3267 | cbm_edge_t *edges = NULL; |
| 3268 | int edge_count = 0; |
| 3269 | if (is_inbound) { |
| 3270 | cbm_store_find_edges_by_target(store, src->id, &edges, &edge_count); |
| 3271 | } else { |
| 3272 | cbm_store_find_edges_by_source(store, src->id, &edges, &edge_count); |
| 3273 | } |
| 3274 | process_edges(store, edges, edge_count, is_inbound, target_node, b, to_var, rel_var, |
| 3275 | new_bindings, new_count, max_new, match_count); |
| 3276 | cbm_store_free_edges(edges, edge_count); |
| 3277 | if (is_any) { |
| 3278 | edges = NULL; |
| 3279 | edge_count = 0; |
| 3280 | cbm_store_find_edges_by_target(store, src->id, &edges, &edge_count); |
| 3281 | process_edges(store, edges, edge_count, true, target_node, b, to_var, rel_var, |
| 3282 | new_bindings, new_count, max_new, match_count); |
| 3283 | cbm_store_free_edges(edges, edge_count); |
| 3284 | } |
| 3285 | } |
| 3286 | } |
| 3287 | |
| 3288 | static void expand_pattern_rels(cbm_store_t *store, cbm_pattern_t *pat, binding_t **bindings, |
| 3289 | int *bind_count, const int *bind_cap, const char **var_name, |
no test coverage detected