You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by li...@apache.org on 2016/03/22 08:16:46 UTC
kylin git commit: KYLIN-1492 ammend missing file
Repository: kylin
Updated Branches:
refs/heads/master 004a25e97 -> e3383dd8f
KYLIN-1492 ammend missing file
Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/e3383dd8
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/e3383dd8
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/e3383dd8
Branch: refs/heads/master
Commit: e3383dd8ffea2b1299c5e997f5138d8c72c71de8
Parents: 004a25e
Author: Li Yang <li...@apache.org>
Authored: Tue Mar 22 15:15:52 2016 +0800
Committer: Li Yang <li...@apache.org>
Committed: Tue Mar 22 15:16:31 2016 +0800
----------------------------------------------------------------------
.../dimension/DimensionEncodingFactory.java | 79 ++++++++++++++++++++
1 file changed, 79 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kylin/blob/e3383dd8/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
new file mode 100644
index 0000000..fa639c6
--- /dev/null
+++ b/core-metadata/src/main/java/org/apache/kylin/dimension/DimensionEncodingFactory.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.apache.kylin.dimension;
+
+import java.util.Map;
+
+import org.apache.kylin.common.KylinConfig;
+import org.apache.kylin.common.util.ClassUtil;
+
+import com.google.common.collect.Maps;
+
+public abstract class DimensionEncodingFactory {
+
+ private static Map<String, DimensionEncodingFactory> factoryMap;
+
+ /** Create a DimensionEncoding instance, with inputs corresponding to RowKeyColDesc.encodingName and RowKeyColDesc.encodingArgs. */
+ public static DimensionEncoding create(String encodingName, String[] args) {
+ if (factoryMap == null) {
+ initFactoryMap();
+ }
+
+ DimensionEncodingFactory factory = factoryMap.get(encodingName);
+ if (factory == null) {
+ throw new IllegalArgumentException("Unknown dimension encoding name " + encodingName //
+ + " (note '" + DictionaryDimEnc.ENCODING_NAME + "' is not handled by factory)");
+ }
+
+ return factory.createDimensionEncoding(encodingName, args);
+ }
+
+ public static boolean isVaildEncoding(String encodingName) {
+ if (factoryMap == null) {
+ initFactoryMap();
+ }
+
+ // note dictionary is a special case
+ return DictionaryDimEnc.ENCODING_NAME.equals(encodingName) || factoryMap.containsKey(encodingName);
+ }
+
+ private synchronized static void initFactoryMap() {
+ if (factoryMap == null) {
+ Map<String, DimensionEncodingFactory> map = Maps.newConcurrentMap();
+
+ // built-in encodings, note dictionary is a special case
+ map.put(FixedLenDimEnc.ENCODING_NAME, FixedLenDimEnc.getFactory());
+
+ // custom encodings
+ String[] clsNames = KylinConfig.getInstanceFromEnv().getCubeDimensionCustomEncodingFactories();
+ for (String clsName : clsNames) {
+ DimensionEncodingFactory factory = (DimensionEncodingFactory) ClassUtil.newInstance(clsName);
+ map.put(factory.getSupportedEncodingName(), factory);
+ }
+
+ factoryMap = map;
+ }
+ }
+
+ /** Return the supported encoding name, corresponds to RowKeyColDesc.encodingName */
+ abstract public String getSupportedEncodingName();
+
+ /** Create a DimensionEncoding instance, with inputs corresponding to RowKeyColDesc.encodingName and RowKeyColDesc.encodingArgs */
+ abstract public DimensionEncoding createDimensionEncoding(String encodingName, String[] args);
+}