Skip to content

Commit

Permalink
Remove isDateTime helper
Browse files Browse the repository at this point in the history
  • Loading branch information
niloc132 committed Jul 19, 2024
1 parent cf810b6 commit 10ddbee
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import io.deephaven.configuration.Configuration;
import io.deephaven.engine.table.ColumnDefinition;
import io.deephaven.engine.table.Table;
import io.deephaven.time.DateTimeUtils;
import io.deephaven.util.type.NumericTypeUtils;
import io.deephaven.vector.Vector;
import io.deephaven.engine.table.impl.BaseTable;
Expand All @@ -15,6 +14,8 @@
import org.apache.commons.lang3.StringUtils;
import org.jpy.PyListWrapper;

import java.time.Instant;
import java.time.ZonedDateTime;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -157,7 +158,7 @@ public static boolean isColumnTypeDisplayable(Class<?> type) {
|| io.deephaven.util.type.TypeUtils.isBoxedType(type)
|| io.deephaven.util.type.TypeUtils.isString(type)
|| NumericTypeUtils.isBigNumeric(type)
|| DateTimeUtils.isDateTime(type)
|| Instant.class == type || ZonedDateTime.class == type
|| isOnWhiteList(type);
}

Expand Down
10 changes: 0 additions & 10 deletions engine/time/src/main/java/io/deephaven/time/DateTimeUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -201,16 +201,6 @@ public class DateTimeUtils {
*/
public static final double YEARS_PER_NANO_AVG = 1. / (double) YEAR_AVG;

/**
* Whether the class is an {@link Instant} or a {@link ZonedDateTime}.
*
* @param type The class.
* @return true if the type is a DateTime: {@link ZonedDateTime} or {@link Instant}.
*/
public static boolean isDateTime(Class<?> type) {
return Instant.class == type || ZonedDateTime.class == type;
}

// endregion

// region Overflow / Underflow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import io.deephaven.engine.util.input.InputTableUpdater;
import io.deephaven.chunk.ChunkType;
import io.deephaven.proto.backplane.grpc.ExportedTableCreationResponse;
import io.deephaven.time.DateTimeUtils;
import io.deephaven.util.type.TypeUtils;
import io.deephaven.vector.Vector;
import io.grpc.stub.StreamObserver;
Expand Down Expand Up @@ -683,7 +682,7 @@ private static ConvertedArrowSchema convertArrowSchema(

private static boolean isTypeNativelySupported(final Class<?> typ) {
if (typ.isPrimitive() || TypeUtils.isBoxedType(typ) || supportedTypes.contains(typ)
|| Vector.class.isAssignableFrom(typ) || DateTimeUtils.isDateTime(typ)) {
|| Vector.class.isAssignableFrom(typ) || Instant.class == typ || ZonedDateTime.class == typ) {
return true;
}
if (typ.isArray()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import io.deephaven.server.table.stats.ChunkedStatsKernel;
import io.deephaven.server.table.stats.DateTimeChunkedStats;
import io.deephaven.server.table.stats.ObjectChunkedStats;
import io.deephaven.time.DateTimeUtils;
import io.deephaven.util.type.NumericTypeUtils;
import org.apache.commons.lang3.mutable.Mutable;
import org.apache.commons.lang3.mutable.MutableObject;
Expand Down Expand Up @@ -68,19 +67,12 @@ public Table create(ColumnStatisticsRequest request, List<SessionState.ExportObj
// Based on the column type, make a stats function and get a column source
final ChunkedStatsKernel statsFunc;
final ColumnSource<?> columnSource;
if (DateTimeUtils.isDateTime(type)) {
// Instant/ZonedDateTime only look at max/min and count
if (type == Instant.class) {
statsFunc = new DateTimeChunkedStats();

// Reinterpret the column to read only long values
if (Instant.class.isAssignableFrom(type)) {
columnSource = ReinterpretUtils.instantToLongSource(table.getColumnSource(columnName));
} else if (ZonedDateTime.class.isAssignableFrom(type)) {
columnSource = ReinterpretUtils.zonedDateTimeToLongSource(table.getColumnSource(columnName));
} else {
throw Exceptions.statusRuntimeException(Code.INVALID_ARGUMENT,
"DateTime columns must be Instant or ZonedDateTime");
}
columnSource = ReinterpretUtils.instantToLongSource(table.getColumnSource(columnName));
} else if (type == ZonedDateTime.class) {
statsFunc = new DateTimeChunkedStats();
columnSource = ReinterpretUtils.zonedDateTimeToLongSource(table.getColumnSource(columnName));
} else if (NumericTypeUtils.isNumeric(type)) {
// Numeric types have a variety of statistics recorded
statsFunc = ChunkedNumericalStatsKernel.makeChunkedNumericalStats(type);
Expand Down

0 comments on commit 10ddbee

Please sign in to comment.