APACHE-KYLIN-2969: Fix compatible issue of NumberDictionary Signed-off-by: Zhong <nju_y...@apache.org> Signed-off-by: lidongsjtu <lid...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/kylin/repo Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/1d0c4d4f Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/1d0c4d4f Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/1d0c4d4f Branch: refs/heads/master Commit: 1d0c4d4fddfc0d858b2173b0c37c8dc5f6b3d0bc Parents: 16f7ade Author: Ma Gang <mg4w...@163.com> Authored: Wed Oct 25 18:25:12 2017 +0800 Committer: lidongsjtu <lid...@apache.org> Committed: Fri Nov 3 22:58:32 2017 +0800 ---------------------------------------------------------------------- .../org/apache/kylin/dict/Number2BytesConverter.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kylin/blob/1d0c4d4f/core-dictionary/src/main/java/org/apache/kylin/dict/Number2BytesConverter.java ---------------------------------------------------------------------- diff --git a/core-dictionary/src/main/java/org/apache/kylin/dict/Number2BytesConverter.java b/core-dictionary/src/main/java/org/apache/kylin/dict/Number2BytesConverter.java index 397ca9f..09c4c81 100644 --- a/core-dictionary/src/main/java/org/apache/kylin/dict/Number2BytesConverter.java +++ b/core-dictionary/src/main/java/org/apache/kylin/dict/Number2BytesConverter.java @@ -19,9 +19,12 @@ package org.apache.kylin.dict; import java.io.Serializable; import java.math.BigDecimal; +import java.util.Map; import org.apache.kylin.common.util.Bytes; +import com.google.common.collect.Maps; + /** * Created by xiefan on 17-1-20. */ @@ -35,13 +38,18 @@ public class Number2BytesConverter implements BytesConverter<String>, Serializab int maxDigitsBeforeDecimalPoint; - static final transient ThreadLocal<NumberBytesCodec> LOCAL = new ThreadLocal<NumberBytesCodec>(); + static final transient ThreadLocal<Map<Integer, NumberBytesCodec>> LOCAL = new ThreadLocal<Map<Integer, NumberBytesCodec>>(); static NumberBytesCodec getCodec(int maxDigitsBeforeDecimalPoint) { - NumberBytesCodec codec = LOCAL.get(); + Map<Integer, NumberBytesCodec> codecMap = LOCAL.get(); + if (codecMap == null) { + codecMap = Maps.newHashMap(); + LOCAL.set(codecMap); + } + NumberBytesCodec codec = codecMap.get(maxDigitsBeforeDecimalPoint); if (codec == null) { codec = new NumberBytesCodec(maxDigitsBeforeDecimalPoint); - LOCAL.set(codec); + codecMap.put(maxDigitsBeforeDecimalPoint, codec); } return codec; }