Skip to content

Commit

Permalink
Updateby rollingWAvg and more (#106)
Browse files Browse the repository at this point in the history
* updateby rolling std,wavg,count,ems,emmax,emmin
* Change scale factors to save some time for updateby
  • Loading branch information
stanbrub authored May 16, 2023
1 parent fde3431 commit 25f933a
Show file tree
Hide file tree
Showing 21 changed files with 736 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/* Copyright (c) 2022-2023 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 tick-based exponential moving maximum for specified
* columns and places the result into a new column for each row.
*/
public class EmMaxTickTest {
final StandardTestRunner runner = new StandardTestRunner(this);

@BeforeEach
public void setup() {
runner.setRowFactor(6);
runner.tables("timed");
runner.addSetupQuery("from deephaven.updateby import emmax_tick");
}

@Test
public void emMaxTick0Group1Col() {
runner.setScaleFactors(20, 12);
var q = "timed.update_by(ops=emmax_tick(time_scale_ticks=100,cols=['X=int5']))";
runner.test("EmMaxTick- No Groups 1 Col", q, "int5");
}

@Test
public void emMaxTick0Group2Cols() {
runner.setScaleFactors(10, 7);
var q = "timed.update_by(ops=emmax_tick(time_scale_ticks=100,cols=['X=int5','Y=int10']))";
runner.test("EmMaxTick- No Groups 2 Cols", q, "int5", "int10");
}


@Test
public void emMaxTick1Group1Col() {
runner.setScaleFactors(7, 1);
var q = "timed.update_by(ops=emmax_tick(time_scale_ticks=100,cols=['X=int5']), by=['str100'])";
runner.test("EmMaxTick- 1 Group 100 Unique Vals 1 Col", q, "str100", "int5");
}

@Test
public void emMaxTick1Group2Cols() {
runner.setScaleFactors(5, 1);
var q = "timed.update_by(ops=emmax_tick(time_scale_ticks=100,cols=['X=int5','Y=int10']), by=['str100'])";
runner.test("EmMaxTick- 1 Group 100 Unique Vals 2 Cols", q, "str100", "int5", "int10");
}

@Test
public void emMaxTick2GroupsInt() {
runner.setScaleFactors(5, 1);
var q = "timed.update_by(ops=emmax_tick(time_scale_ticks=100,cols=['X=int5']), by=['str100','str150'])";
runner.test("EmMaxTick- 2 Groups 15K Unique Combos 1 Col Int", q, "str100", "str150",
"int5");
}

@Test
public void emMaxTick2GroupsFloat() {
runner.setScaleFactors(5, 1);
var q = "timed.update_by(ops=emmax_tick(time_scale_ticks=100,cols=['X=float5']), by=['str100','str150'])";
runner.test("EmMaxTick- 2 Groups 15K Unique Combos 1 Col Float", q, "str100", "str150",
"float5");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/* Copyright (c) 2022-2023 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 time-based exponential moving maximum for specified
* columns and places the result into a new column for each row.
*/
public class EmMaxTimeTest {
final StandardTestRunner runner = new StandardTestRunner(this);

@BeforeEach
public void setup() {
runner.setRowFactor(6);
runner.tables("timed");
runner.addSetupQuery("from deephaven.updateby import emmax_time");
}

@Test
public void emMaxTime0Group1Col() {
var q = "timed.update_by(ops=emmax_time(ts_col='timestamp', time_scale='00:00:02', cols=['X=int5']))";
runner.test("EmMaxTime- No Groups 1 Col", q, "int5", "timestamp");
}

@Test
public void emMaxTime1Group1Col() {
var q = "timed.update_by(ops=emmax_time(ts_col='timestamp', time_scale='00:00:02', cols=['X=int5']), by=['str100'])";
runner.test("EmMaxTime- 1 Group 100 Unique Vals 1 Col", q, "str100", "int5", "timestamp");
}

@Test
public void emMaxTime2GroupsInt() {
var q = "timed.update_by(ops=emmax_time(ts_col='timestamp', time_scale='00:00:02', cols=['X=int5']), by=['str100','str150'])";
runner.test("EmMaxTime- 2 Groups 15K Unique Combos 1 Col Int", q, "str100", "str150",
"int5", "timestamp");
}

@Test
public void emMaxTime2GroupsFloat() {
var q = "timed.update_by(ops=emmax_time(ts_col='timestamp', time_scale='00:00:02', cols=['X=float5']), by=['str100','str150'])";
runner.test("EmMaxTime- 2 Groups 15K Unique Combos 1 Col Float", q, "str100", "str150",
"float5", "timestamp");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/* Copyright (c) 2022-2023 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 tick-based exponential moving minimum for specified
* columns and places the result into a new column for each row.
*/
public class EmMinTickTest {
final StandardTestRunner runner = new StandardTestRunner(this);

@BeforeEach
public void setup() {
runner.setRowFactor(6);
runner.tables("timed");
runner.addSetupQuery("from deephaven.updateby import emmin_tick");
}

@Test
public void emMinTick0Group1Col() {
runner.setScaleFactors(20, 12);
var q = "timed.update_by(ops=emmin_tick(time_scale_ticks=100,cols=['X=int5']))";
runner.test("EmMinTick- No Groups 1 Col", q, "int5");
}

@Test
public void emMinTick0Group2Cols() {
runner.setScaleFactors(10, 7);
var q = "timed.update_by(ops=emmin_tick(time_scale_ticks=100,cols=['X=int5','Y=int10']))";
runner.test("EmMinTick- No Groups 2 Cols", q, "int5", "int10");
}

@Test
public void emMinTick1Group1Col() {
runner.setScaleFactors(7, 1);
var q = "timed.update_by(ops=emmin_tick(time_scale_ticks=100,cols=['X=int5']), by=['str100'])";
runner.test("EmMinTick- 1 Group 100 Unique Vals 1 Col", q, "str100", "int5");
}

@Test
public void emMinTick1Group2Cols() {
runner.setScaleFactors(5, 1);
var q = "timed.update_by(ops=emmin_tick(time_scale_ticks=100,cols=['X=int5','Y=int10']), by=['str100'])";
runner.test("EmMinTick- 1 Group 100 Unique Vals 2 Cols", q, "str100", "int5", "int10");
}

@Test
public void emMinTick2GroupsInt() {
runner.setScaleFactors(5, 1);
var q = "timed.update_by(ops=emmin_tick(time_scale_ticks=100,cols=['X=int5']), by=['str100','str150'])";
runner.test("EmMinTick- 2 Groups 15K Unique Combos 1 Col Int", q, "str100", "str150",
"int5");
}

@Test
public void emMinTick2GroupsFloat() {
runner.setScaleFactors(5, 1);
var q = "timed.update_by(ops=emmin_tick(time_scale_ticks=100,cols=['X=float5']), by=['str100','str150'])";
runner.test("EmMinTick- 2 Groups 15K Unique Combos 1 Col Float", q, "str100", "str150",
"float5");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/* Copyright (c) 2022-2023 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 time-based exponential moving minimum for specified
* columns and places the result into a new column for each row.
*/
public class EmMinTimeTest {
final StandardTestRunner runner = new StandardTestRunner(this);

@BeforeEach
public void setup() {
runner.setRowFactor(6);
runner.tables("timed");
runner.addSetupQuery("from deephaven.updateby import emmin_time");
}

@Test
public void emMinTime0Group1Col() {
var q = "timed.update_by(ops=emmin_time(ts_col='timestamp', time_scale='00:00:02', cols=['X=int5']))";
runner.test("EmMinTime- No Groups 1 Col", q, "int5", "timestamp");
}

@Test
public void emMinTime1Group1Col() {
var q = "timed.update_by(ops=emmin_time(ts_col='timestamp', time_scale='00:00:02', cols=['X=int5']), by=['str100'])";
runner.test("EmMinTime- 1 Group 100 Unique Vals 1 Col", q, "str100", "int5", "timestamp");
}

@Test
public void emMinTime2GroupsInt() {
var q = "timed.update_by(ops=emmin_time(ts_col='timestamp', time_scale='00:00:02', cols=['X=int5']), by=['str100','str150'])";
runner.test("EmMinTime- 2 Groups 15K Unique Combos 1 Col Int", q, "str100", "str150",
"int5", "timestamp");
}

@Test
public void emMinTime2GroupsFloat() {
var q = "timed.update_by(ops=emmin_time(ts_col='timestamp', time_scale='00:00:02', cols=['X=float5']), by=['str100','str150'])";
runner.test("EmMinTime- 2 Groups 15K Unique Combos 1 Col Float", q, "str100", "str150",
"float5", "timestamp");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/* Copyright (c) 2022-2023 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 tick-based exponential moving sum for specified
* columns and places the result into a new column for each row.
*/
public class EmsTickTest {
final StandardTestRunner runner = new StandardTestRunner(this);

@BeforeEach
public void setup() {
runner.setRowFactor(6);
runner.tables("timed");
runner.addSetupQuery("from deephaven.updateby import ems_tick");
}

@Test
public void emsTick0Group1Col() {
runner.setScaleFactors(30, 15);
var q = "timed.update_by(ops=ems_tick(time_scale_ticks=100,cols=['X=int5']))";
runner.test("EmsTick- No Groups 1 Col", q, "int5");
}

@Test
public void emsTick0Group2Cols() {
runner.setScaleFactors(15, 8);
var q = "timed.update_by(ops=ems_tick(time_scale_ticks=100,cols=['X=int5','Y=int10']))";
runner.test("EmsTick- No Groups 2 Cols", q, "int5", "int10");
}

@Test
public void emsTick1Group1Col() {
runner.setScaleFactors(9, 1);
var q = "timed.update_by(ops=ems_tick(time_scale_ticks=100,cols=['X=int5']), by=['str100'])";
runner.test("EmsTick- 1 Group 100 Unique Vals 1 Col", q, "str100", "int5");
}

@Test
public void emsTick1Group2Cols() {
runner.setScaleFactors(5, 1);
var q = "timed.update_by(ops=ems_tick(time_scale_ticks=100,cols=['X=int5','Y=int10']), by=['str100'])";
runner.test("EmsTick- 1 Group 100 Unique Vals 2 Cols", q, "str100", "int5", "int10");
}

@Test
public void emsTick2GroupsInt() {
runner.setScaleFactors(5, 1);
var q = "timed.update_by(ops=ems_tick(time_scale_ticks=100,cols=['X=int5']), by=['str100','str150'])";
runner.test("EmsTick- 2 Groups 15K Unique Combos 1 Col Int", q, "str100", "str150",
"int5");
}

@Test
public void emsTick2GroupsFloat() {
runner.setScaleFactors(5, 1);
var q = "timed.update_by(ops=ems_tick(time_scale_ticks=100,cols=['X=float5']), by=['str100','str150'])";
runner.test("EmsTick- 2 Groups 15K Unique Combos 1 Col Float", q, "str100", "str150",
"float5");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/* Copyright (c) 2022-2023 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 time-based exponential moving average for specified
* columns and places the result into a new column for each row.
*/
public class EmsTimeTest {
final StandardTestRunner runner = new StandardTestRunner(this);

@BeforeEach
public void setup() {
runner.setRowFactor(6);
runner.tables("timed");
runner.addSetupQuery("from deephaven.updateby import ems_time");
}

@Test
public void emsTime0Group1Col() {
var q = "timed.update_by(ops=ems_time(ts_col='timestamp', time_scale='00:00:02', cols=['X=int5']))";
runner.test("EmsTime- No Groups 1 Col", q, "int5", "timestamp");
}

@Test
public void emsTime1Group1Col() {
var q = "timed.update_by(ops=ems_time(ts_col='timestamp', time_scale='00:00:02', cols=['X=int5']), by=['str100'])";
runner.test("EmsTime- 1 Group 100 Unique Vals 1 Col", q, "str100", "int5", "timestamp");
}

@Test
public void emsTime2GroupsInt() {
var q = "timed.update_by(ops=ems_time(ts_col='timestamp', time_scale='00:00:02', cols=['X=int5']), by=['str100','str150'])";
runner.test("EmsTime- 2 Groups 15K Unique Combos 1 Col Int", q, "str100", "str150",
"int5", "timestamp");
}

@Test
public void emsTime2GroupsFloat() {
var q = "timed.update_by(ops=ems_time(ts_col='timestamp', time_scale='00:00:02', cols=['X=float5']), by=['str100','str150'])";
runner.test("EmsTime- 2 Groups 15K Unique Combos 1 Col Float", q, "str100", "str150",
"float5", "timestamp");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class MixedComboTest {

@BeforeEach
public void setup() {
runner.setRowFactor(6);
runner.setRowFactor(4);
runner.tables("timed");

setupStr = """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class RollingAvgTimeTest {

@BeforeEach
public void setup() {
runner.setRowFactor(6);
runner.setRowFactor(4);
runner.tables("timed");

var setup = """
Expand All @@ -28,6 +28,8 @@ public void setup() {

@Test
public void rollingAvgTime0Group3Ops() {
runner.setRowFactor(6);
runner.tables("timed");
var q = "timed.update_by(ops=[contains_row, before_row, after_row])";
runner.test("RollingAvgTime- 3 Ops No Groups", q, "int5", "timestamp");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ public class RollingComboTest {

@BeforeEach
public void setup() {
runner.setRowFactor(6);
runner.setRowFactor(4);
runner.tables("timed");

setupStr = """
from deephaven.updateby import rolling_sum_time, rolling_min_time, rolling_prod_time
from deephaven.updateby import rolling_avg_tick, rolling_max_tick, rolling_group_tick
Expand Down
Loading

0 comments on commit 25f933a

Please sign in to comment.