PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ g_box_consider_split()

static void g_box_consider_split ( ConsiderSplitContext context,
int  dimNum,
float  rightLower,
int  minLeftCount,
float  leftUpper,
int  maxLeftCount 
)
inlinestatic

Definition at line 1588 of file gserialized_gist_2d.c.

1591 {
1592  int leftCount,
1593  rightCount;
1594  float4 ratio,
1595  overlap;
1596  float range;
1597 
1598  POSTGIS_DEBUGF(5, "consider split: dimNum = %d, rightLower = %f, "
1599  "minLeftCount = %d, leftUpper = %f, maxLeftCount = %d ",
1600  dimNum, rightLower, minLeftCount, leftUpper, maxLeftCount);
1601 
1602  /*
1603  * Calculate entries distribution ratio assuming most uniform distribution
1604  * of common entries.
1605  */
1606  if (minLeftCount >= (context->entriesCount + 1) / 2)
1607  {
1608  leftCount = minLeftCount;
1609  }
1610  else
1611  {
1612  if (maxLeftCount <= context->entriesCount / 2)
1613  leftCount = maxLeftCount;
1614  else
1615  leftCount = context->entriesCount / 2;
1616  }
1617  rightCount = context->entriesCount - leftCount;
1618 
1619  /*
1620  * Ratio of split - quotient between size of lesser group and total
1621  * entries count.
1622  */
1623  ratio = ((float4) Min(leftCount, rightCount)) /
1624  ((float4) context->entriesCount);
1625 
1626  if (ratio > LIMIT_RATIO)
1627  {
1628  bool selectthis = false;
1629 
1630  /*
1631  * The ratio is acceptable, so compare current split with previously
1632  * selected one. Between splits of one dimension we search for minimal
1633  * overlap (allowing negative values) and minimal ration (between same
1634  * overlaps. We switch dimension if find less overlap (non-negative)
1635  * or less range with same overlap.
1636  */
1637  if (dimNum == 0)
1638  range = context->boundingBox.xmax - context->boundingBox.xmin;
1639  else
1640  range = context->boundingBox.ymax - context->boundingBox.ymin;
1641 
1642  overlap = (leftUpper - rightLower) / range;
1643 
1644  /* If there is no previous selection, select this */
1645  if (context->first)
1646  selectthis = true;
1647  else if (context->dim == dimNum)
1648  {
1649  /*
1650  * Within the same dimension, choose the new split if it has a
1651  * smaller overlap, or same overlap but better ratio.
1652  */
1653  if (overlap < context->overlap ||
1654  (overlap == context->overlap && ratio > context->ratio))
1655  selectthis = true;
1656  }
1657  else
1658  {
1659  /*
1660  * Across dimensions, choose the new split if it has a smaller
1661  * *non-negative* overlap, or same *non-negative* overlap but
1662  * bigger range. This condition differs from the one described in
1663  * the article. On the datasets where leaf MBRs don't overlap
1664  * themselves, non-overlapping splits (i.e. splits which have zero
1665  * *non-negative* overlap) are frequently possible. In this case
1666  * splits tends to be along one dimension, because most distant
1667  * non-overlapping splits (i.e. having lowest negative overlap)
1668  * appears to be in the same dimension as in the previous split.
1669  * Therefore MBRs appear to be very prolonged along another
1670  * dimension, which leads to bad search performance. Using range
1671  * as the second split criteria makes MBRs more quadratic. Using
1672  * *non-negative* overlap instead of overlap as the first split
1673  * criteria gives to range criteria a chance to matter, because
1674  * non-overlapping splits are equivalent in this criteria.
1675  */
1676  if (non_negative(overlap) < non_negative(context->overlap) ||
1677  (range > context->range &&
1678  non_negative(overlap) <= non_negative(context->overlap)))
1679  selectthis = true;
1680  }
1681 
1682  if (selectthis)
1683  {
1684  /* save information about selected split */
1685  context->first = false;
1686  context->ratio = ratio;
1687  context->range = range;
1688  context->overlap = overlap;
1689  context->rightLower = rightLower;
1690  context->leftUpper = leftUpper;
1691  context->dim = dimNum;
1692  POSTGIS_DEBUG(5, "split selected");
1693  }
1694  }
1695 }
#define LIMIT_RATIO
static float non_negative(float val)

References ConsiderSplitContext::boundingBox, ConsiderSplitContext::dim, ConsiderSplitContext::entriesCount, ConsiderSplitContext::first, ConsiderSplitContext::leftUpper, LIMIT_RATIO, non_negative(), ConsiderSplitContext::overlap, ConsiderSplitContext::range, ConsiderSplitContext::ratio, and ConsiderSplitContext::rightLower.

Referenced by gserialized_gist_picksplit_2d().

Here is the call graph for this function:
Here is the caller graph for this function: