Luo Chen has submitted this change and it was merged. Change subject: [NO ISSUE][RT] Eliminate HashMap lookup during comparision ......................................................................
[NO ISSUE][RT] Eliminate HashMap lookup during comparision - user model changes: no - storage format changes: no - interface changes: no Details: - Eliminate the use of hash map to store type tags. Replace it with a simple TypeTag[] to improve performance. Change-Id: Ie5b8efdcb226a8818deaf57a6305a18107544feb Reviewed-on: https://asterix-gerrit.ics.uci.edu/2655 Sonar-Qube: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Reviewed-by: Michael Blow <mb...@apache.org> Tested-by: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Contrib: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Reviewed-by: Taewoo Kim <wangs...@gmail.com> Integration-Tests: Jenkins <jenk...@fulliautomatix.ics.uci.edu> --- M asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/EnumDeserializer.java 1 file changed, 6 insertions(+), 5 deletions(-) Approvals: Anon. E. Moose #1000171: Taewoo Kim: Looks good to me, approved Jenkins: Verified; No violations found; ; Verified Michael Blow: Looks good to me, approved diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/EnumDeserializer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/EnumDeserializer.java index 05f265c..f2d1f1a 100644 --- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/EnumDeserializer.java +++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/EnumDeserializer.java @@ -18,24 +18,25 @@ */ package org.apache.asterix.om.types; -import java.util.HashMap; -import java.util.Map; +import java.lang.reflect.Array; public class EnumDeserializer<E extends Enum<E> & IEnumSerializer> { public static final EnumDeserializer<ATypeTag> ATYPETAGDESERIALIZER = new EnumDeserializer<ATypeTag>(ATypeTag.class); - private Map<Byte, E> enumvalMap = new HashMap<Byte, E>(); + private final E[] enumvalMap; + @SuppressWarnings("unchecked") private EnumDeserializer(Class<E> enumClass) { + enumvalMap = (E[]) Array.newInstance(enumClass, Byte.MAX_VALUE); for (E constant : enumClass.getEnumConstants()) { - enumvalMap.put(constant.serialize(), constant); + enumvalMap[constant.serialize()] = constant; } } public E deserialize(byte value) { - return enumvalMap.get(value); + return enumvalMap[value]; } } -- To view, visit https://asterix-gerrit.ics.uci.edu/2655 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ie5b8efdcb226a8818deaf57a6305a18107544feb Gerrit-PatchSet: 2 Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-Owner: Luo Chen <cl...@uci.edu> Gerrit-Reviewer: Anon. E. Moose #1000171 Gerrit-Reviewer: Dmitry Lychagin <dmitry.lycha...@couchbase.com> Gerrit-Reviewer: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Gerrit-Reviewer: Luo Chen <cl...@uci.edu> Gerrit-Reviewer: Michael Blow <mb...@apache.org> Gerrit-Reviewer: Taewoo Kim <wangs...@gmail.com> Gerrit-Reviewer: Till Westmann <ti...@apache.org> Gerrit-Reviewer: abdullah alamoudi <bamou...@gmail.com>