PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ gserialized_gist_penalty()

Datum gserialized_gist_penalty ( PG_FUNCTION_ARGS  )

Definition at line 1175 of file gserialized_gist_nd.c.

1176 {
1177  GISTENTRY *origentry = (GISTENTRY *)PG_GETARG_POINTER(0);
1178  GISTENTRY *newentry = (GISTENTRY *)PG_GETARG_POINTER(1);
1179  float *result = (float *)PG_GETARG_POINTER(2);
1180  GIDX *gbox_index_orig, *gbox_index_new;
1181 
1182  gbox_index_orig = (GIDX *)DatumGetPointer(origentry->key);
1183  gbox_index_new = (GIDX *)DatumGetPointer(newentry->key);
1184 
1185  /* Penalty value of 0 has special code path in Postgres's gistchoose.
1186  * It is used as an early exit condition in subtree loop, allowing faster tree descend.
1187  * For multi-column index, it lets next column break the tie, possibly more confidently.
1188  */
1189  *result = 0.0;
1190 
1191  /* Drop out if we're dealing with null inputs. Shouldn't happen. */
1192  if (gbox_index_orig && gbox_index_new)
1193  {
1194  /* Calculate the size difference of the boxes (volume difference in this case). */
1195  float size_union = gidx_union_volume(gbox_index_orig, gbox_index_new);
1196  float size_orig = gidx_volume(gbox_index_orig);
1197  float volume_extension = size_union - size_orig;
1198 
1199  /* REALM 1: Area extension is nonzero, return it */
1200  if (volume_extension > FLT_EPSILON)
1201  *result = pack_float(volume_extension, 1);
1202  else
1203  {
1204  /* REALM 0: Area extension is zero, return nonzero edge extension */
1205  float edge_union = gidx_union_edge(gbox_index_orig, gbox_index_new);
1206  float edge_orig = gidx_edge(gbox_index_orig);
1207  float edge_extension = edge_union - edge_orig;
1208  if (edge_extension > FLT_EPSILON)
1209  *result = pack_float(edge_extension, 0);
1210  }
1211  }
1212  PG_RETURN_POINTER(result);
1213 }
static float gidx_union_volume(GIDX *a, GIDX *b)
static float gidx_union_edge(GIDX *a, GIDX *b)
static float gidx_volume(GIDX *a)
static float gidx_edge(GIDX *a)
static float pack_float(const float value, const uint8_t realm)

References gidx_edge(), gidx_union_edge(), gidx_union_volume(), gidx_volume(), and pack_float().

Referenced by gserialized_gist_picksplit_constructsplit().

Here is the call graph for this function:
Here is the caller graph for this function: