MCPcopy Create free account
hub / github.com/apache/cloudberry / createHashPartitionedPolicy

Function createHashPartitionedPolicy

src/backend/cdb/cdbcat.c:129–152  ·  view source on GitHub ↗

* createHashPartitionedPolicy-- Create a policy with data * partitioned by keys */

Source from the content-addressed store, hash-verified

127 * partitioned by keys
128 */
129GpPolicy *
130createHashPartitionedPolicy(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.

Callers 5

ATExecSetDistributedByFunction · 0.85
setQryDistributionPolicyFunction · 0.85
cdbllize_adjust_top_pathFunction · 0.85

Calls 4

list_lengthFunction · 0.85
makeGpPolicyFunction · 0.85
forbothFunction · 0.85

Tested by

no test coverage detected