PostGIS  2.5.2dev-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 1701 of file gserialized_gist_nd.c.

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

Referenced by gserialized_gist_picksplit().

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