Revert "KYLIN-2010 retire 'time' and 'date' encoding, rollback to use dictionary"
This reverts commit a768b65d608cb6c1d0dbb7bcadf4adbd97a7b1f6. Project: http://git-wip-us.apache.org/repos/asf/kylin/repo Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/7d716dff Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/7d716dff Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/7d716dff Branch: refs/heads/1.5.x-CDH5.7 Commit: 7d716dff10326e8f906bdcb8d70c67fde18881d5 Parents: 5a049a5 Author: Yang Li <liy...@apache.org> Authored: Tue Sep 20 21:07:39 2016 +0800 Committer: Yang Li <liy...@apache.org> Committed: Tue Sep 20 21:07:39 2016 +0800 ---------------------------------------------------------------------- .../apache/kylin/cube/model/RowKeyColDesc.java | 15 ++++++++---- .../org/apache/kylin/dimension/DateDimEnc.java | 24 +++++++++----------- .../dimension/DimensionEncodingFactory.java | 2 ++ .../org/apache/kylin/dimension/TimeDimEnc.java | 24 +++++++++----------- 4 files changed, 35 insertions(+), 30 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kylin/blob/7d716dff/core-cube/src/main/java/org/apache/kylin/cube/model/RowKeyColDesc.java ---------------------------------------------------------------------- diff --git a/core-cube/src/main/java/org/apache/kylin/cube/model/RowKeyColDesc.java b/core-cube/src/main/java/org/apache/kylin/cube/model/RowKeyColDesc.java index 296c1a3..8d4f862 100644 --- a/core-cube/src/main/java/org/apache/kylin/cube/model/RowKeyColDesc.java +++ b/core-cube/src/main/java/org/apache/kylin/cube/model/RowKeyColDesc.java @@ -26,6 +26,7 @@ import org.apache.kylin.dimension.DictionaryDimEnc; import org.apache.kylin.dimension.DimensionEncoding; import org.apache.kylin.dimension.DimensionEncodingFactory; import org.apache.kylin.dimension.TimeDimEnc; +import org.apache.kylin.metadata.datatype.DataType; import org.apache.kylin.metadata.model.TblColRef; import com.fasterxml.jackson.annotation.JsonAutoDetect; @@ -37,8 +38,8 @@ import com.google.common.base.Preconditions; /** * @author yangli9 + * */ -@SuppressWarnings("deprecation") @JsonAutoDetect(fieldVisibility = Visibility.NONE, getterVisibility = Visibility.NONE, isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE) public class RowKeyColDesc { @@ -74,9 +75,15 @@ public class RowKeyColDesc { if (!DimensionEncodingFactory.isVaildEncoding(this.encodingName)) throw new IllegalArgumentException("Not supported row key col encoding: '" + this.encoding + "'"); - // convert date/time encoding to dictionary, because encoding does not remember date pattern and cannot format string correctly at query time - if (DateDimEnc.ENCODING_NAME.equals(encodingName) || TimeDimEnc.ENCODING_NAME.equals(encodingName)) { - throw new IllegalStateException("Encoding '" + DateDimEnc.ENCODING_NAME + "' and '" + TimeDimEnc.ENCODING_NAME + "' are deprecated, please use dictionary encoding instead"); + // convert date/time dictionary to DimensionEncoding implicitly, date/time dictionary is deprecated + if (DictionaryDimEnc.ENCODING_NAME.equals(encodingName)) { + DataType type = colRef.getType(); + if (type.isDate()) { + encoding = encodingName = DateDimEnc.ENCODING_NAME; + } + if (type.isTime() || type.isTimestamp() || type.isDatetime()) { + encoding = encodingName = TimeDimEnc.ENCODING_NAME; + } } } http://git-wip-us.apache.org/repos/asf/kylin/blob/7d716dff/core-metadata/src/main/java/org/apache/kylin/dimension/DateDimEnc.java ---------------------------------------------------------------------- diff --git a/core-metadata/src/main/java/org/apache/kylin/dimension/DateDimEnc.java b/core-metadata/src/main/java/org/apache/kylin/dimension/DateDimEnc.java index 3992ed7..79e00ce 100644 --- a/core-metadata/src/main/java/org/apache/kylin/dimension/DateDimEnc.java +++ b/core-metadata/src/main/java/org/apache/kylin/dimension/DateDimEnc.java @@ -20,8 +20,6 @@ package org.apache.kylin.dimension; /** * This encoding is meant to be IDENTICAL to DateStrDictionary for 100% backward compatibility. - * - * @deprecated for now, please use dictionary */ public class DateDimEnc extends AbstractDateDimEnc { private static final long serialVersionUID = 1L; @@ -30,17 +28,17 @@ public class DateDimEnc extends AbstractDateDimEnc { public static final String ENCODING_NAME = "date"; -// public static class Factory extends DimensionEncodingFactory { -// @Override -// public String getSupportedEncodingName() { -// return ENCODING_NAME; -// } -// -// @Override -// public DimensionEncoding createDimensionEncoding(String encodingName, String[] args) { -// return new DateDimEnc(); -// } -// }; + public static class Factory extends DimensionEncodingFactory { + @Override + public String getSupportedEncodingName() { + return ENCODING_NAME; + } + + @Override + public DimensionEncoding createDimensionEncoding(String encodingName, String[] args) { + return new DateDimEnc(); + } + }; public DateDimEnc() { super(3, new IMillisCodec() { http://git-wip-us.apache.org/repos/asf/kylin/blob/7d716dff/core-metadata/src/main/java/org/apache/kylin/dimension/DimensionEncodingFactory.java ---------------------------------------------------------------------- diff --git a/core-metadata/src/main/java/org/apache/kylin/dimension/DimensionEncodingFactory.java b/core-metadata/src/main/java/org/apache/kylin/dimension/DimensionEncodingFactory.java index bc4bf5c..739fa25 100644 --- a/core-metadata/src/main/java/org/apache/kylin/dimension/DimensionEncodingFactory.java +++ b/core-metadata/src/main/java/org/apache/kylin/dimension/DimensionEncodingFactory.java @@ -77,6 +77,8 @@ public abstract class DimensionEncodingFactory { map.put(IntegerDimEnc.ENCODING_NAME, new IntegerDimEnc.Factory()); map.put(SlimLongDimEnc.ENCODING_NAME, new SlimLongDimEnc.Factory()); map.put(FixedLenHexDimEnc.ENCODING_NAME, new FixedLenHexDimEnc.Factory()); + map.put(DateDimEnc.ENCODING_NAME, new DateDimEnc.Factory()); + map.put(TimeDimEnc.ENCODING_NAME, new TimeDimEnc.Factory()); // custom encodings String[] clsNames = KylinConfig.getInstanceFromEnv().getCubeDimensionCustomEncodingFactories(); http://git-wip-us.apache.org/repos/asf/kylin/blob/7d716dff/core-metadata/src/main/java/org/apache/kylin/dimension/TimeDimEnc.java ---------------------------------------------------------------------- diff --git a/core-metadata/src/main/java/org/apache/kylin/dimension/TimeDimEnc.java b/core-metadata/src/main/java/org/apache/kylin/dimension/TimeDimEnc.java index 245f513..8c66d5d 100644 --- a/core-metadata/src/main/java/org/apache/kylin/dimension/TimeDimEnc.java +++ b/core-metadata/src/main/java/org/apache/kylin/dimension/TimeDimEnc.java @@ -20,25 +20,23 @@ package org.apache.kylin.dimension; /** * This encoding is meant to be IDENTICAL to TimeStrDictionary for 100% backward compatibility. - * - * @deprecated for now, please use dictionary */ public class TimeDimEnc extends AbstractDateDimEnc { private static final long serialVersionUID = 1L; public static final String ENCODING_NAME = "time"; -// public static class Factory extends DimensionEncodingFactory { -// @Override -// public String getSupportedEncodingName() { -// return ENCODING_NAME; -// } -// -// @Override -// public DimensionEncoding createDimensionEncoding(String encodingName, String[] args) { -// return new TimeDimEnc(); -// } -// }; + public static class Factory extends DimensionEncodingFactory { + @Override + public String getSupportedEncodingName() { + return ENCODING_NAME; + } + + @Override + public DimensionEncoding createDimensionEncoding(String encodingName, String[] args) { + return new TimeDimEnc(); + } + }; public TimeDimEnc() { super(4, new IMillisCodec() {