LAE

Welcome to the LAE community!  Please feel free to start a discussion in the discussion tab or join in a conversation.

Discussions

Members

Resources

Events

 View Only
  • 1.  Expanding a list of gap ranges within a number squence to a list of missing numbers

    Employee
    Posted 06-18-2012 07:17

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: aop

    Hi!

    I'm analyzing gaps in number sequences using Interval Inspection node (and previously I've used a gap check example shared here on the forum). So in my current output each row represents a gap range within the data and has last number found before the gap and first number found after the gap as columns. How could I "expand" this list of gap ranges to a complete list of missing numbers? My desired end result is to have an output with one "missing number" column and multiple rows containing all missing numbers.


  • 2.  RE: Expanding a list of gap ranges within a number squence to a list of missing numbers

    Employee
    Posted 06-18-2012 08:07

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: mmarinelli

    Hello. You'll want to use the looping operators to produce a set of rows which fill the gap you've identified with the Interval Inspection node. An example is provided below, which can be copied into a Filter node and executed. There is one important proviso on this method, however: This assumes that the source data conforms exactly to a sequence spaced at fixed intervals. If the interval in the data source were actually variable, for example if you had source records with IDs of 1, 1.24, 3, 4, 5.2, and 6, and your record set was missing 1.24 and 5.2, your attempt to identify the missing records given an interval of 1 may yield misleading results, as it would only produce 2 and 5 rather than the actual source values.

    --- script follows ---

    # define output metadata with a null record
    output 1
    {
    emit long(null) as _MISSING_ID
    where false
    }

    # set variables which define range begin/end and first missing ID
    _RANGE_BEGIN = Previous
    _RANGE_END = Current
    _ITERATOR = _RANGE_BEGIN + Interval

    # create a new record with a missing ID for each interval step within the gap
    while (_ITERATOR < _RANGE_END)
    {
    do output 1
    {
    emit _ITERATOR as _MISSING_ID
    }
    _ITERATOR = _ITERATOR + Interval
    }