processing/src/main/java/org/apache/druid/segment/MergingRowIterator.java
/**
   * Sinks (pushes down) the iterator at the given index i, because it's value just changed due to {@link
   * RowIterator#moveToNext()} call.
   *
   * This method implementation is originally based on {@link ObjectHeaps#downHeap} implementation, plus it updates
   * {@link #equalToChild} states along the way.
   */
Sinks (pushes down) the iterator at the given index i, because it's value just changed due to {@link
RowIterator#moveToNext()} call.

This method implementation is originally based on  ObjectHeaps#downHeap implementation, plus it updates
#equalToChild states along the way.
Sinks ( pushes down ) the iterator at the given index i because it ' s value just changed due to { @link RowIterator#moveToNext () } call . This method implementation is originally based on ObjectHeaps#downHeap implementation plus it updates #equalToChild states along the way .
private int sinkHeap(int i)
  {
    final RowIterator iteratorToSink = pQueue[i];
    while (true) {
      int left = (i << 1) + 1;
      if (left >= pQueueSize) {
        break;
      }
      int child = left;
      RowIterator childIterator = pQueue[left];
      final int right = left + 1;
      int childrenDiff = -1; 
      if (right < pQueueSize) {
        RowIterator rightChildIterator = pQueue[right];
        childrenDiff = rightChildIterator.getPointer().compareTo(childIterator.getPointer());
        if (childrenDiff < 0) {
          child = right;
          childIterator = rightChildIterator;
        }
      }
      int parentDiff = iteratorToSink.getPointer().compareTo(childIterator.getPointer());
      if (parentDiff == 0) {
        equalToChild[i] = true;
        pQueue[i] = iteratorToSink;
        return i;
      }
      if (parentDiff < 0) {
        equalToChild[i] = false;
        pQueue[i] = iteratorToSink;
        return i;
      }
      equalToChild[i] = childrenDiff == 0 || equalToChild[child];
      pQueue[i] = childIterator;
      i = child;
    }
    equalToChild[i] = false; 
    pQueue[i] = iteratorToSink;
    return i;
  }
private int sinkHeap ( int i ) { final RowIterator iteratorToSink = pQueue [ i ] ; while ( true ) { int left = ( i << 1 ) + 1 ; if ( left >= pQueueSize ) { break ; } int child = left ; RowIterator childIterator = pQueue [ left ] ; final int right = left + 1 ; int childrenDiff = - 1 ; if ( right < pQueueSize ) { RowIterator rightChildIterator = pQueue [ right ] ; childrenDiff = rightChildIterator . getPointer ( ) . compareTo ( childIterator . getPointer ( ) ) ; if ( childrenDiff < 0 ) { child = right ; childIterator = rightChildIterator ; } } int parentDiff = iteratorToSink . getPointer ( ) . compareTo ( childIterator . getPointer ( ) ) ; if ( parentDiff == 0 ) { equalToChild [ i ] = true ; pQueue [ i ] = iteratorToSink ; return i ; } if ( parentDiff < 0 ) { equalToChild [ i ] = false ; pQueue [ i ] = iteratorToSink ; return i ; } equalToChild [ i ] = childrenDiff == 0 || equalToChild [ child ] ; pQueue [ i ] = childIterator ; i = child ; } equalToChild [ i ] = false ; pQueue [ i ] = iteratorToSink ; return i ; }
Sinks (pushes down) the iterator at the given index i, because it's value just changed due to {@link
 RowIterator#moveToNext()} call.
Sinks ( pushes down ) the iterator at the given index i because it ' s value just changed due to { @link RowIterator#moveToNext () } call .
// Setting childrenDiff to non-zero initially, so that if there is just one child (right == pQueueSize), // the expression `childrenDiff == 0` below is false. // any non-zero number // Since we exited from the above loop, there are no more children