PostGIS  2.5.1dev-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 1698 of file gserialized_gist_nd.c.

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

Referenced by gserialized_gist_picksplit().

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