PostGIS  3.0.6dev-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 1471 of file gserialized_gist_nd.c.

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