io.deephaven.engine.table.impl.by.ssmminmax.CharSetResult 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.by.ssmminmax;
import io.deephaven.engine.table.WritableColumnSource;
import io.deephaven.engine.table.impl.sources.CharacterArraySource;
import io.deephaven.engine.table.impl.ssms.CharSegmentedSortedMultiset;
import io.deephaven.engine.table.impl.ssms.SegmentedSortedMultiSet;
import static io.deephaven.util.QueryConstants.NULL_CHAR;
public class CharSetResult implements SsmChunkedMinMaxOperator.SetResult {
private final boolean minimum;
private final CharacterArraySource resultColumn;
public CharSetResult(boolean minimum, WritableColumnSource resultColumn) {
this.minimum = minimum;
this.resultColumn = (CharacterArraySource) resultColumn;
}
@Override
public boolean setResult(SegmentedSortedMultiSet ssm, long destination) {
final char newResult;
if (ssm.size() == 0) {
newResult = NULL_CHAR;
} else {
final CharSegmentedSortedMultiset charSsm = (CharSegmentedSortedMultiset) ssm;
newResult = minimum ? charSsm.getMinChar() : charSsm.getMaxChar();
}
return setResult(destination, newResult);
}
@Override
public boolean setResultNull(long destination) {
return setResult(destination, NULL_CHAR);
}
private boolean setResult(long destination, char newResult) {
final char oldResult = resultColumn.getAndSetUnsafe(destination, newResult);
return oldResult != newResult;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy