PostGIS  2.2.7dev-r@@SVN_REVISION@@
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 1399 of file gserialized_gist_nd.c.

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

Referenced by gserialized_gist_picksplit().

1400 {
1401  bool firstToLeft = true;
1402 
1403  POSTGIS_DEBUG(4, "[GIST] picksplit in constructsplit function");
1404 
1405  if (v->spl_ldatum_exists || v->spl_rdatum_exists)
1406  {
1407  if (v->spl_ldatum_exists && v->spl_rdatum_exists)
1408  {
1409  GIDX *LRl = gidx_copy(*union1);
1410  GIDX *LRr = gidx_copy(*union2);
1411  GIDX *RLl = gidx_copy(*union2);
1412  GIDX *RLr = gidx_copy(*union1);
1413  double sizeLR, sizeRL;
1414 
1415  gidx_merge(&LRl, (GIDX*)DatumGetPointer(v->spl_ldatum));
1416  gidx_merge(&LRr, (GIDX*)DatumGetPointer(v->spl_rdatum));
1417  gidx_merge(&RLl, (GIDX*)DatumGetPointer(v->spl_ldatum));
1418  gidx_merge(&RLr, (GIDX*)DatumGetPointer(v->spl_rdatum));
1419 
1420  sizeLR = gidx_inter_volume(LRl,LRr);
1421  sizeRL = gidx_inter_volume(RLl,RLr);
1422 
1423  POSTGIS_DEBUGF(4, "[GIST] sizeLR / sizeRL == %.12g / %.12g", sizeLR, sizeRL);
1424 
1425  if (sizeLR > sizeRL)
1426  firstToLeft = false;
1427 
1428  }
1429  else
1430  {
1431  float p1, p2;
1432  GISTENTRY oldUnion, addon;
1433 
1434  gistentryinit(oldUnion, (v->spl_ldatum_exists) ? v->spl_ldatum : v->spl_rdatum,
1435  NULL, NULL, InvalidOffsetNumber, FALSE);
1436 
1437  gistentryinit(addon, PointerGetDatum(*union1), NULL, NULL, InvalidOffsetNumber, FALSE);
1438  DirectFunctionCall3(gserialized_gist_penalty, PointerGetDatum(&oldUnion), PointerGetDatum(&addon), PointerGetDatum(&p1));
1439  gistentryinit(addon, PointerGetDatum(*union2), NULL, NULL, InvalidOffsetNumber, FALSE);
1440  DirectFunctionCall3(gserialized_gist_penalty, PointerGetDatum(&oldUnion), PointerGetDatum(&addon), PointerGetDatum(&p2));
1441 
1442  POSTGIS_DEBUGF(4, "[GIST] p1 / p2 == %.12g / %.12g", p1, p2);
1443 
1444  if ((v->spl_ldatum_exists && p1 > p2) || (v->spl_rdatum_exists && p1 < p2))
1445  firstToLeft = false;
1446  }
1447  }
1448 
1449  POSTGIS_DEBUGF(4, "[GIST] firstToLeft == %d", firstToLeft);
1450 
1451  if (firstToLeft)
1452  {
1453  v->spl_left = list1;
1454  v->spl_right = list2;
1455  v->spl_nleft = nlist1;
1456  v->spl_nright = nlist2;
1457  if (v->spl_ldatum_exists)
1458  gidx_merge(union1, (GIDX*)DatumGetPointer(v->spl_ldatum));
1459  v->spl_ldatum = PointerGetDatum(*union1);
1460  if (v->spl_rdatum_exists)
1461  gidx_merge(union2, (GIDX*)DatumGetPointer(v->spl_rdatum));
1462  v->spl_rdatum = PointerGetDatum(*union2);
1463  }
1464  else
1465  {
1466  v->spl_left = list2;
1467  v->spl_right = list1;
1468  v->spl_nleft = nlist2;
1469  v->spl_nright = nlist1;
1470  if (v->spl_ldatum_exists)
1471  gidx_merge(union2, (GIDX*)DatumGetPointer(v->spl_ldatum));
1472  v->spl_ldatum = PointerGetDatum(*union2);
1473  if (v->spl_rdatum_exists)
1474  gidx_merge(union1, (GIDX*)DatumGetPointer(v->spl_rdatum));
1475  v->spl_rdatum = PointerGetDatum(*union1);
1476  }
1477 
1478  v->spl_ldatum_exists = v->spl_rdatum_exists = false;
1479 }
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)
#define FALSE
Definition: dbfopen.c:168

Here is the call graph for this function:

Here is the caller graph for this function: