aeron-driver/src/main/java/io/aeron/driver/LossDetector.java
public long scan(
        final UnsafeBuffer termBuffer,
        final long rebuildPosition,
        final long hwmPosition,
        final long nowNs,
        final int termLengthMask,
        final int positionBitsToShift,
        final int initialTermId)
    {
        boolean lossFound = false;
        int rebuildOffset = (int)rebuildPosition & termLengthMask;

        if (rebuildPosition < hwmPosition)
        {
            final int rebuildTermCount = (int)(rebuildPosition >>> positionBitsToShift);
            final int hwmTermCount = (int)(hwmPosition >>> positionBitsToShift);

            final int rebuildTermId = initialTermId + rebuildTermCount;
            final int hwmTermOffset = (int)hwmPosition & termLengthMask;
            final int limitOffset = rebuildTermCount == hwmTermCount ? hwmTermOffset : termLengthMask + 1;

            rebuildOffset = scanForGap(termBuffer, rebuildTermId, rebuildOffset, limitOffset, this);
            if (rebuildOffset < limitOffset)
            {
                if (scannedTermOffset != activeTermOffset || scannedTermId != activeTermId)
                {
                    activateGap(nowNs);
                    lossFound = true;
                }

                checkTimerExpiry(nowNs);
            }
        }

        return pack(rebuildOffset, lossFound);
    }
public long scan(
        final UnsafeBuffer termBuffer,
        final long rebuildPosition,
        final long hwmPosition,
        final long nowNs,
        final int termLengthMask,
        final int positionBitsToShift,
        final int initialTermId)
    {
        boolean lossFound = false;
        int rebuildOffset = (int)rebuildPosition & termLengthMask;

        if (rebuildPosition < hwmPosition)
        {
            final int rebuildTermCount = (int)(rebuildPosition >>> positionBitsToShift);
            final int hwmTermCount = (int)(hwmPosition >>> positionBitsToShift);

            final int rebuildTermId = initialTermId + rebuildTermCount;
            final int hwmTermOffset = (int)hwmPosition & termLengthMask;
            final int limitOffset = rebuildTermCount == hwmTermCount ? hwmTermOffset : termLengthMask + 1;

            rebuildOffset = scanForGap(termBuffer, rebuildTermId, rebuildOffset, limitOffset, this);
            if (rebuildOffset < limitOffset)
            {
                if (scannedTermOffset != activeTermOffset || scannedTermId != activeTermId)
                {
                    activateGap(nowNs);
                    lossFound = true;
                }

                checkTimerExpiry(nowNs);
            }
        }

        return pack(rebuildOffset, lossFound);
    }
public long scan ( final UnsafeBuffer termBuffer , final long rebuildPosition , final long hwmPosition , final long nowNs , final int termLengthMask , final int positionBitsToShift , final int initialTermId ) { boolean lossFound = false ; int rebuildOffset = ( int ) rebuildPosition & termLengthMask ; if ( rebuildPosition < hwmPosition ) { final int rebuildTermCount = ( int ) ( rebuildPosition >>> positionBitsToShift ) ; final int hwmTermCount = ( int ) ( hwmPosition >>> positionBitsToShift ) ; final int rebuildTermId = initialTermId + rebuildTermCount ; final int hwmTermOffset = ( int ) hwmPosition & termLengthMask ; final int limitOffset = rebuildTermCount == hwmTermCount ? hwmTermOffset : termLengthMask + 1 ; rebuildOffset = scanForGap ( termBuffer , rebuildTermId , rebuildOffset , limitOffset , this ) ; if ( rebuildOffset < limitOffset ) { if ( scannedTermOffset != activeTermOffset || scannedTermId != activeTermId ) { activateGap ( nowNs ) ; lossFound = true ; } checkTimerExpiry ( nowNs ) ; } } return pack ( rebuildOffset , lossFound ) ; }
Scan for gaps and handle received data.
<p>
The handler keeps track from scan to scan what is a gap and what must have been repaired.

@param termBuffer          to scan
@param rebuildPosition     to start scanning from
@param hwmPosition         to scan up to
@param nowNs               time in nanoseconds
@param termLengthMask      used for offset calculation
@param positionBitsToShift used for position calculation
@param initialTermId       used by the scanner
@return packed outcome of the scan.
Scan for gaps and handle received data . <p > The handler keeps track from scan to scan what is a gap and what must have been repaired .