PostGIS  2.5.1dev-r@@SVN_REVISION@@

◆ gidx_merge()

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

Definition at line 173 of file gserialized_gist_nd.c.

References 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().

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  *b_union = b_new;
188  return;
189  }
190 
191  dims_union = GIDX_NDIMS(*b_union);
192  dims_new = GIDX_NDIMS(b_new);
193 
194  POSTGIS_DEBUGF(4, "merging gidx (%s) into gidx (%s)", gidx_to_string(b_new), gidx_to_string(*b_union));
195 
196  if ( dims_new > dims_union )
197  {
198  POSTGIS_DEBUGF(5, "reallocating b_union from %d dims to %d dims", dims_union, dims_new);
199  *b_union = (GIDX*)repalloc(*b_union, GIDX_SIZE(dims_new));
200  SET_VARSIZE(*b_union, VARSIZE(b_new));
201  dims_union = dims_new;
202  }
203 
204  for ( i = 0; i < dims_new; i++ )
205  {
206  /* Adjust minimums */
207  GIDX_SET_MIN(*b_union, i, Min(GIDX_GET_MIN(*b_union,i),GIDX_GET_MIN(b_new,i)));
208  /* Adjust maximums */
209  GIDX_SET_MAX(*b_union, i, Max(GIDX_GET_MAX(*b_union,i),GIDX_GET_MAX(b_new,i)));
210  }
211 
212  POSTGIS_DEBUGF(5, "merge complete (%s)", gidx_to_string(*b_union));
213  return;
214 }
bool gidx_is_unknown(const GIDX *a)
Here is the call graph for this function:
Here is the caller graph for this function: