PostGIS  2.3.7dev-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 1588 of file gserialized_gist_nd.c.

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

Referenced by gserialized_gist_picksplit().

1589 {
1590  bool firstToLeft = true;
1591 
1592  POSTGIS_DEBUG(4, "[GIST] picksplit in constructsplit function");
1593 
1594  if (v->spl_ldatum_exists || v->spl_rdatum_exists)
1595  {
1596  if (v->spl_ldatum_exists && v->spl_rdatum_exists)
1597  {
1598  GIDX *LRl = gidx_copy(*union1);
1599  GIDX *LRr = gidx_copy(*union2);
1600  GIDX *RLl = gidx_copy(*union2);
1601  GIDX *RLr = gidx_copy(*union1);
1602  double sizeLR, sizeRL;
1603 
1604  gidx_merge(&LRl, (GIDX*)DatumGetPointer(v->spl_ldatum));
1605  gidx_merge(&LRr, (GIDX*)DatumGetPointer(v->spl_rdatum));
1606  gidx_merge(&RLl, (GIDX*)DatumGetPointer(v->spl_ldatum));
1607  gidx_merge(&RLr, (GIDX*)DatumGetPointer(v->spl_rdatum));
1608 
1609  sizeLR = gidx_inter_volume(LRl,LRr);
1610  sizeRL = gidx_inter_volume(RLl,RLr);
1611 
1612  POSTGIS_DEBUGF(4, "[GIST] sizeLR / sizeRL == %.12g / %.12g", sizeLR, sizeRL);
1613 
1614  if (sizeLR > sizeRL)
1615  firstToLeft = false;
1616 
1617  }
1618  else
1619  {
1620  float p1, p2;
1621  GISTENTRY oldUnion, addon;
1622 
1623  gistentryinit(oldUnion, (v->spl_ldatum_exists) ? v->spl_ldatum : v->spl_rdatum,
1624  NULL, NULL, InvalidOffsetNumber, FALSE);
1625 
1626  gistentryinit(addon, PointerGetDatum(*union1), NULL, NULL, InvalidOffsetNumber, FALSE);
1627  DirectFunctionCall3(gserialized_gist_penalty, PointerGetDatum(&oldUnion), PointerGetDatum(&addon), PointerGetDatum(&p1));
1628  gistentryinit(addon, PointerGetDatum(*union2), NULL, NULL, InvalidOffsetNumber, FALSE);
1629  DirectFunctionCall3(gserialized_gist_penalty, PointerGetDatum(&oldUnion), PointerGetDatum(&addon), PointerGetDatum(&p2));
1630 
1631  POSTGIS_DEBUGF(4, "[GIST] p1 / p2 == %.12g / %.12g", p1, p2);
1632 
1633  if ((v->spl_ldatum_exists && p1 > p2) || (v->spl_rdatum_exists && p1 < p2))
1634  firstToLeft = false;
1635  }
1636  }
1637 
1638  POSTGIS_DEBUGF(4, "[GIST] firstToLeft == %d", firstToLeft);
1639 
1640  if (firstToLeft)
1641  {
1642  v->spl_left = list1;
1643  v->spl_right = list2;
1644  v->spl_nleft = nlist1;
1645  v->spl_nright = nlist2;
1646  if (v->spl_ldatum_exists)
1647  gidx_merge(union1, (GIDX*)DatumGetPointer(v->spl_ldatum));
1648  v->spl_ldatum = PointerGetDatum(*union1);
1649  if (v->spl_rdatum_exists)
1650  gidx_merge(union2, (GIDX*)DatumGetPointer(v->spl_rdatum));
1651  v->spl_rdatum = PointerGetDatum(*union2);
1652  }
1653  else
1654  {
1655  v->spl_left = list2;
1656  v->spl_right = list1;
1657  v->spl_nleft = nlist2;
1658  v->spl_nright = nlist1;
1659  if (v->spl_ldatum_exists)
1660  gidx_merge(union2, (GIDX*)DatumGetPointer(v->spl_ldatum));
1661  v->spl_ldatum = PointerGetDatum(*union2);
1662  if (v->spl_rdatum_exists)
1663  gidx_merge(union1, (GIDX*)DatumGetPointer(v->spl_rdatum));
1664  v->spl_rdatum = PointerGetDatum(*union1);
1665  }
1666 
1667  v->spl_ldatum_exists = v->spl_rdatum_exists = false;
1668 }
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:168

Here is the call graph for this function:

Here is the caller graph for this function: