From 62a372c88caecd854db22c61c5060bf7d7afdb5d Mon Sep 17 00:00:00 2001 From: Ma Gang Date: Wed, 25 Oct 2017 18:25:12 +0800 Subject: [PATCH] APACHE-KYLIN-2969: Fix compatible issue of NumberDictionary Signed-off-by: Zhong --- .../java/org/apache/kylin/dict/Number2BytesConverter.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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, Serializab int maxDigitsBeforeDecimalPoint; - static final transient ThreadLocal LOCAL = new ThreadLocal(); + static final transient ThreadLocal> LOCAL = new ThreadLocal>(); static NumberBytesCodec getCodec(int maxDigitsBeforeDecimalPoint) { - NumberBytesCodec codec = LOCAL.get(); + Map 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; } -- 2.5.4 (Apple Git-61)