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

Definition at line 1062 of file gserialized_gist_nd.c.

References gidx_union_volume(), and gidx_volume().

Referenced by gserialized_gist_picksplit_constructsplit().

1063 {
1064  GISTENTRY *origentry = (GISTENTRY*) PG_GETARG_POINTER(0);
1065  GISTENTRY *newentry = (GISTENTRY*) PG_GETARG_POINTER(1);
1066  float *result = (float*) PG_GETARG_POINTER(2);
1067  GIDX *gbox_index_orig, *gbox_index_new;
1068  float size_union, size_orig;
1069 
1070  POSTGIS_DEBUG(4, "[GIST] 'penalty' function called");
1071 
1072  gbox_index_orig = (GIDX*)DatumGetPointer(origentry->key);
1073  gbox_index_new = (GIDX*)DatumGetPointer(newentry->key);
1074 
1075  /* Drop out if we're dealing with null inputs. Shouldn't happen. */
1076  if ( (gbox_index_orig == NULL) && (gbox_index_new == NULL) )
1077  {
1078  POSTGIS_DEBUG(4, "[GIST] both inputs NULL! returning penalty of zero");
1079  *result = 0.0;
1080  PG_RETURN_FLOAT8(*result);
1081  }
1082 
1083  /* Calculate the size difference of the boxes (volume difference in this case). */
1084  size_union = gidx_union_volume(gbox_index_orig, gbox_index_new);
1085  size_orig = gidx_volume(gbox_index_orig);
1086  *result = size_union - size_orig;
1087 
1088  /* All things being equal, we prefer to expand small boxes rather than large boxes.
1089  NOTE: This code seemed to be causing badly balanced trees to be built
1090  and therefore has been commented out. Not sure why it didn't work,
1091  but it didn't.
1092  if( FP_IS_ZERO(*result) )
1093  if( FP_IS_ZERO(size_orig) )
1094  *result = 0.0;
1095  else
1096  *result = 1.0 - (1.0/(1.0 + size_orig));
1097  else
1098  *result += 1.0;
1099  */
1100 
1101  POSTGIS_DEBUGF(4, "[GIST] union size (%.12f), original size (%.12f), penalty (%.12f)", size_union, size_orig, *result);
1102 
1103  PG_RETURN_POINTER(result);
1104 }
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: