Skip to content

Commit

Permalink
refactor: Migrate zero-length arrays from CollectionUtil to ArrayType…
Browse files Browse the repository at this point in the history
…Utils

Partial deephaven#188
  • Loading branch information
niloc132 committed Jul 10, 2024
1 parent 4d8406f commit 8cbeb84
Show file tree
Hide file tree
Showing 78 changed files with 268 additions and 306 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
//
package io.deephaven.benchmarking.generator;

import io.deephaven.datastructures.util.CollectionUtil;
import io.deephaven.benchmarking.generator.random.ExtendedRandom;
import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -50,7 +49,7 @@ public void init(@NotNull ExtendedRandom random) {
enums.add(super.get());
}

enumVals = enums.toArray(CollectionUtil.ZERO_LENGTH_STRING_ARRAY);
enumVals = enums.toArray(String[]::new);
}

public String get() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,27 @@
*/
public class CollectionUtil {

public static final byte[] ZERO_LENGTH_BYTE_ARRAY = new byte[0];
@Deprecated(forRemoval = true)
public static final short[] ZERO_LENGTH_SHORT_ARRAY = new short[0];
@Deprecated(forRemoval = true)
public static final byte[] ZERO_LENGTH_BYTE_ARRAY = new byte[0];
@Deprecated(forRemoval = true)
public static final int[] ZERO_LENGTH_INT_ARRAY = new int[0];
@Deprecated(forRemoval = true)
public static final int[][] ZERO_LENGTH_INT_ARRAY_ARRAY = new int[0][];
@Deprecated(forRemoval = true)
public static final long[] ZERO_LENGTH_LONG_ARRAY = new long[0];
@Deprecated(forRemoval = true)
public static final float[] ZERO_LENGTH_FLOAT_ARRAY = new float[0];
@Deprecated(forRemoval = true)
public static final double[] ZERO_LENGTH_DOUBLE_ARRAY = new double[0];
@Deprecated(forRemoval = true)
public static final double[][] ZERO_LENGTH_DOUBLE_ARRAY_ARRAY = new double[0][];
@Deprecated(forRemoval = true)
public static final Object[] ZERO_LENGTH_OBJECT_ARRAY = new Object[0];
@Deprecated(forRemoval = true)
public static final String[] ZERO_LENGTH_STRING_ARRAY = new String[0];
@Deprecated(forRemoval = true)
public static final String[][] ZERO_LENGTH_STRING_ARRAY_ARRAY = new String[0][];

// ----------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ private static String createMultiSeriesArgs(JavaFunction f) {
final String[] names = f.getParameterNames();
String args = String.join(", ", names);
if (!names[names.length - 1].equals("keys")) {
args += ", io.deephaven.datastructures.util.CollectionUtil.ZERO_LENGTH_OBJECT_ARRAY";
args += ", io.deephaven.util.type.ArrayTypeUtils.EMPTY_OBJECT_ARRAY";
}

return args;
Expand Down
7 changes: 3 additions & 4 deletions Plot/src/main/java/io/deephaven/plot/AxesImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import io.deephaven.api.ColumnName;
import io.deephaven.api.agg.Aggregation;
import io.deephaven.datastructures.util.CollectionUtil;
import io.deephaven.engine.table.impl.MemoizedOperationKey;
import io.deephaven.plot.axisformatters.AxisFormat;
import io.deephaven.plot.axisformatters.NanosAxisFormat;
Expand Down Expand Up @@ -1583,7 +1582,7 @@ public IntervalXYDataSeriesArray histPlot(final Comparable seriesName, final Sel
final List<String> allCols = new ArrayList<>(byCols);
allCols.add(x);
final SwappableTable ht = sds.getSwappableTable(seriesName, chart, tableTransform,
allCols.toArray(CollectionUtil.ZERO_LENGTH_STRING_ARRAY));
allCols.toArray(String[]::new));
return histPlot(seriesName, ht);
}

Expand All @@ -1607,7 +1606,7 @@ public IntervalXYDataSeriesArray histPlot(final Comparable seriesName, final Sel
final List<String> allCols = new ArrayList<>(byCols);
allCols.add(x);
final SwappableTable ht = sds.getSwappableTable(seriesName, chart, tableTransform,
allCols.toArray(CollectionUtil.ZERO_LENGTH_STRING_ARRAY));
allCols.toArray(String[]::new));
return histPlot(seriesName, ht);
}

Expand Down Expand Up @@ -1653,7 +1652,7 @@ public CategoryDataSeriesSwappablePartitionedTable catHistPlot(final Comparable
}

final Function<Table, Table> tableTransform = (Function<Table, Table> & Serializable) t -> PlotUtils
.createCategoryHistogramTable(t, cols.toArray(CollectionUtil.ZERO_LENGTH_STRING_ARRAY));
.createCategoryHistogramTable(t, cols.toArray(String[]::new));
final SwappableTable counts = sds.getSwappableTable(seriesName, chart, tableTransform, categories,
CategoryDataSeries.CAT_SERIES_ORDER_COLUMN);
final CategoryDataSeriesSwappablePartitionedTable ds = new CategoryDataSeriesSwappablePartitionedTable(this,
Expand Down
3 changes: 1 addition & 2 deletions Plot/src/main/java/io/deephaven/plot/BaseFigureImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import io.deephaven.api.Selectable;
import io.deephaven.configuration.Configuration;
import io.deephaven.datastructures.util.CollectionUtil;
import io.deephaven.engine.table.PartitionedTable;
import io.deephaven.plot.errors.*;
import io.deephaven.plot.util.functions.FigureImplFunction;
Expand Down Expand Up @@ -491,7 +490,7 @@ public void consolidatePartitionedTables() {
final Map<Set<String>, PartitionedTable> byColMap = new HashMap<>();
for (final PartitionedTableHandle h : hs) {
final Set<String> keyColumns = h.getKeyColumns();
final String[] keyColumnsArray = keyColumns.toArray(CollectionUtil.ZERO_LENGTH_STRING_ARRAY);
final String[] keyColumnsArray = keyColumns.toArray(String[]::new);

final PartitionedTable partitionedTable = byColMap.computeIfAbsent(keyColumns,
x -> {
Expand Down
Loading

0 comments on commit 8cbeb84

Please sign in to comment.