Skip to content

Commit

Permalink
Initial commit for AggCount additional operators.
Browse files Browse the repository at this point in the history
  • Loading branch information
lbooker42 committed Nov 8, 2024
1 parent 09eeedb commit 1e21206
Show file tree
Hide file tree
Showing 24 changed files with 1,371 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public void visit(AggSpecApproximatePercentile approxPct) {}
@Override
public void visit(AggSpecAvg avg) {}

@Override
public void visit(AggSpecCountValues countValues) {}

@Override
public void visit(AggSpecCountDistinct countDistinct) {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ public void visit(AggSpecAvg avg) {
drop();
}

@Override
public void visit(AggSpecCountValues countValues) {
drop();
}

@Override
public void visit(AggSpecCountDistinct countDistinct) {
drop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ public void visit(AggSpecAvg avg) {
out = Collections.emptySet();
}

@Override
public void visit(AggSpecCountValues countValues) {
out = Collections.emptySet();
}

@Override
public void visit(AggSpecCountDistinct countDistinct) {
out = Collections.emptySet();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,7 @@
import io.deephaven.api.Pair;
import io.deephaven.api.SortColumn;
import io.deephaven.api.agg.*;
import io.deephaven.api.agg.spec.AggSpec;
import io.deephaven.api.agg.spec.AggSpecAbsSum;
import io.deephaven.api.agg.spec.AggSpecApproximatePercentile;
import io.deephaven.api.agg.spec.AggSpecAvg;
import io.deephaven.api.agg.spec.AggSpecCountDistinct;
import io.deephaven.api.agg.spec.AggSpecDistinct;
import io.deephaven.api.agg.spec.AggSpecFirst;
import io.deephaven.api.agg.spec.AggSpecFormula;
import io.deephaven.api.agg.spec.AggSpecFreeze;
import io.deephaven.api.agg.spec.AggSpecGroup;
import io.deephaven.api.agg.spec.AggSpecLast;
import io.deephaven.api.agg.spec.AggSpecMax;
import io.deephaven.api.agg.spec.AggSpecMedian;
import io.deephaven.api.agg.spec.AggSpecMin;
import io.deephaven.api.agg.spec.AggSpecPercentile;
import io.deephaven.api.agg.spec.AggSpecSortedFirst;
import io.deephaven.api.agg.spec.AggSpecSortedLast;
import io.deephaven.api.agg.spec.AggSpecStd;
import io.deephaven.api.agg.spec.AggSpecSum;
import io.deephaven.api.agg.spec.AggSpecTDigest;
import io.deephaven.api.agg.spec.AggSpecUnique;
import io.deephaven.api.agg.spec.AggSpecVar;
import io.deephaven.api.agg.spec.AggSpecWAvg;
import io.deephaven.api.agg.spec.AggSpecWSum;
import io.deephaven.api.agg.spec.*;
import io.deephaven.api.object.UnionObject;
import io.deephaven.base.verify.Assert;
import io.deephaven.chunk.ChunkType;
Expand Down Expand Up @@ -727,6 +704,11 @@ public void visit(@NotNull final AggSpecAvg avg) {
addBasicOperators((t, n) -> makeAvgOperator(t, n, false));
}

@Override
public void visit(@NotNull final AggSpecCountValues countValues) {
addBasicOperators((t, n) -> makeCountOperator(t, n, countValues.countType()));
}

@Override
public void visit(@NotNull final AggSpecCountDistinct countDistinct) {
addBasicOperators((t, n) -> makeCountDistinctOperator(t, n, countDistinct.countNulls(), false, false));
Expand Down Expand Up @@ -942,6 +924,7 @@ private RollupBaseConverter(

@Override
public void visit(@NotNull final Count count) {
// No input needed, counting rows not values
addNoInputOperator(new CountAggregationOperator(count.column().name()));
}

Expand Down Expand Up @@ -977,6 +960,11 @@ public void visit(@NotNull final AggSpecAvg avg) {
addBasicOperators((t, n) -> makeAvgOperator(t, n, true));
}

@Override
public void visit(@NotNull final AggSpecCountValues countValues) {
addBasicOperators((t, n) -> makeSumOperator(t, n, false));
}

@Override
public void visit(@NotNull final AggSpecCountDistinct countDistinct) {
addBasicOperators((t, n) -> makeCountDistinctOperator(t, n, countDistinct.countNulls(), true, false));
Expand Down Expand Up @@ -1127,6 +1115,11 @@ public void visit(@NotNull final AggSpecAvg avg) {
reaggregateAvgOperator();
}

@Override
public void visit(@NotNull final AggSpecCountValues countValues) {
reaggregateAsSum();
}

@Override
public void visit(@NotNull final AggSpecCountDistinct countDistinct) {
reaggregateSsmBackedOperator((ssmSrc, priorResultSrc, n) -> makeCountDistinctOperator(
Expand Down Expand Up @@ -1490,6 +1483,34 @@ private WeightedOpResult(@NotNull final Pair pair, @NotNull final WeightedOpResu
// Operator Construction Helpers (e.g. to multiplex on input/output data type)
// -----------------------------------------------------------------------------------------------------------------

private static IterativeChunkedAggregationOperator makeCountOperator(
@NotNull final Class<?> type,
@NotNull final String name,
final AggSpecCountValues.AggCountType countType) {
if (type == Byte.class || type == byte.class) {
return new ByteChunkedCountOperator(name, countType);
} else if (type == Character.class || type == char.class) {
return new CharChunkedCountOperator(name, countType);
} else if (type == Double.class || type == double.class) {
return new DoubleChunkedCountOperator(name, countType);
} else if (type == Float.class || type == float.class) {
return new FloatChunkedCountOperator(name, countType);
} else if (type == Integer.class || type == int.class) {
return new IntChunkedCountOperator(name, countType);
} else if (type == Long.class || type == long.class) {
return new LongChunkedCountOperator(name, countType);
} else if (type == Short.class || type == short.class) {
return new ShortChunkedCountOperator(name, countType);
} else if (type == BigInteger.class) {
return new BigIntegerChunkedCountOperator(name, countType);
} else if (type == BigDecimal.class) {
return new BigDecimalChunkedCountOperator(name, countType);
} else if (type == Instant.class) {
return new LongChunkedCountOperator(name, countType);
}
return new ObjectChunkedCountOperator(name, countType);
}

private static IterativeChunkedAggregationOperator makeSumOperator(
@NotNull final Class<?> type,
@NotNull final String name,
Expand Down
Loading

0 comments on commit 1e21206

Please sign in to comment.