io.deephaven.engine.table.impl.sources.DoubleNullToZeroColumnSource Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of deephaven-engine-table Show documentation
Show all versions of deephaven-engine-table Show documentation
Engine Table: Implementation and closely-coupled utilities
/**
* Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending
*/
package io.deephaven.engine.table.impl.sources;
import io.deephaven.engine.table.impl.AbstractColumnSource;
import io.deephaven.engine.table.impl.MutableColumnSourceGetDefaults;
import io.deephaven.util.QueryConstants;
/**
* If you want to expose the internal state of an aggregation and compare it, then the new tables might have nulls where
* the old tables have zero. This wrapper prevents that spurious comparison failure.
*/
@SuppressWarnings("unused")
public class DoubleNullToZeroColumnSource extends AbstractColumnSource implements MutableColumnSourceGetDefaults.ForDouble {
private final DoubleArraySource column;
private DoubleNullToZeroColumnSource(DoubleArraySource column) {
super(double.class);
this.column = column;
}
@Override
public void startTrackingPrevValues() {
// Nothing to do.
}
@Override
public double getDouble(long rowKey) {
final double value = column.getDouble(rowKey);
return nullToZero(value);
}
@Override
public double getPrevDouble(long rowKey) {
final double value = column.getPrevDouble(rowKey);
return nullToZero(value);
}
private static double nullToZero(double value) {
return value == QueryConstants.NULL_DOUBLE ? 0 : value;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy