io.deephaven.engine.table.impl.by.ssmcountdistinct.ShortSsmBackedSource 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
*/
/*
* ---------------------------------------------------------------------------------------------------------------------
* AUTO-GENERATED CLASS - DO NOT EDIT MANUALLY - for any changes edit CharSsmBackedSource and regenerate
* ---------------------------------------------------------------------------------------------------------------------
*/
package io.deephaven.engine.table.impl.by.ssmcountdistinct;
import io.deephaven.vector.ShortVector;
import io.deephaven.engine.table.impl.AbstractColumnSource;
import io.deephaven.engine.table.impl.ColumnSourceGetDefaults;
import io.deephaven.engine.table.impl.MutableColumnSourceGetDefaults;
import io.deephaven.engine.table.impl.sources.ObjectArraySource;
import io.deephaven.engine.table.impl.ssms.ShortSegmentedSortedMultiset;
import io.deephaven.engine.rowset.RowSet;
/**
* A {@link SsmBackedColumnSource} for Shorts.
*/
public class ShortSsmBackedSource extends AbstractColumnSource
implements ColumnSourceGetDefaults.ForObject,
MutableColumnSourceGetDefaults.ForObject,
SsmBackedColumnSource {
private final ObjectArraySource underlying;
private boolean trackingPrevious = false;
//region Constructor
public ShortSsmBackedSource() {
super(ShortVector.class, short.class);
underlying = new ObjectArraySource<>(ShortSegmentedSortedMultiset.class, short.class);
}
//endregion Constructor
//region SsmBackedColumnSource
@Override
public ShortSegmentedSortedMultiset getOrCreate(long key) {
ShortSegmentedSortedMultiset ssm = underlying.getUnsafe(key);
if(ssm == null) {
//region CreateNew
underlying.set(key, ssm = new ShortSegmentedSortedMultiset(SsmDistinctContext.NODE_SIZE));
//endregion CreateNew
}
ssm.setTrackDeltas(trackingPrevious);
return ssm;
}
@Override
public ShortSegmentedSortedMultiset getCurrentSsm(long key) {
return underlying.getUnsafe(key);
}
@Override
public void clear(long key) {
underlying.set(key, null);
}
@Override
public void ensureCapacity(long capacity) {
underlying.ensureCapacity(capacity);
}
@Override
public ObjectArraySource getUnderlyingSource() {
return underlying;
}
//endregion
@Override
public boolean isImmutable() {
return false;
}
@Override
public ShortVector get(long rowKey) {
return underlying.get(rowKey);
}
@Override
public ShortVector getPrev(long rowKey) {
final ShortSegmentedSortedMultiset maybePrev = underlying.getPrev(rowKey);
return maybePrev == null ? null : maybePrev.getPrevValues();
}
@Override
public void startTrackingPrevValues() {
trackingPrevious = true;
underlying.startTrackingPrevValues();
}
@Override
public void clearDeltas(RowSet indices) {
indices.iterator().forEachLong(key -> {
final ShortSegmentedSortedMultiset ssm = getCurrentSsm(key);
if(ssm != null) {
ssm.clearDeltas();
}
return true;
});
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy