PostGIS 3.0.6dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ 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 1460 of file gserialized_gist_2d.c.

1463{
1464 int leftCount,
1465 rightCount;
1466 float4 ratio,
1467 overlap;
1468 float range;
1469
1470 POSTGIS_DEBUGF(5, "consider split: dimNum = %d, rightLower = %f, "
1471 "minLeftCount = %d, leftUpper = %f, maxLeftCount = %d ",
1472 dimNum, rightLower, minLeftCount, leftUpper, maxLeftCount);
1473
1474 /*
1475 * Calculate entries distribution ratio assuming most uniform distribution
1476 * of common entries.
1477 */
1478 if (minLeftCount >= (context->entriesCount + 1) / 2)
1479 {
1480 leftCount = minLeftCount;
1481 }
1482 else
1483 {
1484 if (maxLeftCount <= context->entriesCount / 2)
1485 leftCount = maxLeftCount;
1486 else
1487 leftCount = context->entriesCount / 2;
1488 }
1489 rightCount = context->entriesCount - leftCount;
1490
1491 /*
1492 * Ratio of split - quotient between size of lesser group and total
1493 * entries count.
1494 */
1495 ratio = ((float4) Min(leftCount, rightCount)) /
1496 ((float4) context->entriesCount);
1497
1498 if (ratio > LIMIT_RATIO)
1499 {
1500 bool selectthis = false;
1501
1502 /*
1503 * The ratio is acceptable, so compare current split with previously
1504 * selected one. Between splits of one dimension we search for minimal
1505 * overlap (allowing negative values) and minimal ration (between same
1506 * overlaps. We switch dimension if find less overlap (non-negative)
1507 * or less range with same overlap.
1508 */
1509 if (dimNum == 0)
1510 range = context->boundingBox.xmax - context->boundingBox.xmin;
1511 else
1512 range = context->boundingBox.ymax - context->boundingBox.ymin;
1513
1514 overlap = (leftUpper - rightLower) / range;
1515
1516 /* If there is no previous selection, select this */
1517 if (context->first)
1518 selectthis = true;
1519 else if (context->dim == dimNum)
1520 {
1521 /*
1522 * Within the same dimension, choose the new split if it has a
1523 * smaller overlap, or same overlap but better ratio.
1524 */
1525 if (overlap < context->overlap ||
1526 (overlap == context->overlap && ratio > context->ratio))
1527 selectthis = true;
1528 }
1529 else
1530 {
1531 /*
1532 * Across dimensions, choose the new split if it has a smaller
1533 * *non-negative* overlap, or same *non-negative* overlap but
1534 * bigger range. This condition differs from the one described in
1535 * the article. On the datasets where leaf MBRs don't overlap
1536 * themselves, non-overlapping splits (i.e. splits which have zero
1537 * *non-negative* overlap) are frequently possible. In this case
1538 * splits tends to be along one dimension, because most distant
1539 * non-overlapping splits (i.e. having lowest negative overlap)
1540 * appears to be in the same dimension as in the previous split.
1541 * Therefore MBRs appear to be very prolonged along another
1542 * dimension, which leads to bad search performance. Using range
1543 * as the second split criteria makes MBRs more quadratic. Using
1544 * *non-negative* overlap instead of overlap as the first split
1545 * criteria gives to range criteria a chance to matter, because
1546 * non-overlapping splits are equivalent in this criteria.
1547 */
1548 if (non_negative(overlap) < non_negative(context->overlap) ||
1549 (range > context->range &&
1550 non_negative(overlap) <= non_negative(context->overlap)))
1551 selectthis = true;
1552 }
1553
1554 if (selectthis)
1555 {
1556 /* save information about selected split */
1557 context->first = false;
1558 context->ratio = ratio;
1559 context->range = range;
1560 context->overlap = overlap;
1561 context->rightLower = rightLower;
1562 context->leftUpper = leftUpper;
1563 context->dim = dimNum;
1564 POSTGIS_DEBUG(5, "split selected");
1565 }
1566 }
1567}
#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: