PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ gidx_merge()

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

Definition at line 173 of file gserialized_gist_nd.c.

174 {
175  int i, dims_union, dims_new;
176  Assert(b_union);
177  Assert(*b_union);
178  Assert(b_new);
179 
180  /* Can't merge an unknown into any thing */
181  if( gidx_is_unknown(b_new) )
182  return;
183 
184  /* Merge of unknown and known is known */
185  if( gidx_is_unknown(*b_union) )
186  {
187  pfree(*b_union);
188  *b_union = gidx_copy(b_new);
189  return;
190  }
191 
192  dims_union = GIDX_NDIMS(*b_union);
193  dims_new = GIDX_NDIMS(b_new);
194 
195  POSTGIS_DEBUGF(4, "merging gidx (%s) into gidx (%s)", gidx_to_string(b_new), gidx_to_string(*b_union));
196 
197  if ( dims_new < dims_union )
198  {
199  POSTGIS_DEBUGF(5, "reallocating b_union from %d dims to %d dims", dims_union, dims_new);
200  *b_union = (GIDX*)repalloc(*b_union, GIDX_SIZE(dims_new));
201  SET_VARSIZE(*b_union, VARSIZE(b_new));
202  dims_union = dims_new;
203  }
204 
205  for ( i = 0; i < dims_union; i++ )
206  {
207  /* Adjust minimums */
208  GIDX_SET_MIN(*b_union, i, Min(GIDX_GET_MIN(*b_union,i),GIDX_GET_MIN(b_new,i)));
209  /* Adjust maximums */
210  GIDX_SET_MAX(*b_union, i, Max(GIDX_GET_MAX(*b_union,i),GIDX_GET_MAX(b_new,i)));
211  }
212 
213  POSTGIS_DEBUGF(5, "merge complete (%s)", gidx_to_string(*b_union));
214  return;
215 }
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: