io.deephaven.engine.table.impl.sources.UngroupedCharVectorColumnSource 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.ColumnSource;
import io.deephaven.engine.table.impl.MutableColumnSourceGetDefaults;
import io.deephaven.vector.CharVector;
import static io.deephaven.util.QueryConstants.NULL_CHAR;
public class UngroupedCharVectorColumnSource extends UngroupedColumnSource implements MutableColumnSourceGetDefaults.ForChar {
private ColumnSource innerSource;
private final boolean isUngroupable;
@Override
public Class> getComponentType() {
return null;
}
public UngroupedCharVectorColumnSource(ColumnSource innerSource) {
super(Character.class);
this.innerSource = innerSource;
this.isUngroupable = innerSource instanceof UngroupableColumnSource && ((UngroupableColumnSource)innerSource).isUngroupable();
}
@Override
public Character get(long rowKey) {
if (rowKey < 0) {
return null;
}
long segment = rowKey >>base;
int offset = (int) (rowKey & ((1< >base;
int offset = (int) (rowKey & ((1< > getPrevBase();
int offset = (int) (rowKey & ((1<< getPrevBase()) - 1));
final Character result;
if (isUngroupable) {
result = (Character)((UngroupableColumnSource)innerSource).getUngroupedPrev(segment, offset);
if (result == null) {
return null;
}
} else {
final CharVector segmentArray = innerSource.getPrev(segment);
result = segmentArray == null ? NULL_CHAR : segmentArray.get(offset);
}
return (result == NULL_CHAR ? null : result);
}
@Override
public char getPrevChar(long rowKey) {
if (rowKey < 0) {
return NULL_CHAR;
}
long segment = rowKey >> getPrevBase();
int offset = (int) (rowKey & ((1<< getPrevBase()) - 1));
if (isUngroupable) {
return ((UngroupableColumnSource)innerSource).getUngroupedPrevChar(segment, offset);
}
final CharVector segmentArray = innerSource.getPrev(segment);
return segmentArray == null ? NULL_CHAR : segmentArray.get(offset);
}
@Override
public boolean isImmutable() {
return false;
}
@Override
public boolean isStateless() {
return innerSource.isStateless();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy