PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ gidx_merge()

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

Definition at line 145 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(), and gserialized_gist_union().

146 {
147  int i, dims_union, dims_new;
148  Assert(b_union);
149  Assert(*b_union);
150  Assert(b_new);
151 
152  /* Can't merge an unknown into any thing */
153  if( gidx_is_unknown(b_new) )
154  return;
155 
156  /* Merge of unknown and known is known */
157  if( gidx_is_unknown(*b_union) )
158  {
159  *b_union = b_new;
160  return;
161  }
162 
163  dims_union = GIDX_NDIMS(*b_union);
164  dims_new = GIDX_NDIMS(b_new);
165 
166  POSTGIS_DEBUGF(4, "merging gidx (%s) into gidx (%s)", gidx_to_string(b_new), gidx_to_string(*b_union));
167 
168  if ( dims_new > dims_union )
169  {
170  POSTGIS_DEBUGF(5, "reallocating b_union from %d dims to %d dims", dims_union, dims_new);
171  *b_union = (GIDX*)repalloc(*b_union, GIDX_SIZE(dims_new));
172  SET_VARSIZE(*b_union, VARSIZE(b_new));
173  dims_union = dims_new;
174  }
175 
176  for ( i = 0; i < dims_new; i++ )
177  {
178  /* Adjust minimums */
179  GIDX_SET_MIN(*b_union, i, Min(GIDX_GET_MIN(*b_union,i),GIDX_GET_MIN(b_new,i)));
180  /* Adjust maximums */
181  GIDX_SET_MAX(*b_union, i, Max(GIDX_GET_MAX(*b_union,i),GIDX_GET_MAX(b_new,i)));
182  }
183 
184  POSTGIS_DEBUGF(5, "merge complete (%s)", gidx_to_string(*b_union));
185  return;
186 }
static bool gidx_is_unknown(const GIDX *a)
Here is the call graph for this function:
Here is the caller graph for this function: