You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by ma...@apache.org on 2016/11/22 01:40:32 UTC
[1/3] kylin git commit: encoding at version tips
Repository: kylin
Updated Branches:
refs/heads/yang21 61dd19f6f -> d4715b559
encoding at version tips
Signed-off-by: Hongbin Ma <ma...@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 <55...@qq.com>
Authored: Sat Nov 19 14:50:52 2016 +0800
Committer: Hongbin Ma <ma...@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;
}
}
});
[3/3] kylin git commit: add utilsjs link
Posted by ma...@apache.org.
add utilsjs link
Signed-off-by: Hongbin Ma <ma...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/d4715b55
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/d4715b55
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/d4715b55
Branch: refs/heads/yang21
Commit: d4715b559dda73457610f41374fc0042ffdbddf2
Parents: 258353f
Author: luguosheng <55...@qq.com>
Authored: Sat Nov 19 19:44:53 2016 +0800
Committer: Hongbin Ma <ma...@apache.org>
Committed: Tue Nov 22 09:39:42 2016 +0800
----------------------------------------------------------------------
webapp/app/index.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kylin/blob/d4715b55/webapp/app/index.html
----------------------------------------------------------------------
diff --git a/webapp/app/index.html b/webapp/app/index.html
index 8fb2cb9..ad881d5 100644
--- a/webapp/app/index.html
+++ b/webapp/app/index.html
@@ -163,7 +163,7 @@
<!--New GUI-->
<script src="js/model/modelsManager.js"></script>
<script src="js/services/badQuery.js"></script>
-
+<script src="js/utils/utils.js"></script>
<script src="js/controllers/page.js"></script>
<script src="js/controllers/index.js"></script>
<script src="js/controllers/access.js"></script>
[2/3] kylin git commit: encoding add filter by column type
Posted by ma...@apache.org.
encoding add filter by column type
Signed-off-by: Hongbin Ma <ma...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/258353f5
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/258353f5
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/258353f5
Branch: refs/heads/yang21
Commit: 258353f5718ce007313fd723b3ba62cb82c1d9f4
Parents: 577e6be
Author: luguosheng <55...@qq.com>
Authored: Sat Nov 19 16:49:41 2016 +0800
Committer: Hongbin Ma <ma...@apache.org>
Committed: Tue Nov 22 09:39:26 2016 +0800
----------------------------------------------------------------------
webapp/app/js/controllers/cubeEdit.js | 51 +++++++++++++++-----------
webapp/app/js/controllers/cubeMeasures.js | 33 +++++++++++++----
webapp/app/js/utils/utils.js | 21 ++++++++---
3 files changed, 70 insertions(+), 35 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kylin/blob/258353f5/webapp/app/js/controllers/cubeEdit.js
----------------------------------------------------------------------
diff --git a/webapp/app/js/controllers/cubeEdit.js b/webapp/app/js/controllers/cubeEdit.js
index 5c5d9c7..3282974 100755
--- a/webapp/app/js/controllers/cubeEdit.js
+++ b/webapp/app/js/controllers/cubeEdit.js
@@ -77,33 +77,40 @@ KylinApp.controller('CubeEditCtrl', function ($scope, $q, $routeParams, $locatio
},function(e){
$scope.store.supportedEncoding = $scope.cubeConfig.encodings;
})
-
+ $scope.createFilter=function(type){
+ if(type.indexOf("varchar")<=0){
+ return ['fixed_length_hex'];
+ }else if(type!="date"){
+ return ['date'];
+ }else if(type!="time"&&type!="datetime"&&type!="timestamp"){
+ return ['time'];
+ }else{
+ return [];
+ }
+ }
$scope.getEncodings =function (name){
- var type = TableModel.columnNameTypeMap[name]||'';
- var encodings =[];
- for(var k=0;k<$scope.store.supportedEncoding.length;k++){
- encodings.push($scope.store.supportedEncoding[k]);
- }
+ var filterName=name;
+ var type = TableModel.columnNameTypeMap[filterName]||'';
+ var encodings =$scope.store.supportedEncoding,filterEncoding;
+ var filerList=$scope.createFilter(type);
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)
+ if($scope.cubeMetaFrame.rowkey.rowkey_columns&&name){
+ for(var s=0;s<$scope.cubeMetaFrame.rowkey.rowkey_columns.length;s++){
+ if(filterName==$scope.cubeMetaFrame.rowkey.rowkey_columns[s].column){
+ var version=$scope.cubeMetaFrame.rowkey.rowkey_columns[s].encoding_version;
+ filterEncoding=VdmUtil.getFilterObjectListByOrFilterVal(encodings,'value',$scope.cubeMetaFrame.rowkey.rowkey_columns[s].encoding.replace(/:\d+/,"")+(version?"[v"+version+"]":"[v1]"),'suggest',true)
+ }
}
+ }else{
+ filterEncoding=VdmUtil.getFilterObjectListByOrFilterVal(encodings,'suggest',true);
}
+ }else{
+ filterEncoding=VdmUtil.getFilterObjectListByOrFilterVal(encodings,'suggest',true);
+ }
+ for(var f=0;f<filerList.length;f++){
+ filterEncoding=VdmUtil.removeFilterObjectList(filterEncoding,'baseValue',filerList[f]);
}
- //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;
+ return filterEncoding;
}
$scope.getColumnsByTable = function (tableName) {
http://git-wip-us.apache.org/repos/asf/kylin/blob/258353f5/webapp/app/js/controllers/cubeMeasures.js
----------------------------------------------------------------------
diff --git a/webapp/app/js/controllers/cubeMeasures.js b/webapp/app/js/controllers/cubeMeasures.js
index 2358167..2629179 100644
--- a/webapp/app/js/controllers/cubeMeasures.js
+++ b/webapp/app/js/controllers/cubeMeasures.js
@@ -44,16 +44,35 @@ KylinApp.controller('CubeMeasuresCtrl', function ($scope, $modal,MetaModel,cubes
return 1;
}
}
-
+ $scope.createFilter=function(type){
+ if(type.indexOf("varchar")<=0){
+ return ['fixed_length_hex'];
+ }else if(type!="date"){
+ return ['date'];
+ }else if(type!="time"&&type!="datetime"&&type!="timestamp"){
+ return ['time'];
+ }else{
+ return [];
+ }
+ }
$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);
+ var encodings =$scope.store.supportedEncoding,filterEncoding=[];
+ var filerList=$scope.createFilter(type);
+ if($scope.isEdit) {
+ if (name && $scope.newMeasure.function.configuration) {
+ var version = $scope.newMeasure.function.configuration['topn.encoding_version.' + name] || 1;
+ filterEncoding = VdmUtil.getFilterObjectListByOrFilterVal(encodings, 'value', $scope.newMeasure.function.configuration['topn.encoding.' + name].replace(/:\d+/, "") + (version ? "[v" + version + "]" : "[v1]"), 'suggest', true);
+ }else{
+ filterEncoding=VdmUtil.getFilterObjectListByOrFilterVal(encodings,'suggest', true);
+ }
+ }else{
+ filterEncoding=VdmUtil.getFilterObjectListByOrFilterVal(encodings,'suggest', true);
+ }
+ for(var f=0;f<filerList.length;f++){
+ filterEncoding=VdmUtil.removeFilterObjectList(filterEncoding,'baseValue',filerList[f]);
}
- return VdmUtil.getObjectListByFilterVal(filterEncodings, '', '','suggest',true);
+ return filterEncoding;
}
$scope.addNewMeasure = function (measure, index) {
if(measure&&index>=0){
http://git-wip-us.apache.org/repos/asf/kylin/blob/258353f5/webapp/app/js/utils/utils.js
----------------------------------------------------------------------
diff --git a/webapp/app/js/utils/utils.js b/webapp/app/js/utils/utils.js
index d2f9625..aabcad5 100644
--- a/webapp/app/js/utils/utils.js
+++ b/webapp/app/js/utils/utils.js
@@ -84,7 +84,7 @@ KylinApp.factory('VdmUtil', function ($modal, $timeout, $location, $anchorScroll
}
return resultValue;
},
- getObjectListByFilterVal:function(objList,key,value,matchkey,matchval){
+ getFilterObjectListByAndFilterVal: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)){
@@ -99,15 +99,24 @@ KylinApp.factory('VdmUtil', function ($modal, $timeout, $location, $anchorScroll
}
return newArr;
},
- changeObjectListValueByFilter:function(objList,key,val,newKey,newVal){
+ getFilterObjectListByOrFilterVal:function(objList,key,val,orKey,orVal){
var len=objList&&objList.length|| 0,newArr=[];
for(var i=0;i<len;i++){
- if(val===objList[i][key]){
- objList[i][newKey]=newVal;
- continue;
+ if((key&&val===objList[i][key])||(orKey&&objList[i][orKey]===orVal)){
+ newArr.push(objList[i]);
}
}
- return objList;
+ return newArr;
+ },
+ removeFilterObjectList:function(objList,key,val,orKey,orVal){
+ var len=objList&&objList.length|| 0,newArr=[];
+ for(var i=0;i<len;i++){
+ if(key&&val!=objList[i][key]){
+ newArr.push(objList[i]);
+ }
+ }
+ return newArr;
}
+
}
});