1) Fix some bugs found by external test suite

This commit is contained in:
Eric Tschetter 2013-01-16 21:06:57 -06:00
parent c8cb96b006
commit 5b1e03530c
4 changed files with 44 additions and 14 deletions

View File

@ -51,7 +51,12 @@ public class BitmapIndexColumnPartSupplier implements Supplier<BitmapIndex>
{ {
final int index = dictionary.indexOf(value); final int index = dictionary.indexOf(value);
return index >= 0 ? bitmaps.get(index) : EMPTY_SET; if (index < 0) {
return EMPTY_SET;
}
final ImmutableConciseSet bitmap = bitmaps.get(index);
return bitmap == null ? EMPTY_SET : bitmap;
} }
}; };
} }

View File

@ -36,25 +36,28 @@ public class ComplexColumnPartSerde implements ColumnPartSerde
{ {
@JsonCreator @JsonCreator
public static ComplexColumnPartSerde createDeserializer( public static ComplexColumnPartSerde createDeserializer(
@JsonProperty("complexType") String complexType @JsonProperty("typeName") String complexType
) )
{ {
return new ComplexColumnPartSerde(null, complexType); return new ComplexColumnPartSerde(null, complexType);
} }
private final GenericIndexed column; private final GenericIndexed column;
private final String typeName;
private final ComplexMetricSerde serde; private final ComplexMetricSerde serde;
public ComplexColumnPartSerde(GenericIndexed column, String complexType) public ComplexColumnPartSerde(GenericIndexed column, String typeName)
{ {
this.column = column; this.column = column;
serde = ComplexMetrics.getSerdeForType(complexType); this.typeName = typeName;
serde = ComplexMetrics.getSerdeForType(typeName);
} }
@JsonProperty @JsonProperty
public GenericIndexed getColumn() public String getTypeName()
{ {
return column; return typeName;
} }
@Override @Override

View File

@ -79,6 +79,7 @@ import java.util.Iterator;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.TreeSet; import java.util.TreeSet;
/** /**
@ -784,13 +785,11 @@ public class IndexMerger
private static <T extends Comparable> ArrayList<T> mergeIndexed(final List<Iterable<T>> indexedLists) private static <T extends Comparable> ArrayList<T> mergeIndexed(final List<Iterable<T>> indexedLists)
{ {
LinkedHashSet<T> retVal = Sets.newLinkedHashSet(); Set<T> retVal = Sets.newTreeSet(Ordering.<T>natural().nullsFirst());
for (Iterable<T> indexedList : indexedLists) { for (Iterable<T> indexedList : indexedLists) {
for (T val : indexedList) { for (T val : indexedList) {
if (val != null) { retVal.add(val);
retVal.add(val);
}
} }
} }

View File

@ -19,12 +19,14 @@
package com.metamx.druid.index.v1; package com.metamx.druid.index.v1;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.common.io.Closeables; import com.google.common.io.Closeables;
import com.metamx.common.ISE; import com.metamx.common.ISE;
import com.metamx.druid.index.QueryableIndex; import com.metamx.druid.index.QueryableIndex;
import com.metamx.druid.index.column.BitmapIndex;
import com.metamx.druid.index.column.Column; import com.metamx.druid.index.column.Column;
import com.metamx.druid.index.column.ComplexColumn; import com.metamx.druid.index.column.ComplexColumn;
import com.metamx.druid.index.column.DictionaryEncodedColumn; import com.metamx.druid.index.column.DictionaryEncodedColumn;
@ -32,6 +34,7 @@ import com.metamx.druid.index.column.GenericColumn;
import com.metamx.druid.index.column.ValueType; import com.metamx.druid.index.column.ValueType;
import com.metamx.druid.kv.ArrayBasedIndexedInts; import com.metamx.druid.kv.ArrayBasedIndexedInts;
import com.metamx.druid.kv.ConciseCompressedIndexedInts; import com.metamx.druid.kv.ConciseCompressedIndexedInts;
import com.metamx.druid.kv.EmptyIndexedInts;
import com.metamx.druid.kv.Indexed; import com.metamx.druid.kv.Indexed;
import com.metamx.druid.kv.IndexedInts; import com.metamx.druid.kv.IndexedInts;
import com.metamx.druid.kv.IndexedIterable; import com.metamx.druid.kv.IndexedIterable;
@ -91,7 +94,18 @@ public class QueryableIndexIndexableAdapter implements IndexableAdapter
@Override @Override
public Indexed<String> getDimValueLookup(String dimension) public Indexed<String> getDimValueLookup(String dimension)
{ {
final DictionaryEncodedColumn dict = input.getColumn(dimension).getDictionaryEncoding(); final Column column = input.getColumn(dimension);
if (column == null) {
return null;
}
final DictionaryEncodedColumn dict = column.getDictionaryEncoding();
if (dict == null) {
return null;
}
return new Indexed<String>() return new Indexed<String>()
{ {
@Override @Override
@ -244,9 +258,18 @@ public class QueryableIndexIndexableAdapter implements IndexableAdapter
@Override @Override
public IndexedInts getInverteds(String dimension, String value) public IndexedInts getInverteds(String dimension, String value)
{ {
return new ConciseCompressedIndexedInts( final Column column = input.getColumn(dimension);
input.getColumn(dimension).getBitmapIndex().getConciseSet(value)
); if (column == null) {
return new EmptyIndexedInts();
}
final BitmapIndex bitmaps = column.getBitmapIndex();
if (bitmaps == null) {
return new EmptyIndexedInts();
}
return new ConciseCompressedIndexedInts(bitmaps.getConciseSet(value));
} }
@Override @Override