Expand fixed-length (1-hop) relationship edges */
| 2936 | |
| 2937 | /* Expand fixed-length (1-hop) relationship edges */ |
| 2938 | static void expand_fixed_length(cbm_store_t *store, cbm_rel_pattern_t *rel, |
| 2939 | cbm_node_pattern_t *target_node, binding_t *b, cbm_node_t *src, |
| 2940 | const char *to_var, binding_t *new_bindings, int *new_count, |
| 2941 | int max_new, int *match_count) { |
| 2942 | bool is_inbound = rel->direction && strcmp(rel->direction, "inbound") == 0; |
| 2943 | bool is_any = rel->direction && strcmp(rel->direction, "any") == 0; |
| 2944 | const char *rel_var = rel->variable; |
| 2945 | |
| 2946 | if (rel->type_count > 0) { |
| 2947 | for (int ti = 0; ti < rel->type_count; ti++) { |
| 2948 | cbm_edge_t *edges = NULL; |
| 2949 | int edge_count = 0; |
| 2950 | if (is_inbound) { |
| 2951 | cbm_store_find_edges_by_target_type(store, src->id, rel->types[ti], &edges, |
| 2952 | &edge_count); |
| 2953 | } else { |
| 2954 | cbm_store_find_edges_by_source_type(store, src->id, rel->types[ti], &edges, |
| 2955 | &edge_count); |
| 2956 | } |
| 2957 | process_edges(store, edges, edge_count, is_inbound, target_node, b, to_var, rel_var, |
| 2958 | new_bindings, new_count, max_new, match_count); |
| 2959 | cbm_store_free_edges(edges, edge_count); |
| 2960 | } |
| 2961 | if (is_any) { |
| 2962 | for (int ti = 0; ti < rel->type_count; ti++) { |
| 2963 | cbm_edge_t *edges = NULL; |
| 2964 | int edge_count = 0; |
| 2965 | cbm_store_find_edges_by_target_type(store, src->id, rel->types[ti], &edges, |
| 2966 | &edge_count); |
| 2967 | process_edges(store, edges, edge_count, true, target_node, b, to_var, rel_var, |
| 2968 | new_bindings, new_count, max_new, match_count); |
| 2969 | cbm_store_free_edges(edges, edge_count); |
| 2970 | } |
| 2971 | } |
| 2972 | } else { |
| 2973 | cbm_edge_t *edges = NULL; |
| 2974 | int edge_count = 0; |
| 2975 | if (is_inbound) { |
| 2976 | cbm_store_find_edges_by_target(store, src->id, &edges, &edge_count); |
| 2977 | } else { |
| 2978 | cbm_store_find_edges_by_source(store, src->id, &edges, &edge_count); |
| 2979 | } |
| 2980 | process_edges(store, edges, edge_count, is_inbound, target_node, b, to_var, rel_var, |
| 2981 | new_bindings, new_count, max_new, match_count); |
| 2982 | cbm_store_free_edges(edges, edge_count); |
| 2983 | if (is_any) { |
| 2984 | edges = NULL; |
| 2985 | edge_count = 0; |
| 2986 | cbm_store_find_edges_by_target(store, src->id, &edges, &edge_count); |
| 2987 | process_edges(store, edges, edge_count, true, target_node, b, to_var, rel_var, |
| 2988 | new_bindings, new_count, max_new, match_count); |
| 2989 | cbm_store_free_edges(edges, edge_count); |
| 2990 | } |
| 2991 | } |
| 2992 | } |
| 2993 | |
| 2994 | static void expand_pattern_rels(cbm_store_t *store, cbm_pattern_t *pat, binding_t **bindings, |
| 2995 | int *bind_count, const int *bind_cap, const char **var_name, |
no test coverage detected