Skip to content

Commit

Permalink
Widened array and vector parquet tests. Re-scaled
Browse files Browse the repository at this point in the history
  • Loading branch information
stanbrub committed Oct 11, 2023
1 parent b713313 commit 4586c35
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,11 @@
* Standard tests for writing/reading multi-column data with different codec/compression. To save time, the parquet
* generated by the "write" tests is used by the "read" tests
*/

// Need to add array and vector tests. Look at adding iterations

@TestMethodOrder(OrderAnnotation.class)
public class ParquetCodecTest {
final ParquetTestRunner runner = new ParquetTestRunner(this);
final String[] usedColumns = {"str10K", "long10K", "int10K", "short10K", "bigDec10K", "array1K", "vector1K"};
final String[] usedColumns = {"str10K", "long10K", "int10K", "short10K", "bigDec10K", "array5", "vector5"};

@BeforeEach
public void setup() {
runner.setScaleFactors(5, 1);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.deephaven.benchmark.tests.standard.parquet;

import org.junit.jupiter.api.*;
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;

/**
* Standard tests for writing single column parquet for different column types.
Expand All @@ -11,43 +10,43 @@ public class ParquetSingleColTest {

@Test
public void writeOneStringCol() {
runner.setScaleFactors(5, 50);
runner.setScaleFactors(5, 15);
runner.runWriteTest("ParquetWrite- 1 String Col -Static", "SNAPPY", "str10K");
}

@Test
public void writeOneBigDecimalCol() {
runner.setScaleFactors(5, 12);
runner.setScaleFactors(5, 6);
runner.runWriteTest("ParquetWrite- 1 Big Decimal Col -Static", "SNAPPY", "bigDec10K");
}

@Test
public void writeOneLongCol() {
runner.setScaleFactors(5, 30);
runner.setScaleFactors(5, 15);
runner.runWriteTest("ParquetWrite- 1 Long Col -Static", "SNAPPY", "long10K");
}

@Test
public void writeOneIntCol() {
runner.setScaleFactors(5, 60);
runner.setScaleFactors(5, 30);
runner.runWriteTest("ParquetWrite- 1 Int Col -Static", "SNAPPY", "int10K");
}

@Test
public void writeOneShortCol() {
runner.setScaleFactors(5, 70);
runner.setScaleFactors(5, 35);
runner.runWriteTest("ParquetWrite- 1 Short Col -Static", "SNAPPY", "short10K");
}

@Test
public void writeOneArrayCol() {
runner.setScaleFactors(5, 2);
runner.setScaleFactors(0.10, 1);
runner.runWriteTest("ParquetWrite- 1 Int Array Col -Static", "SNAPPY", "array1K");
}

@Test
public void writeOneVectorCol() {
runner.setScaleFactors(5, 2);
runner.setScaleFactors(0.10, 1);
runner.runWriteTest("ParquetWrite- 1 Int Vector Col -Static", "SNAPPY", "vector1K");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class ParquetTestRunner {
final Object testInst;
final Bench api;
private int rowCountFactor = 1;
private double rowCountFactor = 1;
private int scaleFactor = 1;
private long scaleRowCount;

Expand All @@ -31,7 +31,7 @@ class ParquetTestRunner {
* @param rowCountFactor the multiplier for the scale.row.count property
* @param scaleFactor the multiplier for how many merges to do on the generated table to simulate more rows
*/
void setScaleFactors(int rowCountFactor, int scaleFactor) {
void setScaleFactors(double rowCountFactor, int scaleFactor) {
this.rowCountFactor = rowCountFactor;
this.scaleRowCount = (long) (api.propertyAsIntegral("scale.row.count", "100000") * rowCountFactor);
this.scaleFactor = scaleFactor;
Expand Down Expand Up @@ -140,34 +140,22 @@ String getGenerators(String... columnNames) {
* @param columnName the column name to generate data for
* @return the data generation code
*/
String getGenerator(String columnName) {
String g = "";
switch (columnName) {
case "str10K":
g = "(ii % 10 == 0) ? null : (`` + (ii % 10000))";
break;
case "long10K":
g = "(ii % 10 == 0) ? null : (ii % 10000)";
break;
case "int10K":
g = "(ii % 10 == 0) ? null : ((int)(ii % 10000))";
break;
case "short10K":
g = "(ii % 10 == 0) ? null : ((short)(ii % 10000))";
break;
case "bigDec10K":
g = "(ii % 10 == 0) ? null : java.math.BigDecimal.valueOf(ii % 10000)";
break;
case "array1K":
g = "(ii % 10 == 0) ? null : new int[]{i,i+1,i+2,i+3,i+4,i+5}";
break;
case "vector1K":
g = "(ii % 10 == 0) ? null : new io.deephaven.vector.IntVectorDirect(i,i+1,i+2,i+3,i+4,i+5)";
break;
default:
throw new RuntimeException("Undefined column: " + columnName);
}
return g;
String getGenerator(final String columnName) {
var array5 = "java.util.stream.IntStream.range((int)(ii % 5),(int)((ii % 5) + 5)).toArray()";
var array1K = "java.util.stream.IntStream.range((int)(ii % 1000),(int)((ii % 1000) + 1000)).toArray()";
var gen = switch (columnName) {
case "str10K" -> "(`` + (ii % 10000))";
case "long10K" -> "(ii % 10000)";
case "int10K" -> "((int)(ii % 10000))";
case "short10K" -> "((short)(ii % 10000))";
case "bigDec10K" -> "java.math.BigDecimal.valueOf(ii % 10000)";
case "array5" -> array5;
case "vector5" -> "new io.deephaven.vector.IntVectorDirect(" + array5 + ")";
case "array1K" -> array1K;
case "vector1K" -> "new io.deephaven.vector.IntVectorDirect(" + array1K + ")";
default -> throw new RuntimeException("Undefined column: " + columnName);
};
return "(ii % 10 == 0) ? null : " + gen;
}

/**
Expand Down

0 comments on commit 4586c35

Please sign in to comment.