* createHashPartitionedPolicy-- Create a policy with data * partitioned by keys */
| 127 | * partitioned by keys |
| 128 | */ |
| 129 | GpPolicy * |
| 130 | createHashPartitionedPolicy(List *keys, List *opclasses, int numsegments) |
| 131 | { |
| 132 | GpPolicy *policy; |
| 133 | ListCell *lc; |
| 134 | ListCell *lop; |
| 135 | int idx = 0; |
| 136 | int len = list_length(keys); |
| 137 | |
| 138 | Assert(list_length(keys) == list_length(opclasses)); |
| 139 | |
| 140 | if (len == 0) |
| 141 | return createRandomPartitionedPolicy(numsegments); |
| 142 | |
| 143 | policy = makeGpPolicy(POLICYTYPE_PARTITIONED, len, numsegments); |
| 144 | forboth(lc, keys, lop, opclasses) |
| 145 | { |
| 146 | policy->attrs[idx] = (AttrNumber) lfirst_int(lc); |
| 147 | policy->opclasses[idx] = (Oid) lfirst_oid(lop); |
| 148 | idx++; |
| 149 | } |
| 150 | |
| 151 | return policy; |
| 152 | } |
| 153 | |
| 154 | /* |
| 155 | * GpPolicyCopy -- Return a copy of a GpPolicy object. |
no test coverage detected