Skip to content

Commit

Permalink
Reverting the change from apache#5291
Browse files Browse the repository at this point in the history
For the use cases with high qps with low selectivity queries,
initializing the hashmap with the size of the upperbound incurred
more penalty as opposed to improving performance by reducing
the number of hashmap resizes.
  • Loading branch information
Seunghyun Lee committed May 20, 2020
1 parent bfd263a commit 2601c01
Showing 1 changed file with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@ public DictionaryBasedGroupKeyGenerator(TransformOperator transformOperator,

if (longOverflow) {
_globalGroupIdUpperBound = numGroupsLimit;
_rawKeyHolder = new ArrayMapBasedHolder(_globalGroupIdUpperBound);
_rawKeyHolder = new ArrayMapBasedHolder();
} else {
if (cardinalityProduct > Integer.MAX_VALUE) {
_globalGroupIdUpperBound = numGroupsLimit;
_rawKeyHolder = new LongMapBasedHolder(_globalGroupIdUpperBound);
_rawKeyHolder = new LongMapBasedHolder();
} else {
_globalGroupIdUpperBound = Math.min((int) cardinalityProduct, numGroupsLimit);
if (cardinalityProduct > arrayBasedThreshold) {
_rawKeyHolder = new IntMapBasedHolder(_globalGroupIdUpperBound);
_rawKeyHolder = new IntMapBasedHolder();
} else {
_rawKeyHolder = new ArrayBasedHolder();
}
Expand Down Expand Up @@ -259,12 +259,11 @@ public void remove() {
}

private class IntMapBasedHolder implements RawKeyHolder {
private final Int2IntOpenHashMap _rawKeyToGroupIdMap;
private final Int2IntOpenHashMap _rawKeyToGroupIdMap = new Int2IntOpenHashMap();

private int _numGroups = 0;

public IntMapBasedHolder(int initialSize) {
_rawKeyToGroupIdMap = new Int2IntOpenHashMap(initialSize);
public IntMapBasedHolder() {
_rawKeyToGroupIdMap.defaultReturnValue(INVALID_ID);
}

Expand Down Expand Up @@ -438,12 +437,11 @@ private String getGroupKey(int rawKey) {
}

private class LongMapBasedHolder implements RawKeyHolder {
private final Long2IntOpenHashMap _rawKeyToGroupIdMap;
private final Long2IntOpenHashMap _rawKeyToGroupIdMap = new Long2IntOpenHashMap();

private int _numGroups = 0;

public LongMapBasedHolder(int initialSize) {
_rawKeyToGroupIdMap = new Long2IntOpenHashMap(initialSize);
public LongMapBasedHolder() {
_rawKeyToGroupIdMap.defaultReturnValue(INVALID_ID);
}

Expand Down Expand Up @@ -609,12 +607,11 @@ private String getGroupKey(long rawKey) {
}

private class ArrayMapBasedHolder implements RawKeyHolder {
private final Object2IntOpenHashMap<IntArray> _rawKeyToGroupIdMap;
private final Object2IntOpenHashMap<IntArray> _rawKeyToGroupIdMap = new Object2IntOpenHashMap<>();

private int _numGroups = 0;

public ArrayMapBasedHolder(int initialSize) {
_rawKeyToGroupIdMap = new Object2IntOpenHashMap<>(initialSize);
public ArrayMapBasedHolder() {
_rawKeyToGroupIdMap.defaultReturnValue(INVALID_ID);
}

Expand Down

0 comments on commit 2601c01

Please sign in to comment.