PostGIS  2.3.7dev-r@@SVN_REVISION@@
Datum gserialized_gist_penalty ( PG_FUNCTION_ARGS  )

Definition at line 1251 of file gserialized_gist_nd.c.

References gidx_union_volume(), and gidx_volume().

Referenced by gserialized_gist_picksplit_constructsplit().

1252 {
1253  GISTENTRY *origentry = (GISTENTRY*) PG_GETARG_POINTER(0);
1254  GISTENTRY *newentry = (GISTENTRY*) PG_GETARG_POINTER(1);
1255  float *result = (float*) PG_GETARG_POINTER(2);
1256  GIDX *gbox_index_orig, *gbox_index_new;
1257  float size_union, size_orig;
1258 
1259  POSTGIS_DEBUG(4, "[GIST] 'penalty' function called");
1260 
1261  gbox_index_orig = (GIDX*)DatumGetPointer(origentry->key);
1262  gbox_index_new = (GIDX*)DatumGetPointer(newentry->key);
1263 
1264  /* Drop out if we're dealing with null inputs. Shouldn't happen. */
1265  if ( (gbox_index_orig == NULL) && (gbox_index_new == NULL) )
1266  {
1267  POSTGIS_DEBUG(4, "[GIST] both inputs NULL! returning penalty of zero");
1268  *result = 0.0;
1269  PG_RETURN_FLOAT8(*result);
1270  }
1271 
1272  /* Calculate the size difference of the boxes (volume difference in this case). */
1273  size_union = gidx_union_volume(gbox_index_orig, gbox_index_new);
1274  size_orig = gidx_volume(gbox_index_orig);
1275  *result = size_union - size_orig;
1276 
1277  /* All things being equal, we prefer to expand small boxes rather than large boxes.
1278  NOTE: This code seemed to be causing badly balanced trees to be built
1279  and therefore has been commented out. Not sure why it didn't work,
1280  but it didn't.
1281  if( FP_IS_ZERO(*result) )
1282  if( FP_IS_ZERO(size_orig) )
1283  *result = 0.0;
1284  else
1285  *result = 1.0 - (1.0/(1.0 + size_orig));
1286  else
1287  *result += 1.0;
1288  */
1289 
1290  POSTGIS_DEBUGF(4, "[GIST] union size (%.12f), original size (%.12f), penalty (%.12f)", size_union, size_orig, *result);
1291 
1292  PG_RETURN_POINTER(result);
1293 }
static float gidx_volume(GIDX *a)
static float gidx_union_volume(GIDX *a, GIDX *b)

Here is the call graph for this function:

Here is the caller graph for this function: