use of io.druid.segment.column.DictionaryEncodedColumn in project druid by druid-io.
the class QueryableIndexIndexableAdapter method getDimValueLookup.
@Override
public Indexed<Comparable> getDimValueLookup(String dimension) {
final Column column = input.getColumn(dimension);
if (column == null) {
return null;
}
final DictionaryEncodedColumn dict = column.getDictionaryEncoding();
if (dict == null) {
return null;
}
return new Indexed<Comparable>() {
@Override
public Class<? extends Comparable> getClazz() {
return Comparable.class;
}
@Override
public int size() {
return dict.getCardinality();
}
@Override
public Comparable get(int index) {
return dict.lookupName(index);
}
@Override
public int indexOf(Comparable value) {
return dict.lookupId(value);
}
@Override
public Iterator<Comparable> iterator() {
return IndexedIterable.create(this).iterator();
}
};
}
use of io.druid.segment.column.DictionaryEncodedColumn in project druid by druid-io.
the class StringDimensionHandler method getEncodedKeyComponentFromColumn.
@Override
public int[] getEncodedKeyComponentFromColumn(Closeable column, int currRow) {
DictionaryEncodedColumn dict = (DictionaryEncodedColumn) column;
int[] theVals;
if (dict.hasMultipleValues()) {
final IndexedInts dimVals = dict.getMultiValueRow(currRow);
theVals = new int[dimVals.size()];
for (int i = 0; i < theVals.length; ++i) {
theVals[i] = dimVals.get(i);
}
} else {
theVals = new int[1];
theVals[0] = dict.getSingleValueRow(currRow);
}
return theVals;
}
use of io.druid.segment.column.DictionaryEncodedColumn in project druid by druid-io.
the class IndexMergerTest method assertDimCompression.
private void assertDimCompression(QueryableIndex index, CompressedObjectStrategy.CompressionStrategy expectedStrategy) throws Exception {
// Java voodoo
if (expectedStrategy == null || expectedStrategy == CompressedObjectStrategy.CompressionStrategy.UNCOMPRESSED) {
return;
}
DictionaryEncodedColumn encodedColumn = index.getColumn("dim2").getDictionaryEncoding();
Object obj;
if (encodedColumn.hasMultipleValues()) {
Field field = SimpleDictionaryEncodedColumn.class.getDeclaredField("multiValueColumn");
field.setAccessible(true);
obj = field.get(encodedColumn);
} else {
Field field = SimpleDictionaryEncodedColumn.class.getDeclaredField("column");
field.setAccessible(true);
obj = field.get(encodedColumn);
}
// CompressedVSizeIntsIndexedSupplier$CompressedByteSizeIndexedInts
// CompressedVSizeIndexedSupplier$CompressedVSizeIndexed
Field compressedSupplierField = obj.getClass().getDeclaredField("this$0");
compressedSupplierField.setAccessible(true);
Object supplier = compressedSupplierField.get(obj);
Field compressionField = supplier.getClass().getDeclaredField("compression");
compressionField.setAccessible(true);
Object strategy = compressionField.get(supplier);
Assert.assertEquals(expectedStrategy, strategy);
}
use of io.druid.segment.column.DictionaryEncodedColumn in project druid by druid-io.
the class ColumnSelectorBitmapIndexSelector method getDimensionValues.
@Override
public Indexed<String> getDimensionValues(String dimension) {
if (isFilterableVirtualColumn(dimension)) {
// Virtual columns don't have dictionaries or indexes.
return null;
}
final Column columnDesc = index.getColumn(dimension);
if (columnDesc == null || !columnDesc.getCapabilities().isDictionaryEncoded()) {
return null;
}
final DictionaryEncodedColumn<String> column = columnDesc.getDictionaryEncoding();
return new Indexed<String>() {
@Override
public Class<? extends String> getClazz() {
return String.class;
}
@Override
public int size() {
return column.getCardinality();
}
@Override
public String get(int index) {
return column.lookupName(index);
}
@Override
public int indexOf(String value) {
return column.lookupId(value);
}
@Override
public Iterator<String> iterator() {
return IndexedIterable.create(this).iterator();
}
};
}
Aggregations