Repository: kylin Updated Branches: refs/heads/yang21 61dd19f6f -> d4715b559
encoding at version tips Signed-off-by: Hongbin Ma <mahong...@apache.org> Project: http://git-wip-us.apache.org/repos/asf/kylin/repo Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/577e6be2 Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/577e6be2 Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/577e6be2 Branch: refs/heads/yang21 Commit: 577e6be2d08faf821061d037df8f1576ec2c5d57 Parents: 61dd19f Author: luguosheng <550175...@qq.com> Authored: Sat Nov 19 14:50:52 2016 +0800 Committer: Hongbin Ma <mahong...@apache.org> Committed: Tue Nov 22 09:38:59 2016 +0800 ---------------------------------------------------------------------- webapp/app/js/controllers/cubeAdvanceSetting.js | 68 ++++++++----- webapp/app/js/controllers/cubeEdit.js | 90 ++++++++++------- webapp/app/js/controllers/cubeMeasures.js | 101 +++++++++++++------ webapp/app/js/services/cubes.js | 2 +- webapp/app/js/utils/utils.js | 45 +++++++++ 5 files changed, 211 insertions(+), 95 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kylin/blob/577e6be2/webapp/app/js/controllers/cubeAdvanceSetting.js ---------------------------------------------------------------------- diff --git a/webapp/app/js/controllers/cubeAdvanceSetting.js b/webapp/app/js/controllers/cubeAdvanceSetting.js index be90f65..f2b36fe 100644 --- a/webapp/app/js/controllers/cubeAdvanceSetting.js +++ b/webapp/app/js/controllers/cubeAdvanceSetting.js @@ -19,34 +19,46 @@ 'use strict'; KylinApp.controller('CubeAdvanceSettingCtrl', function ($scope, $modal,cubeConfig,MetaModel,cubesManager,CubeDescModel,SweetAlert) { - $scope.cubesManager = cubesManager; - - + $scope.cubesManager = cubesManager; + $scope.getTypeVersion=function(typename){ + var searchResult=/\[v(\d+)\]/.exec(typename); + if(searchResult&&searchResult.length){ + return searchResult.length&&searchResult[1]||1; + }else{ + return 1; + } + } + $scope.removeVersion=function(typename){ + if(typename){ + return typename.replace(/\[v\d+\]/g,""); + } + return ""; + } + var needLengthKeyList=['fixed_length','fixed_length_hex','int','integer']; //rowkey $scope.convertedRowkeys = []; angular.forEach($scope.cubeMetaFrame.rowkey.rowkey_columns,function(item){ //var _isDictionaries = item.encoding === "dict"?"true":"false"; - var _isFixedLength = item.encoding.substring(0,12) === "fixed_length"?"true":"false";//fixed_length:12 - var _isIntLength = item.encoding.substring(0,3) === "int"?"true":"false";//fixed_length:12 + //var version=$scope.getTypeVersion(encoding); + item.encoding=$scope.removeVersion(item.encoding); + //var _isFixedLength = item.encoding.substring(0,12) === "fixed_length"?"true":"false";//fixed_length:12 + //var _isIntegerLength = item.encoding.substring(0,7) === "integer"?"true":"false"; + //var _isIntLength = item.encoding.substring(0,3) === "int"?"true":"false"; var _encoding = item.encoding; var _valueLength ; - if(_isFixedLength !=="false"){ - _valueLength = item.encoding.substring(13,item.encoding.length); - _encoding = "fixed_length"; - } - if(_isIntLength!="false"){ - _valueLength = item.encoding.substring(4,item.encoding.length); - _encoding = "int"; + var baseKey=item.encoding.replace(/:\d+/,''); + if(needLengthKeyList.indexOf(baseKey)>=-1){ + var result=/:(\d+)/.exec(item.encoding); + _valueLength=result?result[1]:0; } - + _encoding=baseKey; var rowkeyObj = { column:item.column, - encoding:_encoding, + encoding:_encoding+(item.encoding_version?"[v"+item.encoding_version+"]":"[v1]"), valueLength:_valueLength, - isShardBy:item.isShardBy - + isShardBy:item.isShardBy, + encoding_version:item.encoding_version||1 } - $scope.convertedRowkeys.push(rowkeyObj); }) @@ -55,26 +67,26 @@ KylinApp.controller('CubeAdvanceSettingCtrl', function ($scope, $modal,cubeConfi $scope.rule={ shardColumnAvailable:true } - + var checkedlen=$scope.cubeMetaFrame.rowkey.rowkey_columns&&$scope.cubeMetaFrame.rowkey.rowkey_columns.length||0; + for(var i=0;i<checkedlen;i++){ + $scope.cubeMetaFrame.rowkey.rowkey_columns[i].encoding_version=$scope.cubeMetaFrame.rowkey.rowkey_columns[i].encoding_version||1; + } $scope.refreshRowKey = function(list,index,item,checkShard){ var encoding; var column = item.column; var isShardBy = item.isShardBy; - if(item.encoding!=="dict" && item.encoding!=="date"&& item.encoding!=="time"){ - if(item.encoding=="fixed_length" && item.valueLength){ - encoding = "fixed_length:"+item.valueLength; - } - else if(item.encoding=="int" && item.valueLength){ - encoding = "int:"+item.valueLength; - }else{ - encoding = item.encoding; - } + var version=$scope.getTypeVersion(item.encoding); + var encodingType=$scope.removeVersion(item.encoding); + + if(needLengthKeyList.indexOf(encodingType)>=-1){ + encoding = encodingType+":"+item.valueLength; }else{ - encoding = item.encoding; + encoding = encodingType; item.valueLength=0; } $scope.cubeMetaFrame.rowkey.rowkey_columns[index].column = column; $scope.cubeMetaFrame.rowkey.rowkey_columns[index].encoding = encoding; + $scope.cubeMetaFrame.rowkey.rowkey_columns[index].encoding_version =version; $scope.cubeMetaFrame.rowkey.rowkey_columns[index].isShardBy = isShardBy; if(checkShard == true){ $scope.checkShardByColumn(); http://git-wip-us.apache.org/repos/asf/kylin/blob/577e6be2/webapp/app/js/controllers/cubeEdit.js ---------------------------------------------------------------------- diff --git a/webapp/app/js/controllers/cubeEdit.js b/webapp/app/js/controllers/cubeEdit.js index e9bd93e..5c5d9c7 100755 --- a/webapp/app/js/controllers/cubeEdit.js +++ b/webapp/app/js/controllers/cubeEdit.js @@ -19,7 +19,7 @@ 'use strict'; -KylinApp.controller('CubeEditCtrl', function ($scope, $q, $routeParams, $location, $templateCache, $interpolate, MessageService, TableService, CubeDescService, CubeService, loadingRequest, SweetAlert, $log, cubeConfig, CubeDescModel, MetaModel, TableModel, ModelDescService, modelsManager, cubesManager, ProjectModel, StreamingModel, StreamingService) { +KylinApp.controller('CubeEditCtrl', function ($scope, $q, $routeParams, $location, $templateCache, $interpolate, MessageService, TableService, CubeDescService, CubeService, loadingRequest, SweetAlert, $log, cubeConfig, CubeDescModel, MetaModel, TableModel, ModelDescService, modelsManager, cubesManager, ProjectModel, StreamingModel, StreamingService,VdmUtil) { $scope.cubeConfig = cubeConfig; $scope.metaModel = {}; $scope.modelsManager = modelsManager; @@ -40,48 +40,70 @@ KylinApp.controller('CubeEditCtrl', function ($scope, $q, $routeParams, $locatio supportedEncoding:[] } CubeService.getValidEncodings({}, function (encodings) { - for(var i =0;i<encodings.length;i++){ - var value = encodings[i]; - var name = value; - if(value=="int"){ - name = "int (deprecated)"; + if(encodings){ + delete encodings.$promise; + delete encodings.$resolved; + for(var i in encodings) + if(encodings.hasOwnProperty(i)){ + var value = i + var name = value; + var typeVersion=+encodings[i]; + if(value=="int"){ + name = "int(deprecated)"; + } + if(/\d+/.test(""+typeVersion)&&typeVersion>1){ + for(var s=1;s<=typeVersion;s++){ + $scope.store.supportedEncoding.push({ + "name":name+" (v"+s+")"+(s==typeVersion&&typeVersion>1?"(suggest)":""), + "value":value+"[v"+s+"]", + "version":typeVersion, + "baseValue":value, + "suggest":s==typeVersion + + }); + } + }else { + $scope.store.supportedEncoding.push({ + "name": name, + "value": value+"[v1]", + "encoding_version":1, + "version":typeVersion, + "baseValue":value, + "suggest":true + }); + } + } } - $scope.store.supportedEncoding.push({ - "name":name, - "value":value - }); - } },function(e){ $scope.store.supportedEncoding = $scope.cubeConfig.encodings; }) $scope.getEncodings =function (name){ - var type = TableModel.columnNameTypeMap[name]; - var encodings = $scope.store.supportedEncoding; - if(!type){ - return encodings; - } - var filterEncodings = []; - for(var i = 0;i<encodings.length;i++){ - var encodingValue = encodings[i].value; - if(encodingValue == "fixed_length_hex" ){ - if(type.indexOf("varchar")!==-1){ - filterEncodings.push(encodings[i]); - } - }else if(encodingValue == "date"){ - if(type=="date"){ - filterEncodings.push(encodings[i]); + var type = TableModel.columnNameTypeMap[name]||''; + var encodings =[]; + for(var k=0;k<$scope.store.supportedEncoding.length;k++){ + encodings.push($scope.store.supportedEncoding[k]); + } + if($scope.isEdit){ + for(var s=0;s<$scope.cubeMetaFrame.rowkey.rowkey_columns.length;s++){ + if(name==$scope.cubeMetaFrame.rowkey.rowkey_columns[s].column){ + var version=$scope.cubeMetaFrame.rowkey.rowkey_columns[s].encoding_version; + encodings=VdmUtil.changeObjectListValueByFilter(encodings,'value',$scope.cubeMetaFrame.rowkey.rowkey_columns[s].encoding.replace(/:\d+/,"")+(version?"[v"+version+"]":"[v1]"),'suggest',true) } - }else if(encodingValue == "time"){ - if(type=="time"||type=="datetime"||type=="timestamp"){ - filterEncodings.push(encodings[i]); - } - }else{ - filterEncodings.push(encodings[i]); } } - - return filterEncodings; + //if(type.indexOf("varchar")!==-1){ + // filterEncodings=VdmUtil.getObjectListByFilterVal(encodings,'baseValue',['fixed_length_hex','fixed_length'],'suggest',true); + //} + //else if(type=="date"){ + // filterEncodings = VdmUtil.getObjectListByFilterVal(encodings, 'baseValue', 'date','suggest',true); + //}else if(type=="time"||type=="datetime"||type=="timestamp"){ + // filterEncodings = VdmUtil.getObjectListByFilterVal(encodings, 'baseValue', 'time','suggest',true); + //}else{ + encodings=VdmUtil.getObjectListByFilterVal(encodings, '', '','suggest',true); + //} + + return encodings; } $scope.getColumnsByTable = function (tableName) { http://git-wip-us.apache.org/repos/asf/kylin/blob/577e6be2/webapp/app/js/controllers/cubeMeasures.js ---------------------------------------------------------------------- diff --git a/webapp/app/js/controllers/cubeMeasures.js b/webapp/app/js/controllers/cubeMeasures.js index 2f191f9..2358167 100644 --- a/webapp/app/js/controllers/cubeMeasures.js +++ b/webapp/app/js/controllers/cubeMeasures.js @@ -18,7 +18,7 @@ 'use strict'; -KylinApp.controller('CubeMeasuresCtrl', function ($scope, $modal,MetaModel,cubesManager,CubeDescModel,SweetAlert) { +KylinApp.controller('CubeMeasuresCtrl', function ($scope, $modal,MetaModel,cubesManager,CubeDescModel,SweetAlert,VdmUtil,TableModel) { $scope.num=0; $scope.convertedColumns=[]; $scope.groupby=[]; @@ -29,7 +29,32 @@ KylinApp.controller('CubeMeasuresCtrl', function ($scope, $modal,MetaModel,cubes } }; $scope.initUpdateMeasureStatus(); + var needLengthKeyList=['fixed_length','fixed_length_hex','int','integer']; + $scope.removeVersion=function(typename){ + if(typename){ + return typename.replace(/\[v\d+\]/g,""); + } + return ""; + } + $scope.getTypeVersion=function(typename){ + var searchResult=/\[v(\d+)\]/.exec(typename); + if(searchResult&&searchResult.length){ + return searchResult.length&&searchResult[1]||1; + }else{ + return 1; + } + } + $scope.getEncodings =function (name){ + console.log(name); + var type = TableModel.columnNameTypeMap[name]||''; + var encodings =$scope.store.supportedEncoding.slice(0),filterEncodings=[]; + if($scope.isEdit){ + var version = $scope.newMeasure.function.configuration['topn.encoding_version.' +name] || 1; + filterEncodings = VdmUtil.changeObjectListValueByFilter(encodings, 'value', $scope.newMeasure.function.configuration['topn.encoding.' +name].replace(/:\d+/, "") + (version ? "[v" + version + "]" : "[v1]"), 'suggest', true); + } + return VdmUtil.getObjectListByFilterVal(filterEncodings, '', '','suggest',true); + } $scope.addNewMeasure = function (measure, index) { if(measure&&index>=0){ $scope.updateMeasureStatus.isEdit = true; @@ -43,26 +68,43 @@ KylinApp.controller('CubeMeasuresCtrl', function ($scope, $modal,MetaModel,cubes if($scope.newMeasure.function.expression=="TOP_N"){ $scope.convertedColumns=[]; for(var configuration in $scope.newMeasure.function.configuration) { - var _name=configuration.slice(14); - var item=$scope.newMeasure.function.configuration[configuration]; - var _isFixedLength = item.substring(0,12) === "fixed_length"?"true":"false";//fixed_length:12 - var _isIntLength = item.substring(0,3) === "int"?"true":"false";//fixed_length:12 - var _encoding = item; - var _valueLength = 0 ; - if(_isFixedLength !=="false"){ - _valueLength = item.substring(13,item.length); - _encoding = "fixed_length"; - } - if(_isIntLength!="false"){ - _valueLength = item.substring(4,item.length); - _encoding = "int"; - } - $scope.GroupBy = { - name:_name, - encoding:_encoding, - valueLength:_valueLength, + if(/topn\.encoding\./.test(configuration)){ + var _name=configuration.slice(14); + var item=$scope.newMeasure.function.configuration[configuration]; + //var _isFixedLength = item.substring(0,12) === "fixed_length"?"true":"false";//fixed_length:12 + //var _isIntegerLength = item.substring(0,7) === "integer"?"true":"false"; + //var _isIntLength = item.substring(0,3) === "int"?"true":"false"; + var _encoding = item; + var _valueLength = 0 ; + //if(_isFixedLength !=="false"){ + // _valueLength = item.substring(13,item.length); + // _encoding = "fixed_length"; + //} + //if(_isIntLength!="false" && _isIntegerLength=="false" ){ + // _valueLength = item.substring(4,item.length); + // _encoding = "int"; + //} + // + //if(_isIntegerLength!="false" ){ + // _valueLength = item.substring(8,item.length); + // _encoding = "integer"; + //} + var version=$scope.newMeasure.function.configuration['topn.encoding_version.'+_name]||1; + item=$scope.removeVersion(item); + var baseKey=item.replace(/:\d+/,''); + if(needLengthKeyList.indexOf(baseKey)>=-1){ + var result=/:(\d+)/.exec(item); + _valueLength=result?result[1]:0; + } + _encoding=baseKey; + $scope.GroupBy = { + name:_name, + encoding:_encoding+(version?"[v"+version+"]":"[v1]"), + valueLength:_valueLength, + encoding_version:version||1 + } + $scope.convertedColumns.push($scope.GroupBy); } - $scope.convertedColumns.push($scope.GroupBy); }; } }; @@ -129,7 +171,6 @@ KylinApp.controller('CubeMeasuresCtrl', function ($scope, $modal,MetaModel,cubes }; $scope.saveNewMeasure = function () { - if ($scope.newMeasure.function.expression === 'TOP_N' ) { if($scope.newMeasure.function.parameter.value == ""){ SweetAlert.swal('', '[TOP_N] ORDER|SUM by Column is required', 'warning'); @@ -160,21 +201,17 @@ KylinApp.controller('CubeMeasuresCtrl', function ($scope, $modal,MetaModel,cubes $scope.groupby($scope.nextPara); angular.forEach($scope.convertedColumns,function(item){ var a='topn.encoding.'+item.name; + var versionKey='topn.encoding_version.'+item.name; + var version=$scope.getTypeVersion(item.encoding); var encoding=""; - if(item.encoding!=="dict" && item.encoding!=="date"&& item.encoding!=="time"){ - if(item.encoding=="fixed_length" && item.valueLength){ - encoding = "fixed_length:"+item.valueLength; - } - else if(item.encoding=="int" && item.valueLength){ - encoding = "int:"+item.valueLength; - }else{ - encoding = item.encoding; - } + if(needLengthKeyList.indexOf($scope.removeVersion(item.encoding))>=-1){ + encoding = $scope.removeVersion(item.encoding)+":"+item.valueLength; }else{ - encoding = item.encoding; + encoding = $scope.removeVersion(item.encoding); item.valueLength=0; } - $scope.newMeasure.function.configuration[a]=encoding; + $scope.newMeasure.function.configuration[a]= encoding; + $scope.newMeasure.function.configuration[versionKey]=version; }); } http://git-wip-us.apache.org/repos/asf/kylin/blob/577e6be2/webapp/app/js/services/cubes.js ---------------------------------------------------------------------- diff --git a/webapp/app/js/services/cubes.js b/webapp/app/js/services/cubes.js index 953f157..051cc92 100644 --- a/webapp/app/js/services/cubes.js +++ b/webapp/app/js/services/cubes.js @@ -19,7 +19,7 @@ KylinApp.factory('CubeService', ['$resource', function ($resource, config) { return $resource(Config.service.url + 'cubes/:cubeId/:propName/:propValue/:action', {}, { list: {method: 'GET', params: {}, isArray: true}, - getValidEncodings: {method: 'GET', params: {action:"validEncodings"}, isArray: true}, + getValidEncodings: {method: 'GET', params: {action:"validEncodings"}, isArray: false}, getCube: {method: 'GET', params: {}, isArray: false}, getSql: {method: 'GET', params: {propName: 'segs', action: 'sql'}, isArray: false}, updateNotifyList: {method: 'PUT', params: {propName: 'notify_list'}, isArray: false}, http://git-wip-us.apache.org/repos/asf/kylin/blob/577e6be2/webapp/app/js/utils/utils.js ---------------------------------------------------------------------- diff --git a/webapp/app/js/utils/utils.js b/webapp/app/js/utils/utils.js index d838e9e..d2f9625 100644 --- a/webapp/app/js/utils/utils.js +++ b/webapp/app/js/utils/utils.js @@ -63,6 +63,51 @@ KylinApp.factory('VdmUtil', function ($modal, $timeout, $location, $anchorScroll if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); return fmt; + }, + + SCToFloat:function(data){ + var resultValue = ""; + if (data.indexOf('E') != -1){ + var regExp = new RegExp('^((\\d+.?\\d+)[Ee]{1}(\\d+))$', 'ig'); + var result = regExp.exec(data); + var power = ""; + if (result != null){ + resultValue = result[2]; + power = result[3]; + } + if (resultValue != ""){ + if (power != ""){ + var powVer = Math.pow(10, power); + resultValue = (resultValue * powVer).toFixed(2); + } + } + } + return resultValue; + }, + getObjectListByFilterVal:function(objList,key,value,matchkey,matchval){ + var len=objList&&objList.length|| 0,newArr=[]; + for(var i=0;i<len;i++){ + if(!key||value===objList[i][key]||(angular.isArray(value)&&value.indexOf(objList[i][key])>-1)){ + if(matchkey){ + if(matchval==objList[i][matchkey]||(angular.isArray(matchval)&&value.indexOf(objList[i][matchkey])>-1)){ + newArr.push(objList[i]) + } + }else{ + newArr.push(objList[i]) + } + } + } + return newArr; + }, + changeObjectListValueByFilter:function(objList,key,val,newKey,newVal){ + var len=objList&&objList.length|| 0,newArr=[]; + for(var i=0;i<len;i++){ + if(val===objList[i][key]){ + objList[i][newKey]=newVal; + continue; + } + } + return objList; } } });