io.deephaven.server.table.ops.ColumnStatisticsGrpcImpl Maven / Gradle / Ivy
The newest version!
//
// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending
//
package io.deephaven.server.table.ops;
import com.google.rpc.Code;
import io.deephaven.auth.codegen.impl.TableServiceContextualAuthWiring;
import io.deephaven.configuration.Configuration;
import io.deephaven.engine.rowset.RowSet;
import io.deephaven.engine.table.ColumnDefinition;
import io.deephaven.engine.table.ColumnSource;
import io.deephaven.engine.table.Table;
import io.deephaven.engine.table.impl.NotificationStepSource;
import io.deephaven.engine.table.impl.remote.ConstructSnapshot;
import io.deephaven.engine.table.impl.sources.ReinterpretUtils;
import io.deephaven.proto.backplane.grpc.BatchTableRequest;
import io.deephaven.proto.backplane.grpc.ColumnStatisticsRequest;
import io.deephaven.proto.util.Exceptions;
import io.deephaven.server.session.SessionState;
import io.deephaven.server.table.stats.CharacterChunkedStats;
import io.deephaven.server.table.stats.ChunkedNumericalStatsKernel;
import io.deephaven.server.table.stats.ChunkedStatsKernel;
import io.deephaven.server.table.stats.DateTimeChunkedStats;
import io.deephaven.server.table.stats.ObjectChunkedStats;
import io.deephaven.util.type.NumericTypeUtils;
import org.apache.commons.lang3.mutable.Mutable;
import org.apache.commons.lang3.mutable.MutableObject;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.time.Instant;
import java.time.ZonedDateTime;
import java.util.List;
@Singleton
public class ColumnStatisticsGrpcImpl extends GrpcTableOperation {
/** Default number of unique values to collect from a column. */
private static final int DEFAULT_UNIQUE_LIMIT =
Configuration.getInstance().getIntegerWithDefault("ColumnStatistics.defaultUniqueLimit", 20);
/** Maximum number of unique values to let a client request. */
private static final int MAX_UNIQUE_LIMIT =
Configuration.getInstance().getIntegerWithDefault("ColumnStatistics.maxUniqueLimit", 200);
/**
* Maximum number of unique values to collect before falling back and only collecting the count, not the most common
* values
*/
private static final int MAX_UNIQUE_TO_COLLECT =
Configuration.getInstance().getIntegerWithDefault("ColumnStatistics.maxUniqueToCollect", 1_000_000);
@Inject
public ColumnStatisticsGrpcImpl(final TableServiceContextualAuthWiring authWiring) {
super(authWiring::checkPermissionComputeColumnStatistics, BatchTableRequest.Operation::getColumnStatistics,
ColumnStatisticsRequest::getResultId, ColumnStatisticsRequest::getSourceId);
}
@Override
public Table create(ColumnStatisticsRequest request, List> sourceTables) {
Table table = sourceTables.get(0).get().coalesce();
String columnName = request.getColumnName();
ColumnDefinition