Fix a bug in GroupByQueryEngine (#6062)

This commit is contained in:
Roman Leventov 2018-07-30 16:39:38 -05:00 committed by Gian Merlino
parent 7f89c72932
commit f3595c93d9
1 changed files with 13 additions and 17 deletions

View File

@ -178,37 +178,33 @@ public class GroupByQueryEngine
return positions;
}
private List<ByteBuffer> updateValues(
ByteBuffer key,
List<DimensionSelector> dims
)
@Nullable
private List<ByteBuffer> updateValues(ByteBuffer key, List<DimensionSelector> dims)
{
if (dims.size() > 0) {
List<ByteBuffer> retVal = null;
List<ByteBuffer> unaggregatedBuffers = null;
final DimensionSelector dimSelector = dims.get(0);
final IndexedInts row = dimSelector.getRow();
final int rowSize = row.size();
if (rowSize == 0) {
ByteBuffer newKey = key.duplicate();
newKey.putInt(MISSING_VALUE);
unaggregatedBuffers = updateValues(newKey, dims.subList(1, dims.size()));
return updateValues(newKey, dims.subList(1, dims.size()));
} else {
List<ByteBuffer> retVal = null;
for (int i = 0; i < rowSize; i++) {
ByteBuffer newKey = key.duplicate();
int dimValue = row.get(i);
newKey.putInt(dimValue);
unaggregatedBuffers = updateValues(newKey, dims.subList(1, dims.size()));
List<ByteBuffer> unaggregatedBuffers = updateValues(newKey, dims.subList(1, dims.size()));
if (unaggregatedBuffers != null) {
if (retVal == null) {
retVal = Lists.newArrayList();
}
retVal.addAll(unaggregatedBuffers);
}
}
return retVal;
}
if (unaggregatedBuffers != null) {
if (retVal == null) {
retVal = Lists.newArrayList();
}
retVal.addAll(unaggregatedBuffers);
}
return retVal;
} else {
key.clear();
Integer position = positionsHash.get(key);
@ -222,7 +218,7 @@ public class GroupByQueryEngine
position = positionMaintainer.getNext();
if (position == null) {
return Lists.newArrayList(keyCopy);
return Collections.singletonList(keyCopy);
}
positions.put(keyCopy, position);