wangxiaojing123 commented on a change in pull request #1056: KYLIN-4336 Global 
domain dict for MR build engine
URL: https://github.com/apache/kylin/pull/1056#discussion_r375105626
 
 

 ##########
 File path: 
core-cube/src/main/java/org/apache/kylin/cube/model/CubeDescTiretreeGlobalDomainDictUtil.java
 ##########
 @@ -0,0 +1,164 @@
+/*
+ * 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.cube.model;
+
+import com.google.common.collect.ImmutableList;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.kylin.common.KylinConfig;
+import org.apache.kylin.cube.CubeInstance;
+import org.apache.kylin.cube.CubeManager;
+import org.apache.kylin.cube.CubeSegment;
+import org.apache.kylin.metadata.model.DataModelDesc;
+import org.apache.kylin.metadata.model.DataModelManager;
+import org.apache.kylin.metadata.model.TableDesc;
+import org.apache.kylin.metadata.model.TableRef;
+import org.apache.kylin.metadata.model.TblColRef;
+import org.apache.kylin.source.SourceManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Objects;
+import java.util.Set;
+
+public class CubeDescTiretreeGlobalDomainDictUtil {
+    private static final Logger logger = 
LoggerFactory.getLogger(CubeDescTiretreeGlobalDomainDictUtil.class);
+
+    /**
+     * get reuse global tiretree global dic path
+     * @param tblColRef
+     * @param cubeDesc
+     * @return
+     */
+    public static String globalReuseDictPath(KylinConfig config, TblColRef 
tblColRef, CubeDesc cubeDesc) {
+        String globalResumeDictPath = null;
+        List<GlobalDict> globalDicts = cubeDesc.listDomainDict();
+        DataModelManager metadataManager = 
DataModelManager.getInstance(config);
+        CubeManager cubeManager = 
CubeManager.getInstance(KylinConfig.getInstanceFromEnv());
+        for (GlobalDict dict : globalDicts) {
+            if 
(dict.getSrc().getIdentity().equalsIgnoreCase(tblColRef.getIdentity())) {
+                String model = dict.getModel();
+                String cube = dict.getCube();
+                logger.info("cube:{} column:{} tiretree global domain dic 
reuse model:{} cube{} column:{} ", cubeDesc.getName() , tblColRef.getName(), 
model, cube, dict.getDesc());
+
+                DataModelDesc dataModel = 
metadataManager.getDataModelDesc(model);
+                if (Objects.isNull(dataModel)) {
+                    logger.error("get cube:{} column:{} tiretree global domain 
dic reuse DataModelDesc error", cubeDesc.getName(), tblColRef.getName());
+                    return null;
+                }
+
+                CubeInstance cubeInstance = cubeManager.getCube(cube);
+                CubeSegment cubeSegment = cubeInstance.getLatestReadySegment();
+
+                TblColRef colRef = dataModel.findColumn(dict.getDesc());
+                if(Objects.isNull(colRef)){
+                    logger.error("get cube:{} column:{} tiretree global domain 
dic TblColRef error");
+                    return null;
+                }
+
+                globalResumeDictPath = cubeSegment.getDictResPath(colRef);
+
+                if (StringUtils.isBlank(globalResumeDictPath)) {
+                    logger.error("get cube:{} column:{} tiretree global domain 
dic resume dict path error");
+                }
+                logger.error("get cube:{} column:{} tiretree global domain dic 
resume dict path is {}", globalResumeDictPath);
+                break;
+            }
+        }
+        return globalResumeDictPath;
+    }
+
+
+
+
+    /**
+     * add resuce global tiretree global dic for baseid job
+     * @param cubeDesc
+     * @param dumpList
+     */
+    public static void cuboidJob(CubeDesc cubeDesc, Set<String> dumpList) {
+        logger.info("cube {} start to add global domain dic", 
cubeDesc.getName());
+        CubeManager cubeManager = 
CubeManager.getInstance(KylinConfig.getInstanceFromEnv());
+        DataModelManager metadataManager 
=DataModelManager.getInstance(KylinConfig.getInstanceFromEnv());
+
+        cubeManager.getCube(cubeDesc.getName());
 
 Review comment:
   Thanks ,I will fix it.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to