PostGIS  3.4.0dev-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 1474 of file gserialized_gist_nd.c.

1481 {
1482  bool firstToLeft = true;
1483 
1484  POSTGIS_DEBUG(4, "[GIST] picksplit in constructsplit function");
1485 
1486  if (v->spl_ldatum_exists || v->spl_rdatum_exists)
1487  {
1488  if (v->spl_ldatum_exists && v->spl_rdatum_exists)
1489  {
1490  GIDX *LRl = gidx_copy(*union1);
1491  GIDX *LRr = gidx_copy(*union2);
1492  GIDX *RLl = gidx_copy(*union2);
1493  GIDX *RLr = gidx_copy(*union1);
1494  double sizeLR, sizeRL;
1495 
1496  gidx_merge(&LRl, (GIDX *)PG_DETOAST_DATUM(v->spl_ldatum));
1497  gidx_merge(&LRr, (GIDX *)PG_DETOAST_DATUM(v->spl_rdatum));
1498  gidx_merge(&RLl, (GIDX *)PG_DETOAST_DATUM(v->spl_ldatum));
1499  gidx_merge(&RLr, (GIDX *)PG_DETOAST_DATUM(v->spl_rdatum));
1500 
1501  sizeLR = gidx_inter_volume(LRl, LRr);
1502  sizeRL = gidx_inter_volume(RLl, RLr);
1503 
1504  POSTGIS_DEBUGF(4, "[GIST] sizeLR / sizeRL == %.12g / %.12g", sizeLR, sizeRL);
1505 
1506  if (sizeLR > sizeRL)
1507  firstToLeft = false;
1508  }
1509  else
1510  {
1511  float p1 = 0.0, p2 = 0.0;
1512  GISTENTRY oldUnion, addon;
1513 
1514  gistentryinit(oldUnion,
1515  (v->spl_ldatum_exists) ? v->spl_ldatum : v->spl_rdatum,
1516  NULL,
1517  NULL,
1518  InvalidOffsetNumber,
1519  false);
1520 
1521  gistentryinit(addon, PointerGetDatum(*union1), NULL, NULL, InvalidOffsetNumber, false);
1522  DirectFunctionCall3(gserialized_gist_penalty,
1523  PointerGetDatum(&oldUnion),
1524  PointerGetDatum(&addon),
1525  PointerGetDatum(&p1));
1526  gistentryinit(addon, PointerGetDatum(*union2), NULL, NULL, InvalidOffsetNumber, false);
1527  DirectFunctionCall3(gserialized_gist_penalty,
1528  PointerGetDatum(&oldUnion),
1529  PointerGetDatum(&addon),
1530  PointerGetDatum(&p2));
1531 
1532  POSTGIS_DEBUGF(4, "[GIST] p1 / p2 == %.12g / %.12g", p1, p2);
1533 
1534  if ((v->spl_ldatum_exists && p1 > p2) || (v->spl_rdatum_exists && p1 < p2))
1535  firstToLeft = false;
1536  }
1537  }
1538 
1539  POSTGIS_DEBUGF(4, "[GIST] firstToLeft == %d", firstToLeft);
1540 
1541  if (firstToLeft)
1542  {
1543  v->spl_left = list1;
1544  v->spl_right = list2;
1545  v->spl_nleft = nlist1;
1546  v->spl_nright = nlist2;
1547  if (v->spl_ldatum_exists)
1548  gidx_merge(union1, (GIDX *)PG_DETOAST_DATUM(v->spl_ldatum));
1549  v->spl_ldatum = PointerGetDatum(*union1);
1550  if (v->spl_rdatum_exists)
1551  gidx_merge(union2, (GIDX *)PG_DETOAST_DATUM(v->spl_rdatum));
1552  v->spl_rdatum = PointerGetDatum(*union2);
1553  }
1554  else
1555  {
1556  v->spl_left = list2;
1557  v->spl_right = list1;
1558  v->spl_nleft = nlist2;
1559  v->spl_nright = nlist1;
1560  if (v->spl_ldatum_exists)
1561  gidx_merge(union2, (GIDX *)PG_DETOAST_DATUM(v->spl_ldatum));
1562  v->spl_ldatum = PointerGetDatum(*union2);
1563  if (v->spl_rdatum_exists)
1564  gidx_merge(union1, (GIDX *)PG_DETOAST_DATUM(v->spl_rdatum));
1565  v->spl_rdatum = PointerGetDatum(*union1);
1566  }
1567 
1568  v->spl_ldatum_exists = v->spl_rdatum_exists = false;
1569 }
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: