PostGIS  2.1.10dev-r@@SVN_REVISION@@
static void gserialized_gist_picksplit_constructsplit ( GIST_SPLITVEC *  v,
OffsetNumber *  list1,
int  nlist1,
GIDX **  union1,
OffsetNumber *  list2,
int  nlist2,
GIDX **  union2 
)
static

Definition at line 972 of file gserialized_gist_nd.c.

References FALSE, gidx_copy(), gidx_inter_volume(), gidx_merge(), and gserialized_gist_penalty().

Referenced by gserialized_gist_picksplit().

973 {
974  bool firstToLeft = true;
975 
976  POSTGIS_DEBUG(4, "[GIST] picksplit in constructsplit function");
977 
978  if (v->spl_ldatum_exists || v->spl_rdatum_exists)
979  {
980  if (v->spl_ldatum_exists && v->spl_rdatum_exists)
981  {
982  GIDX *LRl = gidx_copy(*union1);
983  GIDX *LRr = gidx_copy(*union2);
984  GIDX *RLl = gidx_copy(*union2);
985  GIDX *RLr = gidx_copy(*union1);
986  double sizeLR, sizeRL;
987 
988  gidx_merge(&LRl, (GIDX*)DatumGetPointer(v->spl_ldatum));
989  gidx_merge(&LRr, (GIDX*)DatumGetPointer(v->spl_rdatum));
990  gidx_merge(&RLl, (GIDX*)DatumGetPointer(v->spl_ldatum));
991  gidx_merge(&RLr, (GIDX*)DatumGetPointer(v->spl_rdatum));
992 
993  sizeLR = gidx_inter_volume(LRl,LRr);
994  sizeRL = gidx_inter_volume(RLl,RLr);
995 
996  POSTGIS_DEBUGF(4, "[GIST] sizeLR / sizeRL == %.12g / %.12g", sizeLR, sizeRL);
997 
998  if (sizeLR > sizeRL)
999  firstToLeft = false;
1000 
1001  }
1002  else
1003  {
1004  float p1, p2;
1005  GISTENTRY oldUnion, addon;
1006 
1007  gistentryinit(oldUnion, (v->spl_ldatum_exists) ? v->spl_ldatum : v->spl_rdatum,
1008  NULL, NULL, InvalidOffsetNumber, FALSE);
1009 
1010  gistentryinit(addon, PointerGetDatum(*union1), NULL, NULL, InvalidOffsetNumber, FALSE);
1011  DirectFunctionCall3(gserialized_gist_penalty, PointerGetDatum(&oldUnion), PointerGetDatum(&addon), PointerGetDatum(&p1));
1012  gistentryinit(addon, PointerGetDatum(*union2), NULL, NULL, InvalidOffsetNumber, FALSE);
1013  DirectFunctionCall3(gserialized_gist_penalty, PointerGetDatum(&oldUnion), PointerGetDatum(&addon), PointerGetDatum(&p2));
1014 
1015  POSTGIS_DEBUGF(4, "[GIST] p1 / p2 == %.12g / %.12g", p1, p2);
1016 
1017  if ((v->spl_ldatum_exists && p1 > p2) || (v->spl_rdatum_exists && p1 < p2))
1018  firstToLeft = false;
1019  }
1020  }
1021 
1022  POSTGIS_DEBUGF(4, "[GIST] firstToLeft == %d", firstToLeft);
1023 
1024  if (firstToLeft)
1025  {
1026  v->spl_left = list1;
1027  v->spl_right = list2;
1028  v->spl_nleft = nlist1;
1029  v->spl_nright = nlist2;
1030  if (v->spl_ldatum_exists)
1031  gidx_merge(union1, (GIDX*)DatumGetPointer(v->spl_ldatum));
1032  v->spl_ldatum = PointerGetDatum(*union1);
1033  if (v->spl_rdatum_exists)
1034  gidx_merge(union2, (GIDX*)DatumGetPointer(v->spl_rdatum));
1035  v->spl_rdatum = PointerGetDatum(*union2);
1036  }
1037  else
1038  {
1039  v->spl_left = list2;
1040  v->spl_right = list1;
1041  v->spl_nleft = nlist2;
1042  v->spl_nright = nlist1;
1043  if (v->spl_ldatum_exists)
1044  gidx_merge(union2, (GIDX*)DatumGetPointer(v->spl_ldatum));
1045  v->spl_ldatum = PointerGetDatum(*union2);
1046  if (v->spl_rdatum_exists)
1047  gidx_merge(union1, (GIDX*)DatumGetPointer(v->spl_rdatum));
1048  v->spl_rdatum = PointerGetDatum(*union1);
1049  }
1050 
1051  v->spl_ldatum_exists = v->spl_rdatum_exists = false;
1052 }
static void gidx_merge(GIDX **b_union, GIDX *b_new)
static GIDX * gidx_copy(GIDX *b)
Datum gserialized_gist_penalty(PG_FUNCTION_ARGS)
static float gidx_inter_volume(GIDX *a, GIDX *b)
#define FALSE
Definition: dbfopen.c:169

Here is the call graph for this function:

Here is the caller graph for this function: