PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ gserialized_gist_picksplit_constructsplit()

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 1702 of file gserialized_gist_nd.c.

1703 {
1704  bool firstToLeft = true;
1705 
1706  POSTGIS_DEBUG(4, "[GIST] picksplit in constructsplit function");
1707 
1708  if (v->spl_ldatum_exists || v->spl_rdatum_exists)
1709  {
1710  if (v->spl_ldatum_exists && v->spl_rdatum_exists)
1711  {
1712  GIDX *LRl = gidx_copy(*union1);
1713  GIDX *LRr = gidx_copy(*union2);
1714  GIDX *RLl = gidx_copy(*union2);
1715  GIDX *RLr = gidx_copy(*union1);
1716  double sizeLR, sizeRL;
1717 
1718  gidx_merge(&LRl, (GIDX*)DatumGetPointer(v->spl_ldatum));
1719  gidx_merge(&LRr, (GIDX*)DatumGetPointer(v->spl_rdatum));
1720  gidx_merge(&RLl, (GIDX*)DatumGetPointer(v->spl_ldatum));
1721  gidx_merge(&RLr, (GIDX*)DatumGetPointer(v->spl_rdatum));
1722 
1723  sizeLR = gidx_inter_volume(LRl,LRr);
1724  sizeRL = gidx_inter_volume(RLl,RLr);
1725 
1726  POSTGIS_DEBUGF(4, "[GIST] sizeLR / sizeRL == %.12g / %.12g", sizeLR, sizeRL);
1727 
1728  if (sizeLR > sizeRL)
1729  firstToLeft = false;
1730 
1731  }
1732  else
1733  {
1734  float p1, p2;
1735  GISTENTRY oldUnion, addon;
1736 
1737  gistentryinit(oldUnion, (v->spl_ldatum_exists) ? v->spl_ldatum : v->spl_rdatum,
1738  NULL, NULL, InvalidOffsetNumber, false);
1739 
1740  gistentryinit(addon, PointerGetDatum(*union1), NULL, NULL, InvalidOffsetNumber, false);
1741  DirectFunctionCall3(gserialized_gist_penalty, PointerGetDatum(&oldUnion), PointerGetDatum(&addon), PointerGetDatum(&p1));
1742  gistentryinit(addon, PointerGetDatum(*union2), NULL, NULL, InvalidOffsetNumber, false);
1743  DirectFunctionCall3(gserialized_gist_penalty, PointerGetDatum(&oldUnion), PointerGetDatum(&addon), PointerGetDatum(&p2));
1744 
1745  POSTGIS_DEBUGF(4, "[GIST] p1 / p2 == %.12g / %.12g", p1, p2);
1746 
1747  if ((v->spl_ldatum_exists && p1 > p2) || (v->spl_rdatum_exists && p1 < p2))
1748  firstToLeft = false;
1749  }
1750  }
1751 
1752  POSTGIS_DEBUGF(4, "[GIST] firstToLeft == %d", firstToLeft);
1753 
1754  if (firstToLeft)
1755  {
1756  v->spl_left = list1;
1757  v->spl_right = list2;
1758  v->spl_nleft = nlist1;
1759  v->spl_nright = nlist2;
1760  if (v->spl_ldatum_exists)
1761  gidx_merge(union1, (GIDX*)DatumGetPointer(v->spl_ldatum));
1762  v->spl_ldatum = PointerGetDatum(*union1);
1763  if (v->spl_rdatum_exists)
1764  gidx_merge(union2, (GIDX*)DatumGetPointer(v->spl_rdatum));
1765  v->spl_rdatum = PointerGetDatum(*union2);
1766  }
1767  else
1768  {
1769  v->spl_left = list2;
1770  v->spl_right = list1;
1771  v->spl_nleft = nlist2;
1772  v->spl_nright = nlist1;
1773  if (v->spl_ldatum_exists)
1774  gidx_merge(union2, (GIDX*)DatumGetPointer(v->spl_ldatum));
1775  v->spl_ldatum = PointerGetDatum(*union2);
1776  if (v->spl_rdatum_exists)
1777  gidx_merge(union1, (GIDX*)DatumGetPointer(v->spl_rdatum));
1778  v->spl_rdatum = PointerGetDatum(*union1);
1779  }
1780 
1781  v->spl_ldatum_exists = v->spl_rdatum_exists = false;
1782 }
static float gidx_inter_volume(GIDX *a, GIDX *b)
GIDX * gidx_copy(GIDX *b)
Datum gserialized_gist_penalty(PG_FUNCTION_ARGS)
void gidx_merge(GIDX **b_union, GIDX *b_new)

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

Referenced by gserialized_gist_picksplit().

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