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 2015/03/14 01:01:26 UTC

[13/50] incubator-kylin git commit: enhance aggregation group generate logic, add mandatory removed logic

enhance aggregation group generate logic,add mandatory removed logic


Project: http://git-wip-us.apache.org/repos/asf/incubator-kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kylin/commit/38aac2c0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kylin/tree/38aac2c0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kylin/diff/38aac2c0

Branch: refs/heads/streaming
Commit: 38aac2c09360efe5df14c2229eafec15a506133f
Parents: 21dc31a
Author: jiazhong <ji...@ebay.com>
Authored: Fri Mar 6 18:20:21 2015 +0800
Committer: jiazhong <ji...@ebay.com>
Committed: Fri Mar 6 18:20:21 2015 +0800

----------------------------------------------------------------------
 webapp/app/js/controllers/cubeEdit.js           | 88 +++++++++++++-------
 webapp/app/js/controllers/cubeSchema.js         |  7 --
 webapp/app/js/model/jobListModel.js             | 11 ---
 .../cubeDesigner/advanced_settings.html         |  1 +
 4 files changed, 60 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/38aac2c0/webapp/app/js/controllers/cubeEdit.js
----------------------------------------------------------------------
diff --git a/webapp/app/js/controllers/cubeEdit.js b/webapp/app/js/controllers/cubeEdit.js
index e903f65..d1fb103 100755
--- a/webapp/app/js/controllers/cubeEdit.js
+++ b/webapp/app/js/controllers/cubeEdit.js
@@ -255,6 +255,17 @@ KylinApp.controller('CubeEditCtrl', function ($scope, $q, $routeParams, $locatio
         }
     }
 
+    $scope.updateMandatory = function(rowkey_column){
+        if(!rowkey_column.mandatory){
+            angular.forEach($scope.cubeMetaFrame.rowkey.aggregation_groups, function (group, index) {
+                   var index = group.indexOf(rowkey_column.column);
+                   if(index>-1){
+                       group.splice(index,1);
+                   }
+            });
+        }
+    }
+
     function reGenerateRowKey(){
         $log.log("reGen rowkey & agg group");
         var tmpRowKeyColumns = [];
@@ -328,6 +339,16 @@ KylinApp.controller('CubeEditCtrl', function ($scope, $q, $routeParams, $locatio
 
         });
 
+
+        //rm mandatory column from aggregation item
+        angular.forEach($scope.cubeMetaFrame.rowkey.rowkey_columns,function(value,index){
+                if(value.mandatory){
+                    tmpAggregationItems = _.filter(tmpAggregationItems,function(item){
+                           return item!=value.column;
+                    });
+                }
+        });
+
         var rowkeyColumns = $scope.cubeMetaFrame.rowkey.rowkey_columns;
         var newRowKeyColumns = sortSharedData(rowkeyColumns,tmpRowKeyColumns);
         var increasedColumns = increasedColumn(rowkeyColumns,tmpRowKeyColumns);
@@ -368,7 +389,10 @@ KylinApp.controller('CubeEditCtrl', function ($scope, $q, $routeParams, $locatio
 
         if($scope.cubeMode==="addNewCube"){
 
-          if(!tmpAggregationItems.length) return;
+          if(!tmpAggregationItems.length) {
+              $scope.cubeMetaFrame.rowkey.aggregation_groups=[];
+              return;
+          }
 
             var newUniqAggregationItem = [];
             angular.forEach(tmpAggregationItems, function (item, index) {
@@ -377,52 +401,58 @@ KylinApp.controller('CubeEditCtrl', function ($scope, $q, $routeParams, $locatio
                 }
             });
 
-          var hierarchyItems = [];
-          for(var m=0;m<hierarchyItemArray.length;m++){
-            for(var n=0;n<hierarchyItemArray[m].length;n++){
-              hierarchyItems.push(hierarchyItemArray[m][n]);
-            }
-          }
+          var hierarchyItems = hierarchyItemArray.join().split(",");
           var unHierarchyItems = increasedData(hierarchyItems,newUniqAggregationItem);
-//            hierarchyItems
+          //hierarchyItems
           var increasedDataGroups = sliceGroupItemToGroups(unHierarchyItems);
+          if(!hierarchyItemArray.length){
+              $scope.cubeMetaFrame.rowkey.aggregation_groups = increasedDataGroups;
+              return;
+          };
+
           var lastAggregationGroup = increasedDataGroups.length===0?[]:increasedDataGroups[increasedDataGroups.length-1];
+
           if(lastAggregationGroup.length<10){
             if(lastAggregationGroup.length+hierarchyItemArray.length<=10){
               lastAggregationGroup = lastAggregationGroup.concat(hierarchyItems);
               if(increasedDataGroups.length==0){
+                //case only hierarchy
                 increasedDataGroups[0]=lastAggregationGroup;
               }else{
                 increasedDataGroups[increasedDataGroups.length-1]=lastAggregationGroup;
               }
             }
             else{
-              var spareLength = 10-lastAggregationGroup.length;
-              var partialHierarchy =lastAggregationGroup.concat(hierarchyItemArray.slice(0,spareLength));
-              //add hierarchy to last group and make sure length less than 10
-              lastAggregationGroup = lastAggregationGroup.concat(partialHierarchy);
-              var spareHierarchy = hierarchyItemArray.slice(spareLength+1,hierarchyItemArray.length-1);
-              if(spareHierarchy.length){
-                lastAggregationGroup.push(spareHierarchy);
-              }
-              increasedDataGroups[increasedDataGroups.length-1]=lastAggregationGroup;
+                var cutIndex = 10-lastAggregationGroup.length;
+                var partialHierarchy =hierarchyItemArray.slice(0,cutIndex).join().split(",");
+                //add hierarchy to last group and make sure length less than 10
+                lastAggregationGroup = lastAggregationGroup.concat(partialHierarchy);
+                increasedDataGroups[increasedDataGroups.length-1]=lastAggregationGroup;
+                var leftHierarchy = hierarchyItemArray.slice(cutIndex);
+
+                var leftHierarchyLength = leftHierarchy.length;
+                var grpLength = parseInt(leftHierarchyLength/10);
+                if(leftHierarchyLength%10==0&&leftHierarchyLength!=0){
+                    grpLength--;
+                }
+                for(var i=0;i<=grpLength;i++){
+                    var hierAggGroupUnit = leftHierarchy.slice(i*10,(i+1)*10).join().split(",");
+                    increasedDataGroups.push(hierAggGroupUnit);
+                }
             }
           }
+          //lastAggregationGroup length >=10
           else{
-            if(hierarchyItemArray.length<=10){
-              increasedDataGroups.push(hierarchyItems);
-            }else{
-              var partialHierarchy =lastAggregationGroup.concat(hierarchyItemArray.slice(0,10));
-              //add hierarchy to last group and make sure length less than 10
-              increasedDataGroups.push(partialHierarchy);
-              var spareHierarchy = hierarchyItemArray.slice(11,hierarchyItemArray.length-1);
-              if(spareHierarchy.length){
-                increasedDataGroups.push(spareHierarchy);
+              var hierrachyArrayLength = hierarchyItemArray.length;
+              var grpLength = parseInt(hierrachyArrayLength/10);
+              if(hierrachyArrayLength%10==0&&hierrachyArrayLength!=0){
+                  grpLength--;
+              }
+              for(var i=0;i<=grpLength;i++){
+                   var hierAggGroupUnit = hierarchyItemArray.slice(i*10,(i+1)*10).join().split(",");
+                   increasedDataGroups.push(hierAggGroupUnit);
               }
-            }
           }
-
-
             //! here get the latest aggregation groups,only effect when add newCube
             $scope.cubeMetaFrame.rowkey.aggregation_groups = increasedDataGroups;
         }

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/38aac2c0/webapp/app/js/controllers/cubeSchema.js
----------------------------------------------------------------------
diff --git a/webapp/app/js/controllers/cubeSchema.js b/webapp/app/js/controllers/cubeSchema.js
index b0de094..d883b59 100755
--- a/webapp/app/js/controllers/cubeSchema.js
+++ b/webapp/app/js/controllers/cubeSchema.js
@@ -62,13 +62,6 @@ KylinApp.controller('CubeSchemaCtrl', function ($scope, QueryService, UserServic
             ModelService.get({model_name: $scope.cubeMetaFrame.model_name}, function (model) {
                 if (model) {
                     $scope.metaModel.model = model;
-
-                    //convert GMT mills ,to make sure partition date show GMT Date
-                    //should run only one time
-                    //if($scope.metaModel.model.partition_desc&&$scope.metaModel.model.partition_desc.partition_date_start)
-                    //{
-                    //    $scope.metaModel.model.partition_desc.partition_date_start+=new Date().getTimezoneOffset()*60000;
-                    //}
                 }
             });
 

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/38aac2c0/webapp/app/js/model/jobListModel.js
----------------------------------------------------------------------
diff --git a/webapp/app/js/model/jobListModel.js b/webapp/app/js/model/jobListModel.js
index 166e4e4..764791a 100755
--- a/webapp/app/js/model/jobListModel.js
+++ b/webapp/app/js/model/jobListModel.js
@@ -36,10 +36,6 @@ KylinApp.service('JobList',function(JobService,$q){
                 }
             });
 
-//            $scope.state.loading = false;
-//            if (angular.isDefined($scope.state.selectedJob)) {
-//                $scope.state.selectedJob = $scope.jobs[selectedJob.uuid];
-//            }
             defer.resolve(jobs.length);
         });
 
@@ -47,13 +43,6 @@ KylinApp.service('JobList',function(JobService,$q){
 
     };
 
-//    this.removeCube = function(cube){
-//        var cubeIndex = _this.cubes.indexOf(cube);
-//        if (cubeIndex > -1) {
-//            _this.cubes.splice(cubeIndex, 1);
-//        }
-//    }
-
     this.removeAll = function(){
         _this.jobs=[];
     };

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/38aac2c0/webapp/app/partials/cubeDesigner/advanced_settings.html
----------------------------------------------------------------------
diff --git a/webapp/app/partials/cubeDesigner/advanced_settings.html b/webapp/app/partials/cubeDesigner/advanced_settings.html
index e29e6a4..dfa05c6 100755
--- a/webapp/app/partials/cubeDesigner/advanced_settings.html
+++ b/webapp/app/partials/cubeDesigner/advanced_settings.html
@@ -119,6 +119,7 @@
                     <button type="button " ng-if="state.mode=='edit'"
                             class="btn btn-xs btn-default {{rowkey_column.mandatory? 'active':''}}"
                             ng-model="rowkey_column.mandatory"
+                            ng-click="updateMandatory(rowkey_column);"
                             btn-checkbox btn-checkbox-true="true" btn-checkbox-false="false">
                         {{rowkey_column.mandatory? 'Y':'N'}}
                     </button>