PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ gidx_merge()

void gidx_merge ( GIDX **  b_union,
GIDX *  b_new 
)

Definition at line 160 of file gserialized_gist_nd.c.

161 {
162  int i, dims_union, dims_new;
163  Assert(b_union);
164  Assert(*b_union);
165  Assert(b_new);
166 
167  /* Can't merge an unknown into any thing */
168  /* Q: Unknown is 0 dimensions. Should we reset result to unknown instead? (ticket #4232) */
169  if (gidx_is_unknown(b_new))
170  return;
171 
172  /* Merge of unknown and known is known */
173  /* Q: Unknown is 0 dimensions. Should we never modify unknown instead? (ticket #4232) */
174  if (gidx_is_unknown(*b_union))
175  {
176  pfree(*b_union);
177  *b_union = gidx_copy(b_new);
178  return;
179  }
180 
181  dims_union = GIDX_NDIMS(*b_union);
182  dims_new = GIDX_NDIMS(b_new);
183 
184  /* Shrink unshared dimensions.
185  * Unset dimension is essentially [-FLT_MAX, FLT_MAX], so we can either trim it or reset to that range.*/
186  if (dims_new < dims_union)
187  {
188  *b_union = (GIDX *)repalloc(*b_union, GIDX_SIZE(dims_new));
189  SET_VARSIZE(*b_union, VARSIZE(b_new));
190  dims_union = dims_new;
191  }
192 
193  for (i = 0; i < dims_union; i++)
194  {
195  /* Adjust minimums */
196  GIDX_SET_MIN(*b_union, i, Min(GIDX_GET_MIN(*b_union, i), GIDX_GET_MIN(b_new, i)));
197  /* Adjust maximums */
198  GIDX_SET_MAX(*b_union, i, Max(GIDX_GET_MAX(*b_union, i), GIDX_GET_MAX(b_new, i)));
199  }
200 }
bool gidx_is_unknown(const GIDX *a)
GIDX * gidx_copy(GIDX *b)

References gidx_copy(), and gidx_is_unknown().

Referenced by gserialized_gist_picksplit(), gserialized_gist_picksplit_addlist(), gserialized_gist_picksplit_constructsplit(), gserialized_gist_picksplit_fallback(), gserialized_gist_union(), and spatial_index_read_extent().

Here is the call graph for this function:
Here is the caller graph for this function: