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

Add spill support to TopNRowNumber operator #7139

Closed
wants to merge 1 commit into from

Conversation

mbasmanova
Copy link
Contributor

@mbasmanova mbasmanova commented Oct 19, 2023

TopNRowNumber operator maintains a hash table of unique partition keys and a
RowContainer of input rows with up to N rows per partition.

When asked to spill, TopNRowNumber operator sorts accumulated input rows by
partition and sorting keys, spills all of them, clears both hash table and
RowContainer, and continues to accumulate future input into freed up hash table
and container.

After receiving (and spilling) all input, TopNRowNumber operator sort-merged
spilled data and generates output. Since at this point all data is sorted by
partition and sorting keys, the operator produces data in streaming fashion.

Spilling is enabled by default. It can be disabled by setting
topn_row_number_spill_enabled configuration property to false.

Spilling after noMoreInput() is not supported yet.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 19, 2023
@netlify
Copy link

netlify bot commented Oct 19, 2023

Deploy Preview for meta-velox canceled.

Name Link
🔨 Latest commit 430173a
🔍 Latest deploy log https://app.netlify.com/sites/meta-velox/deploys/6533a91b49a9ac0008500cc2

@facebook-github-bot
Copy link
Contributor

@mbasmanova has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@mbasmanova mbasmanova force-pushed the top-n-spill branch 3 times, most recently from f544393 to a189989 Compare October 19, 2023 15:13
@facebook-github-bot
Copy link
Contributor

@mbasmanova has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@mbasmanova mbasmanova force-pushed the top-n-spill branch 2 times, most recently from d4e8677 to 76a25e9 Compare October 20, 2023 17:02
@facebook-github-bot
Copy link
Contributor

@mbasmanova has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Copy link
Contributor

@xiaoxmeng xiaoxmeng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mbasmanova looks great. Thanks!

}

outputBatchSize_ = outputBatchRows(rowSize);
outputRows_.resize(outputBatchSize_);
if (!estimatedOutputRowSize_.has_value()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We take the max as the estimation to be conservative on output batch processing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how I was thinking about it. Being conservative. Let me know if you think a different strategy would be better.

}

if (nonReclaimableSection_) {
++stats.numNonReclaimableAttempts;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a warning log here as the other operator does? Thanks!

@facebook-github-bot
Copy link
Contributor

@mbasmanova has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@mbasmanova merged this pull request in 55d5636.

@conbench-facebook
Copy link

Conbench analyzed the 1 benchmark run on commit 55d56366.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants