1703 bool firstToLeft =
true;
1705 POSTGIS_DEBUG(4,
"[GIST] picksplit in constructsplit function");
1707 if (v->spl_ldatum_exists || v->spl_rdatum_exists)
1709 if (v->spl_ldatum_exists && v->spl_rdatum_exists)
1715 double sizeLR, sizeRL;
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));
1725 POSTGIS_DEBUGF(4,
"[GIST] sizeLR / sizeRL == %.12g / %.12g", sizeLR, sizeRL);
1727 if (sizeLR > sizeRL)
1728 firstToLeft =
false;
1734 GISTENTRY oldUnion, addon;
1736 gistentryinit(oldUnion, (v->spl_ldatum_exists) ? v->spl_ldatum : v->spl_rdatum,
1737 NULL, NULL, InvalidOffsetNumber,
FALSE);
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));
1744 POSTGIS_DEBUGF(4,
"[GIST] p1 / p2 == %.12g / %.12g", p1, p2);
1746 if ((v->spl_ldatum_exists && p1 > p2) || (v->spl_rdatum_exists && p1 < p2))
1747 firstToLeft =
false;
1751 POSTGIS_DEBUGF(4,
"[GIST] firstToLeft == %d", firstToLeft);
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);
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);
1780 v->spl_ldatum_exists = v->spl_rdatum_exists =
false;
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)