1704 bool firstToLeft =
true;
1706 POSTGIS_DEBUG(4,
"[GIST] picksplit in constructsplit function");
1708 if (v->spl_ldatum_exists || v->spl_rdatum_exists)
1710 if (v->spl_ldatum_exists && v->spl_rdatum_exists)
1716 double sizeLR, sizeRL;
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));
1726 POSTGIS_DEBUGF(4,
"[GIST] sizeLR / sizeRL == %.12g / %.12g", sizeLR, sizeRL);
1728 if (sizeLR > sizeRL)
1729 firstToLeft =
false;
1735 GISTENTRY oldUnion, addon;
1737 gistentryinit(oldUnion, (v->spl_ldatum_exists) ? v->spl_ldatum : v->spl_rdatum,
1738 NULL, NULL, InvalidOffsetNumber,
false);
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));
1745 POSTGIS_DEBUGF(4,
"[GIST] p1 / p2 == %.12g / %.12g", p1, p2);
1747 if ((v->spl_ldatum_exists && p1 > p2) || (v->spl_rdatum_exists && p1 < p2))
1748 firstToLeft =
false;
1752 POSTGIS_DEBUGF(4,
"[GIST] firstToLeft == %d", firstToLeft);
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);
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);
1781 v->spl_ldatum_exists = v->spl_rdatum_exists =
false;
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)