-
Notifications
You must be signed in to change notification settings - Fork 3
feat: DH-19379 Added CountWhere operations #406
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
Open
stanbrub
wants to merge
13
commits into
deephaven:main
Choose a base branch
from
stanbrub:count-where-benchmarks
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
921070f
Added CountWhere operations
stanbrub dd4c5d8
Remove unnessary num2
stanbrub fcb8cb2
fixed some test method names
stanbrub 4d8dcf0
Merge branch 'deephaven:main' into count-where-benchmarks
stanbrub cfd851a
Merge branch 'deephaven:main' into count-where-benchmarks
stanbrub 49c8959
Merge branch 'deephaven:main' into count-where-benchmarks
stanbrub 7104a1d
Merge branch 'main' into count-where-benchmarks
stanbrub 2961e99
Merge branch 'deephaven:main' into count-where-benchmarks
stanbrub bb1cd8a
Merge branch 'deephaven:main' into count-where-benchmarks
stanbrub 2534d0d
Merge branch 'deephaven:main' into count-where-benchmarks
stanbrub 42c41fd
Merge branch 'deephaven:main' into count-where-benchmarks
stanbrub f250bdd
Add more filters to CumCountWhere, remove 0 group and some Incs from …
stanbrub 1659212
Merge branch 'deephaven:main' into count-where-benchmarks
stanbrub File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/it/java/io/deephaven/benchmark/tests/standard/aggby/CountWhereTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| /* Copyright (c) 2025-2026 Deephaven Data Labs and Patent Pending */ | ||
| package io.deephaven.benchmark.tests.standard.aggby; | ||
|
|
||
| import org.junit.jupiter.api.*; | ||
| import io.deephaven.benchmark.tests.standard.StandardTestRunner; | ||
|
|
||
| /** | ||
| * Standard tests for the countWhere table operation. Returns the number of rows for each group. | ||
| */ | ||
| public class CountWhereTest { | ||
| final StandardTestRunner runner = new StandardTestRunner(this); | ||
|
|
||
| @BeforeEach | ||
| void setup() { | ||
| runner.setRowFactor(6); | ||
| runner.tables("source"); | ||
|
|
||
| var setupStr = "from deephaven import agg"; | ||
| runner.addSetupQuery(setupStr); | ||
| } | ||
|
|
||
| @Test | ||
| void countWhere1Group() { | ||
| runner.setScaleFactors(9, 0); | ||
| var q = "source.agg_by([agg.count_where(col='count', filters=['num1 > 3'])], by=['key1'])"; | ||
| runner.test("CountWhere-AggBy- Range 1 Group 100 Unique Vals", 100, q, "key1", "num1"); | ||
| } | ||
|
|
||
| @Test | ||
| void countWhere2Group() { | ||
| runner.setScaleFactors(3, 2); | ||
| var q = "source.agg_by([agg.count_where(col='count', filters=['num1 % 3 = 0'])], by=['key1', 'key2'])"; | ||
| runner.test("CountWhere-AggBy- Equals 2 Groups 10K Unique Combos", 10100, q, "key1", "key2", "num1"); | ||
| } | ||
|
|
||
| } | ||
66 changes: 66 additions & 0 deletions
66
src/it/java/io/deephaven/benchmark/tests/standard/updateby/CumCountWhereTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| /* Copyright (c) 2025-2026 Deephaven Data Labs and Patent Pending */ | ||
| package io.deephaven.benchmark.tests.standard.updateby; | ||
|
|
||
| import org.junit.jupiter.api.*; | ||
| import io.deephaven.benchmark.tests.standard.StandardTestRunner; | ||
|
|
||
| /** | ||
| * Standard tests for the updateBy table operation. Calculates a cumulative countWhere for specified columns and places | ||
| * the result into a new column for each row. | ||
| */ | ||
| public class CumCountWhereTest { | ||
| final StandardTestRunner runner = new StandardTestRunner(this); | ||
|
|
||
| void setup(int rowFactor, int staticFactor, int incFactor) { | ||
| runner.setRowFactor(rowFactor); | ||
| runner.setScaleFactors(staticFactor, incFactor); | ||
| runner.tables("timed"); | ||
| runner.addSetupQuery(""" | ||
| from deephaven.updateby import cum_count_where | ||
| from deephaven.filters import or_ | ||
| """); | ||
| } | ||
|
|
||
| @Test | ||
| void cumCountWhereRange0Group1Col() { | ||
| setup(5, 10, 0); | ||
| var q = "timed.update_by(ops=cum_count_where(col='X', filters=['num1 > 3']))"; | ||
| runner.test("CumCountWhere- Range No Groups 1 Col", q, "num1"); | ||
| } | ||
|
|
||
| @Test | ||
| void cumCountWhereEquals0Group1Col() { | ||
| setup(5, 8, 0); | ||
| var q = "timed.update_by(ops=cum_count_where(col='X', filters=['num1 % 3 = 0']))"; | ||
| runner.test("CumCountWhere- Equals No Groups 1 Col", q, "num1"); | ||
| } | ||
|
|
||
| @Test | ||
| void cumCountWhereAnd0Group1Col() { | ||
| setup(5, 10, 0); | ||
| var q = "timed.update_by(ops=cum_count_where(col='X', filters=['num1 > 3','num1 % 3 = 0']))"; | ||
| runner.test("CumCountWhere- And No Groups 1 Col", q, "num1"); | ||
| } | ||
|
|
||
| @Test | ||
| void cumCountWhereOr0Group1Col() { | ||
| setup(5, 3, 0); | ||
| var q = "timed.update_by(ops=cum_count_where(col='X', filters=or_(['num1 > 3','num1 % 3 = 0'])))"; | ||
| runner.test("CumCountWhere- Or No Groups 1 Col", q, "num1"); | ||
| } | ||
|
|
||
| @Test | ||
| void cumCountWhereRange1Group1Col() { | ||
| setup(3, 10, 0); | ||
| var q = "timed.update_by(ops=cum_count_where(col='X', filters=['num1 > 3']), by=['key1'])"; | ||
| runner.test("CumCountWhere- Range 1 Group 100 Unique Vals", q, "key1", "num1"); | ||
| } | ||
|
|
||
| @Test | ||
| void cumCountWhereEquals2Groups1Col() { | ||
| setup(2, 3, 1); | ||
| var q = "timed.update_by(ops=cum_count_where(col='X', filters=['num1 % 3 = 0']), by=['key1','key2'])"; | ||
| runner.test("CumCountWhere- Equals 2 Groups 10K Unique Combos", q, "key1", "key2", "num1"); | ||
| } | ||
|
|
||
| } |
39 changes: 39 additions & 0 deletions
39
src/it/java/io/deephaven/benchmark/tests/standard/updateby/RollingCountWhereTickTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| /* Copyright (c) 2025-2026 Deephaven Data Labs and Patent Pending */ | ||
| package io.deephaven.benchmark.tests.standard.updateby; | ||
|
|
||
| import org.junit.jupiter.api.*; | ||
| import io.deephaven.benchmark.tests.standard.StandardTestRunner; | ||
|
|
||
| /** | ||
| * Standard tests for the updateBy table operation. Defines a tick-based rolling countWhere. The result table contains | ||
| * an additional column with windowed rolling countWhere. | ||
| * <p> | ||
| * Note: This test must contain benchmarks and <code>rev_ticks/fwd_ticks</code> that are comparable to | ||
| * <code>RollingCountWhereTimeTest</code> | ||
| */ | ||
| public class RollingCountWhereTickTest { | ||
| final StandardTestRunner runner = new StandardTestRunner(this); | ||
| final Setup setup = new Setup(runner); | ||
| final String fifty = """ | ||
| from deephaven.updateby import rolling_count_where_tick | ||
| contains_row = rolling_count_where_tick('X',filters=["num1 > 3"],rev_ticks=20,fwd_ticks=30) | ||
| """; | ||
|
|
||
|
|
||
| @Test | ||
| void rollingCountWhereTick1Group3Ops() { | ||
| setup.factors(5, 4, 0); | ||
| runner.addSetupQuery(fifty); | ||
| var q = "timed.update_by(ops=[contains_row], by=['key1'])"; | ||
| runner.test("RollingCountWhereTick- 1 Group 100 Unique Vals", q, "key1", "num1"); | ||
| } | ||
|
|
||
| @Test | ||
| void rollingCountWhereTick2Groups3Ops() { | ||
| setup.factors(2, 3, 1); | ||
| runner.addSetupQuery(fifty); | ||
| var q = "timed.update_by(ops=[contains_row], by=['key1','key2'])"; | ||
| runner.test("RollingCountWhereTick- 2 Groups 10K Unique Combos", q, "key1", "key2", "num1"); | ||
| } | ||
|
|
||
| } |
42 changes: 42 additions & 0 deletions
42
src/it/java/io/deephaven/benchmark/tests/standard/updateby/RollingCountWhereTimeTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| /* Copyright (c) 2025-2026 Deephaven Data Labs and Patent Pending */ | ||
| package io.deephaven.benchmark.tests.standard.updateby; | ||
|
|
||
| import org.junit.jupiter.api.*; | ||
| import io.deephaven.benchmark.tests.standard.StandardTestRunner; | ||
|
|
||
| /** | ||
| * Standard tests for the updateBy table operation. Defines a time-based rolling countWhere. The result table contains | ||
| * an additional column with windowed rolling countWhere. | ||
| * <p> | ||
| * Note: This test must contain benchmarks and <code>rev_time/fwd_time</code> that are comparable to | ||
| * <code>RollingCountWhereTickTest</code> | ||
| */ | ||
| public class RollingCountWhereTimeTest { | ||
| final StandardTestRunner runner = new StandardTestRunner(this); | ||
| final Setup setup = new Setup(runner); | ||
| final String fifty1Group = """ | ||
| from deephaven.updateby import rolling_count_where_time | ||
| contains_row = rolling_count_where_time("timestamp",'X',filters=["num1 > 3"],rev_time="PT2S",fwd_time="PT3S") | ||
| """; | ||
| final String fifty2Groups = """ | ||
| from deephaven.updateby import rolling_count_where_time | ||
| contains_row = rolling_count_where_time("timestamp",'X',filters=["num1 > 3"],rev_time="PT4M",fwd_time="PT5M") | ||
| """; | ||
|
|
||
| @Test | ||
| void rollingCountWhereTime1Group3Ops() { | ||
| setup.factors(4, 2, 0); | ||
| runner.addSetupQuery(fifty1Group); | ||
| var q = "timed.update_by(ops=[contains_row], by=['key1'])"; | ||
| runner.test("RollingCountWhereTime- 1 Group 100 Unique Vals", q, "key1", "num1", "timestamp"); | ||
| } | ||
|
|
||
| @Test | ||
| void rollingCountWhereTime2Groups3Ops() { | ||
| setup.factors(2, 2, 1); | ||
| runner.addSetupQuery(fifty2Groups); | ||
| var q = "timed.update_by(ops=[contains_row], by=['key1','key2'])"; | ||
| runner.test("RollingCountWhereTime- 2 Groups 10K Unique Combos", q, "key1", "key2", "num1", "timestamp"); | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.