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

Definition at line 768 of file gserialized_gist_nd.c.

References gidx_union_volume(), gidx_volume(), and result.

Referenced by gserialized_gist_picksplit_constructsplit().

769 {
770  GISTENTRY *origentry = (GISTENTRY*) PG_GETARG_POINTER(0);
771  GISTENTRY *newentry = (GISTENTRY*) PG_GETARG_POINTER(1);
772  float *result = (float*) PG_GETARG_POINTER(2);
773  GIDX *gbox_index_orig, *gbox_index_new;
774  float size_union, size_orig;
775 
776  POSTGIS_DEBUG(4, "[GIST] 'penalty' function called");
777 
778  gbox_index_orig = (GIDX*)DatumGetPointer(origentry->key);
779  gbox_index_new = (GIDX*)DatumGetPointer(newentry->key);
780 
781  /* Drop out if we're dealing with null inputs. Shouldn't happen. */
782  if ( (gbox_index_orig == NULL) && (gbox_index_new == NULL) )
783  {
784  POSTGIS_DEBUG(4, "[GIST] both inputs NULL! returning penalty of zero");
785  *result = 0.0;
786  PG_RETURN_FLOAT8(*result);
787  }
788 
789  /* Calculate the size difference of the boxes (volume difference in this case). */
790  size_union = gidx_union_volume(gbox_index_orig, gbox_index_new);
791  size_orig = gidx_volume(gbox_index_orig);
792  *result = size_union - size_orig;
793 
794  /* All things being equal, we prefer to expand small boxes rather than large boxes.
795  NOTE: This code seemed to be causing badly balanced trees to be built
796  and therefore has been commented out. Not sure why it didn't work,
797  but it didn't.
798  if( FP_IS_ZERO(*result) )
799  if( FP_IS_ZERO(size_orig) )
800  *result = 0.0;
801  else
802  *result = 1.0 - (1.0/(1.0 + size_orig));
803  else
804  *result += 1.0;
805  */
806 
807  POSTGIS_DEBUGF(4, "[GIST] union size (%.12f), original size (%.12f), penalty (%.12f)", size_union, size_orig, *result);
808 
809  PG_RETURN_POINTER(result);
810 }
static float gidx_volume(GIDX *a)
static float gidx_union_volume(GIDX *a, GIDX *b)
char ** result
Definition: liblwgeom.h:218

Here is the call graph for this function:

Here is the caller graph for this function: