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.  Is a Filter node really an Agg node incognito?

    Employee
    Posted 05-07-2008 21:19

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

    Originally posted by: johnpelz

    While playing around with the groupMax and groupMin functions today in a filter node, I noticed that the filter node basically acts like an aggregate node without a "group by" clause.

    2 quick questions:

    1. Do the Agg and Filter nodes leverage the same binary / source code under the covers?

    2. When using the "groupMax" / "groupMin" functions in a filter, I assume the data is processed twice. Once to determine the Min / Max values and once to process the emit statement. Is this correct?

    Any other details of how this node functions under the covers would be greatly appreciated.


  • 2.  RE: Is a Filter node really an Agg node incognito?

    Employee
    Posted 05-08-2008 18:33

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

    Originally posted by: rboccuzzi

    1) Most of the code is shared, but not all. You are correct in that very little is different between the agg and filter nodes. Agg nodes give you the ability to "see into the future" by knowing when the current record is the last in a group (and setting the lastInGroup flag), filters don't. Otherwise, the only real difference is that when you use the group macros, filters are only one group, the whole input, and aggs have groups based on the groupBy expression.

    2) You can look at the actual expansion of the groupMax and groupMin macros by putting them in a node and pressing F3, and you will see that actually, it is very straight forward. The macros just expand to an expression. I am not sure what you mean about processing the data twice. If you say:

    x = groupMax(someField)
    emit x

    that will be equivalent to saying:

    if firstInGroup then
    x = someField
    else
    x = max(x, someField)
    emit x

    you can see, the emit doesn't change in either case.

    hope that helps.
    $Rich