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 APPROX_HISTOGRAM_K Operation #735

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

jbrooks-stripe
Copy link
Collaborator

@jbrooks-stripe jbrooks-stripe commented Mar 29, 2024

Summary

Adds an APPROX_HISTOGRAM_K operation based on the FrequentItems Sketch:
https://datasketches.apache.org/docs/Frequency/FrequentItemsOverview.html

This is mostly a wrapper on top of the frequent items sketch, but have made the two following modifications to make it somewhat more user friendly:

  • The sketch requires a k which is a power of two. Instead of making this a user requirement, we will take the next closest power of two and truncate down to k in the results.
  • The underlying map used by the sketch has a load factor of 0.75, which causes the approximation to kick in before there are k elements. We changed this to keep an exact histogram/map and then switch over to the sketch once the entries exceed k.

Why / Goal

The current histogram operation uses unbounded memory and isn't stable for production use cases.

Test Plan

We've end to end tested everything through backfills/CLI on the batch side on our end.

  • Added Unit Tests
  • Covered by existing CI
  • Integration tested

Checklist

  • Documentation update

Reviewers

@jbrooks-stripe jbrooks-stripe marked this pull request as draft March 29, 2024 15:43
Copy link
Contributor

@nikhilsimha nikhilsimha left a comment

Choose a reason for hiding this comment

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

Few comments. But the approach looks sound overall.

Copy link
Contributor

@nikhilsimha nikhilsimha left a comment

Choose a reason for hiding this comment

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

Let's also add a test to spark/test/FetcherTest.scala

Looks good otherwise. Mostly non-blocking comments.

@jbrooks-stripe
Copy link
Collaborator Author

Let's also add a test to spark/test/FetcherTest.scala

Looks good otherwise. Mostly non-blocking comments.

Appreciate you taking a look. Will address your comments and some from our internal repo shortly.

@jbrooks-stripe jbrooks-stripe force-pushed the jbrooks-approx-histogram branch 12 times, most recently from 536b7c0 to ae59b34 Compare May 24, 2024 16:22
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.

None yet

3 participants