|
| 1 | +/** Copyright 2020 Alibaba Group Holding Limited. |
| 2 | +
|
| 3 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +you may not use this file except in compliance with the License. |
| 5 | +You may obtain a copy of the License at |
| 6 | +
|
| 7 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +
|
| 9 | +Unless required by applicable law or agreed to in writing, software |
| 10 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +See the License for the specific language governing permissions and |
| 13 | +limitations under the License. |
| 14 | +*/ |
| 15 | + |
| 16 | +#include "src/predefine.h" |
| 17 | +// GRIN headers |
| 18 | +#include "partition/topology.h" |
| 19 | + |
| 20 | +#if defined(GRIN_TRAIT_SELECT_MASTER_FOR_VERTEX_LIST) && \ |
| 21 | + !defined(GRIN_WITH_VERTEX_PROPERTY) |
| 22 | +GRIN_VERTEX_LIST grin_get_vertex_list_select_master(GRIN_GRAPH); |
| 23 | + |
| 24 | +GRIN_VERTEX_LIST grin_get_vertex_list_select_mirror(GRIN_GRAPH); |
| 25 | +#endif |
| 26 | + |
| 27 | +#if defined(GRIN_TRAIT_SELECT_MASTER_FOR_VERTEX_LIST) && \ |
| 28 | + defined(GRIN_WITH_VERTEX_PROPERTY) |
| 29 | +GRIN_VERTEX_LIST grin_get_vertex_list_by_type_select_master( |
| 30 | + GRIN_GRAPH g, GRIN_VERTEX_TYPE vtype) { |
| 31 | + auto _g = static_cast<GRIN_GRAPH_T*>(g); |
| 32 | + return new GRIN_VERTEX_LIST_T(vtype, ONE_PARTITION, _g->GetPartitionId()); |
| 33 | +} |
| 34 | + |
| 35 | +GRIN_VERTEX_LIST grin_get_vertex_list_by_type_select_mirror( |
| 36 | + GRIN_GRAPH g, GRIN_VERTEX_TYPE vtype) { |
| 37 | + auto _g = static_cast<GRIN_GRAPH_T*>(g); |
| 38 | + return new GRIN_VERTEX_LIST_T(vtype, ALL_BUT_ONE_PARTITION, |
| 39 | + _g->GetPartitionId()); |
| 40 | +} |
| 41 | +#endif |
| 42 | + |
| 43 | +#if defined(GRIN_TRAIT_SELECT_PARTITION_FOR_VERTEX_LIST) && \ |
| 44 | + !defined(GRIN_WITH_VERTEX_PROPERTY) |
| 45 | +GRIN_VERTEX_LIST grin_get_vertex_list_select_partition(GRIN_GRAPH, |
| 46 | + GRIN_PARTITION); |
| 47 | +#endif |
| 48 | + |
| 49 | +#if defined(GRIN_TRAIT_SELECT_PARTITION_FOR_VERTEX_LIST) && \ |
| 50 | + defined(GRIN_WITH_VERTEX_PROPERTY) |
| 51 | +GRIN_VERTEX_LIST grin_get_vertex_list_by_type_select_partition( |
| 52 | + GRIN_GRAPH g, GRIN_VERTEX_TYPE vtype, GRIN_PARTITION p) { |
| 53 | + auto _g = static_cast<GRIN_GRAPH_T*>(g); |
| 54 | + if (p >= _g->GetPartitionNum()) { |
| 55 | + return GRIN_NULL_VERTEX_LIST; |
| 56 | + } |
| 57 | + return new GRIN_VERTEX_LIST_T(vtype, ONE_PARTITION, p); |
| 58 | +} |
| 59 | +#endif |
| 60 | + |
| 61 | +#if defined(GRIN_TRAIT_SELECT_MASTER_FOR_EDGE_LIST) && \ |
| 62 | + !defined(GRIN_WITH_EDGE_PROPERTY) |
| 63 | +GRIN_EDGE_LIST grin_get_edge_list_select_master(GRIN_GRAPH); |
| 64 | + |
| 65 | +GRIN_EDGE_LIST grin_get_edge_list_select_mirror(GRIN_GRAPH); |
| 66 | +#endif |
| 67 | + |
| 68 | +#if defined(GRIN_TRAIT_SELECT_MASTER_FOR_EDGE_LIST) && \ |
| 69 | + defined(GRIN_WITH_EDGE_PROPERTY) |
| 70 | +GRIN_EDGE_LIST grin_get_edge_list_by_type_select_master(GRIN_GRAPH g, |
| 71 | + GRIN_EDGE_TYPE etype) { |
| 72 | + auto _g = static_cast<GRIN_GRAPH_T*>(g); |
| 73 | + return new GRIN_EDGE_LIST_T(etype, ONE_PARTITION, _g->GetPartitionId()); |
| 74 | +} |
| 75 | + |
| 76 | +GRIN_EDGE_LIST grin_get_edge_list_by_type_select_mirror(GRIN_GRAPH g, |
| 77 | + GRIN_EDGE_TYPE etype) { |
| 78 | + auto _g = static_cast<GRIN_GRAPH_T*>(g); |
| 79 | + return new GRIN_EDGE_LIST_T(etype, ALL_BUT_ONE_PARTITION, |
| 80 | + _g->GetPartitionId()); |
| 81 | +} |
| 82 | +#endif |
| 83 | + |
| 84 | +#if defined(GRIN_TRAIT_SELECT_PARTITION_FOR_EDGE_LIST) && \ |
| 85 | + !defined(GRIN_WITH_EDGE_PROPERTY) |
| 86 | +GRIN_EDGE_LIST grin_get_edge_list_select_partition(GRIN_GRAPH, GRIN_PARTITION); |
| 87 | +#endif |
| 88 | + |
| 89 | +#if defined(GRIN_TRAIT_SELECT_PARTITION_FOR_EDGE_LIST) && \ |
| 90 | + defined(GRIN_WITH_EDGE_PROPERTY) |
| 91 | +GRIN_EDGE_LIST grin_get_edge_list_by_type_select_partition(GRIN_GRAPH g, |
| 92 | + GRIN_EDGE_TYPE etype, |
| 93 | + GRIN_PARTITION p) { |
| 94 | + auto _g = static_cast<GRIN_GRAPH_T*>(g); |
| 95 | + if (p >= _g->GetPartitionNum()) { |
| 96 | + return GRIN_NULL_EDGE_LIST; |
| 97 | + } |
| 98 | + return new GRIN_EDGE_LIST_T(etype, ONE_PARTITION, p); |
| 99 | +} |
| 100 | +#endif |
| 101 | + |
| 102 | +#if defined(GRIN_TRAIT_SELECT_MASTER_NEIGHBOR_FOR_ADJACENT_LIST) && \ |
| 103 | + !defined(GRIN_WITH_VERTEX_PROPERTY) |
| 104 | +GRIN_ADJACENT_LIST grin_get_adjacent_list_select_master_neighbor(GRIN_GRAPH, |
| 105 | + GRIN_DIRECTION, |
| 106 | + GRIN_VERTEX); |
| 107 | + |
| 108 | +GRIN_ADJACENT_LIST grin_get_adjacent_list_select_mirror_neighbor(GRIN_GRAPH, |
| 109 | + GRIN_DIRECTION, |
| 110 | + GRIN_VERTEX); |
| 111 | +#endif |
| 112 | + |
| 113 | +#if defined(GRIN_TRAIT_SELECT_MASTER_NEIGHBOR_FOR_ADJACENT_LIST) && \ |
| 114 | + defined(GRIN_WITH_VERTEX_PROPERTY) |
| 115 | +GRIN_ADJACENT_LIST grin_get_adjacent_list_by_edge_type_select_master_neighbor( |
| 116 | + GRIN_GRAPH g, GRIN_DIRECTION d, GRIN_VERTEX v, GRIN_EDGE_TYPE etype) { |
| 117 | + auto _g = static_cast<GRIN_GRAPH_T*>(g); |
| 118 | + auto vtype = DEMO_STORAGE_NAMESPACE::get_type_id_from_gid(v); |
| 119 | + auto vid = DEMO_STORAGE_NAMESPACE::get_id_from_gid(v); |
| 120 | + return new GRIN_ADJACENT_LIST_T(vtype, vid, d, etype, ONE_PARTITION, |
| 121 | + _g->GetPartitionId()); |
| 122 | +} |
| 123 | + |
| 124 | +GRIN_ADJACENT_LIST grin_get_adjacent_list_by_edge_type_select_mirror_neighbor( |
| 125 | + GRIN_GRAPH g, GRIN_DIRECTION d, GRIN_VERTEX v, GRIN_EDGE_TYPE etype) { |
| 126 | + auto _g = static_cast<GRIN_GRAPH_T*>(g); |
| 127 | + auto vtype = DEMO_STORAGE_NAMESPACE::get_type_id_from_gid(v); |
| 128 | + auto vid = DEMO_STORAGE_NAMESPACE::get_id_from_gid(v); |
| 129 | + return new GRIN_ADJACENT_LIST_T(vtype, vid, d, etype, ALL_BUT_ONE_PARTITION, |
| 130 | + _g->GetPartitionId()); |
| 131 | +} |
| 132 | +#endif |
| 133 | + |
| 134 | +#if defined(GRIN_TRAIT_SELECT_NEIGHBOR_PARTITION_FOR_ADJACENT_LIST) && \ |
| 135 | + !defined(GRIN_WITH_VERTEX_PROPERTY) |
| 136 | +GRIN_ADJACENT_LIST grin_get_adjacent_list_select_partition_neighbor( |
| 137 | + GRIN_GRAPH, GRIN_DIRECTION, GRIN_VERTEX, GRIN_PARTITION); |
| 138 | +#endif |
| 139 | + |
| 140 | +#if defined(GRIN_TRAIT_SELECT_NEIGHBOR_PARTITION_FOR_ADJACENT_LIST) && \ |
| 141 | + defined(GRIN_WITH_VERTEX_PROPERTY) |
| 142 | +GRIN_ADJACENT_LIST |
| 143 | +grin_get_adjacent_list_by_edge_type_select_partition_neighbor( |
| 144 | + GRIN_GRAPH g, GRIN_DIRECTION d, GRIN_VERTEX v, GRIN_EDGE_TYPE etype, |
| 145 | + GRIN_PARTITION p) { |
| 146 | + auto _g = static_cast<GRIN_GRAPH_T*>(g); |
| 147 | + if (p >= _g->GetPartitionNum()) { |
| 148 | + return GRIN_NULL_ADJACENT_LIST; |
| 149 | + } |
| 150 | + auto vtype = DEMO_STORAGE_NAMESPACE::get_type_id_from_gid(v); |
| 151 | + auto vid = DEMO_STORAGE_NAMESPACE::get_id_from_gid(v); |
| 152 | + return new GRIN_ADJACENT_LIST_T(vtype, vid, d, etype, ONE_PARTITION, p); |
| 153 | +} |
| 154 | +#endif |
0 commit comments