mirror of https://github.com/apache/druid.git
Merge pull request #1064 from metamx/groupByHashIndexCoStore
Add a hash map for storing groupBy partition index
This commit is contained in:
commit
6993d84f02
|
@ -148,7 +148,9 @@ public class GroupByQueryEngine
|
||||||
private final BufferAggregator[] aggregators;
|
private final BufferAggregator[] aggregators;
|
||||||
private final PositionMaintainer positionMaintainer;
|
private final PositionMaintainer positionMaintainer;
|
||||||
|
|
||||||
private final TreeMap<ByteBuffer, Integer> positions;
|
private final Map<ByteBuffer, Integer> positions = Maps.newTreeMap();
|
||||||
|
// GroupBy queries tend to do a lot of reads from this. We co-store a hash map to make those reads go faster.
|
||||||
|
private final Map<ByteBuffer, Integer> positionsHash = Maps.newHashMap();
|
||||||
|
|
||||||
public RowUpdater(
|
public RowUpdater(
|
||||||
ByteBuffer metricValues,
|
ByteBuffer metricValues,
|
||||||
|
@ -159,8 +161,6 @@ public class GroupByQueryEngine
|
||||||
this.metricValues = metricValues;
|
this.metricValues = metricValues;
|
||||||
this.aggregators = aggregators;
|
this.aggregators = aggregators;
|
||||||
this.positionMaintainer = positionMaintainer;
|
this.positionMaintainer = positionMaintainer;
|
||||||
|
|
||||||
this.positions = Maps.newTreeMap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getNumRows()
|
public int getNumRows()
|
||||||
|
@ -168,7 +168,7 @@ public class GroupByQueryEngine
|
||||||
return positions.size();
|
return positions.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TreeMap<ByteBuffer, Integer> getPositions()
|
public Map<ByteBuffer, Integer> getPositions()
|
||||||
{
|
{
|
||||||
return positions;
|
return positions;
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,7 @@ public class GroupByQueryEngine
|
||||||
return retVal;
|
return retVal;
|
||||||
} else {
|
} else {
|
||||||
key.clear();
|
key.clear();
|
||||||
Integer position = positions.get(key);
|
Integer position = positionsHash.get(key);
|
||||||
int[] increments = positionMaintainer.getIncrements();
|
int[] increments = positionMaintainer.getIncrements();
|
||||||
int thePosition;
|
int thePosition;
|
||||||
|
|
||||||
|
@ -219,6 +219,7 @@ public class GroupByQueryEngine
|
||||||
}
|
}
|
||||||
|
|
||||||
positions.put(keyCopy, position);
|
positions.put(keyCopy, position);
|
||||||
|
positionsHash.put(keyCopy, position);
|
||||||
thePosition = position;
|
thePosition = position;
|
||||||
for (int i = 0; i < aggregators.length; ++i) {
|
for (int i = 0; i < aggregators.length; ++i) {
|
||||||
aggregators[i].init(metricValues, thePosition);
|
aggregators[i].init(metricValues, thePosition);
|
||||||
|
|
Loading…
Reference in New Issue