Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor aggregate context to be carried with the scope. #98

Merged
merged 4 commits into from
Apr 17, 2024

Conversation

scudette
Copy link
Contributor

  1. Each aggregate function instance in the AST carries a unique
    ID. This allows the function to store its own state in the
    aggregate context without interference from other instances of
    the same function (e.g. having two count() instaces is OK)

  2. The scope may contain a reference to an AggregatorCtx
    object. This object manages access to the aggregate
    context. The main method that should be used is Modify() which
    mofidies the context under lock.

  3. When the scope spawns a child scope, the child scope does not
    have its own AggregatorCtx, instead chasing its parent to find
    one. This allows aggregate functions within the scope to see
    the wider AggregatorCtx which controls the entire query clause.

  4. When the query runs in an isolated context, the AggregatorCtx
    is recreated at the calling scope. This allows isolated scopes
    to reset the AggregatorCtx. For example, when calling a LET
    defined function, a new context is created.

  5. If a GROUP BY query, the Grouper will create a new
    AggregatorCtx for each bin. This allows aggregate functions to
    apply on each group separately.

@scudette scudette merged commit f7fa24c into master Apr 17, 2024
3 checks passed
@scudette scudette deleted the aggregates branch April 17, 2024 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant