You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by sh...@apache.org on 2017/02/20 07:43:59 UTC
[1/2] kylin git commit: KYLIN-2452 validate there is at least one
AggregationGroup
Repository: kylin
Updated Branches:
refs/heads/master bbcb0ed52 -> bf8134010
KYLIN-2452 validate there is at least one AggregationGroup
Signed-off-by: shaofengshi <sh...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/42d09a79
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/42d09a79
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/42d09a79
Branch: refs/heads/master
Commit: 42d09a79848f2becf57deab8742b896d017791b3
Parents: bbcb0ed
Author: Cheng Wang <ch...@kyligence.io>
Authored: Fri Feb 17 10:05:28 2017 +0800
Committer: shaofengshi <sh...@apache.org>
Committed: Mon Feb 20 15:20:31 2017 +0800
----------------------------------------------------------------------
.../org/apache/kylin/cube/model/CubeDesc.java | 18 ++++++++++--------
.../kylin/rest/controller/CubeController.java | 13 +++++++++----
2 files changed, 19 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kylin/blob/42d09a79/core-cube/src/main/java/org/apache/kylin/cube/model/CubeDesc.java
----------------------------------------------------------------------
diff --git a/core-cube/src/main/java/org/apache/kylin/cube/model/CubeDesc.java b/core-cube/src/main/java/org/apache/kylin/cube/model/CubeDesc.java
index 0c1419d..0f804d1 100644
--- a/core-cube/src/main/java/org/apache/kylin/cube/model/CubeDesc.java
+++ b/core-cube/src/main/java/org/apache/kylin/cube/model/CubeDesc.java
@@ -440,6 +440,8 @@ public class CubeDesc extends RootPersistentEntity implements IEngineAware {
}
public int getBuildLevel() {
+ if (aggregationGroups.size() <= 0)
+ throw new IllegalStateException("AggregationGroup size is: " + aggregationGroups.size() + ", there should be at least one AggregationGroup!");
return Collections.max(Collections2.transform(aggregationGroups, new Function<AggregationGroup, Integer>() {
@Nullable
@Override
@@ -554,7 +556,7 @@ public class CubeDesc extends RootPersistentEntity implements IEngineAware {
initMeasureColumns();
rowkey.init(this);
-
+
validateAggregationGroups(); // check if aggregation group is valid
for (AggregationGroup agg : this.aggregationGroups) {
agg.init(this, rowkey);
@@ -752,13 +754,13 @@ public class CubeDesc extends RootPersistentEntity implements IEngineAware {
}
initDerivedMap(dimColArray, DeriveType.LOOKUP, join, derivedCols, derivedExtra);
}
-
+
if (join != null) {
allColumns.addAll(Arrays.asList(join.getForeignKeyColumns()));
allColumns.addAll(Arrays.asList(join.getPrimaryKeyColumns()));
}
}
-
+
// PK-FK derive the other side
Set<TblColRef> realDimensions = new HashSet<>(listDimensionColumnsExcludingDerived(true));
for (JoinTableDesc joinTable : model.getJoinTables()) {
@@ -777,7 +779,7 @@ public class CubeDesc extends RootPersistentEntity implements IEngineAware {
}
}
}
-
+
private String[][] splitDerivedColumnAndExtra(String[] derived) {
String[] cols = new String[derived.length];
String[] extra = new String[derived.length];
@@ -810,7 +812,7 @@ public class CubeDesc extends RootPersistentEntity implements IEngineAware {
i--;
}
}
-
+
if (derivedCols.length == 0)
return;
@@ -826,7 +828,7 @@ public class CubeDesc extends RootPersistentEntity implements IEngineAware {
infoList = new ArrayList<DeriveInfo>();
hostToDerivedMap.put(hostColArray, infoList);
}
-
+
// Merged duplicated derived column
List<TblColRef> whatsLeft = new ArrayList<>();
for (TblColRef derCol : derivedCols) {
@@ -966,7 +968,7 @@ public class CubeDesc extends RootPersistentEntity implements IEngineAware {
allColumns.addAll(Arrays.asList(join.getPrimaryKeyColumns()));
}
}
-
+
for (TblColRef col : allColumns) {
allColumnDescs.add(col.getColumnDesc());
}
@@ -1142,7 +1144,7 @@ public class CubeDesc extends RootPersistentEntity implements IEngineAware {
return null;
}
-
+
/** Get a column which can be used to cluster the source table.
* To reduce memory footprint in base cuboid for global dict */
// TODO handle more than one ultra high cardinality columns use global dict in one cube
http://git-wip-us.apache.org/repos/asf/kylin/blob/42d09a79/server-base/src/main/java/org/apache/kylin/rest/controller/CubeController.java
----------------------------------------------------------------------
diff --git a/server-base/src/main/java/org/apache/kylin/rest/controller/CubeController.java b/server-base/src/main/java/org/apache/kylin/rest/controller/CubeController.java
index f905fe1..fb4be5a 100644
--- a/server-base/src/main/java/org/apache/kylin/rest/controller/CubeController.java
+++ b/server-base/src/main/java/org/apache/kylin/rest/controller/CubeController.java
@@ -327,10 +327,10 @@ public class CubeController extends BasicController {
throw new InternalErrorException("Cannot find cube '" + cubeName + "'");
}
-// if (cube.getSegments() != null && cube.getBuildingSegments().size() > 0) {
-// int num = cube.getBuildingSegments().size();
-// throw new InternalErrorException("Cannot purge cube '" + cubeName + "' as there is " + num + " building " + (num > 1 ? "segment(s)." : "segment. Discard the related job first."));
-// }
+ // if (cube.getSegments() != null && cube.getBuildingSegments().size() > 0) {
+ // int num = cube.getBuildingSegments().size();
+ // throw new InternalErrorException("Cannot purge cube '" + cubeName + "' as there is " + num + " building " + (num > 1 ? "segment(s)." : "segment. Discard the related job first."));
+ // }
return cubeService.purgeCube(cube);
} catch (Exception e) {
@@ -426,6 +426,7 @@ public class CubeController extends BasicController {
public CubeRequest saveCubeDesc(@RequestBody CubeRequest cubeRequest) {
CubeDesc desc = deserializeCubeDesc(cubeRequest);
+
if (desc == null) {
cubeRequest.setMessage("CubeDesc is null.");
return cubeRequest;
@@ -440,6 +441,10 @@ public class CubeController extends BasicController {
throw new BadRequestException("Invalid Cube name, only letters, numbers and underline supported.");
}
+ int aggSize = desc.getAggregationGroups().size();
+ if (aggSize <= 0)
+ throw new IllegalStateException("AggregationGroup size is: " + aggSize + ", there should be at least one AggregationGroup!");
+
try {
desc.setUuid(UUID.randomUUID().toString());
String projectName = (null == cubeRequest.getProject()) ? ProjectInstance.DEFAULT_PROJECT_NAME : cubeRequest.getProject();
[2/2] kylin git commit: KYLIN-2452 code review
Posted by sh...@apache.org.
KYLIN-2452 code review
Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/bf813401
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/bf813401
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/bf813401
Branch: refs/heads/master
Commit: bf8134010a927b35b942957080466bce7ccac6c9
Parents: 42d09a7
Author: shaofengshi <sh...@apache.org>
Authored: Mon Feb 20 15:30:59 2017 +0800
Committer: shaofengshi <sh...@apache.org>
Committed: Mon Feb 20 15:30:59 2017 +0800
----------------------------------------------------------------------
.../src/main/java/org/apache/kylin/cube/model/CubeDesc.java | 5 +++--
.../kylin/cube/model/validation/rule/AggregationGroupRule.java | 5 +++++
.../java/org/apache/kylin/rest/controller/CubeController.java | 4 ----
3 files changed, 8 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kylin/blob/bf813401/core-cube/src/main/java/org/apache/kylin/cube/model/CubeDesc.java
----------------------------------------------------------------------
diff --git a/core-cube/src/main/java/org/apache/kylin/cube/model/CubeDesc.java b/core-cube/src/main/java/org/apache/kylin/cube/model/CubeDesc.java
index 0f804d1..95e3343 100644
--- a/core-cube/src/main/java/org/apache/kylin/cube/model/CubeDesc.java
+++ b/core-cube/src/main/java/org/apache/kylin/cube/model/CubeDesc.java
@@ -440,8 +440,9 @@ public class CubeDesc extends RootPersistentEntity implements IEngineAware {
}
public int getBuildLevel() {
- if (aggregationGroups.size() <= 0)
- throw new IllegalStateException("AggregationGroup size is: " + aggregationGroups.size() + ", there should be at least one AggregationGroup!");
+ if (aggregationGroups == null || aggregationGroups.size() == 0)
+ throw new IllegalStateException("Cube has no aggregation group.");
+
return Collections.max(Collections2.transform(aggregationGroups, new Function<AggregationGroup, Integer>() {
@Nullable
@Override
http://git-wip-us.apache.org/repos/asf/kylin/blob/bf813401/core-cube/src/main/java/org/apache/kylin/cube/model/validation/rule/AggregationGroupRule.java
----------------------------------------------------------------------
diff --git a/core-cube/src/main/java/org/apache/kylin/cube/model/validation/rule/AggregationGroupRule.java b/core-cube/src/main/java/org/apache/kylin/cube/model/validation/rule/AggregationGroupRule.java
index 3f865ea..c9e2d28 100644
--- a/core-cube/src/main/java/org/apache/kylin/cube/model/validation/rule/AggregationGroupRule.java
+++ b/core-cube/src/main/java/org/apache/kylin/cube/model/validation/rule/AggregationGroupRule.java
@@ -50,6 +50,11 @@ public class AggregationGroupRule implements IValidatorRule<CubeDesc> {
private void inner(CubeDesc cube, ValidateContext context) {
+ if (cube.getAggregationGroups() == null || cube.getAggregationGroups().size() == 0) {
+ context.addResult(ResultLevel.ERROR, "Cube should have at least one Aggregation group.");
+ return;
+ }
+
int index = 0;
for (AggregationGroup agg : cube.getAggregationGroups()) {
if (agg.getIncludes() == null) {
http://git-wip-us.apache.org/repos/asf/kylin/blob/bf813401/server-base/src/main/java/org/apache/kylin/rest/controller/CubeController.java
----------------------------------------------------------------------
diff --git a/server-base/src/main/java/org/apache/kylin/rest/controller/CubeController.java b/server-base/src/main/java/org/apache/kylin/rest/controller/CubeController.java
index fb4be5a..da44aec 100644
--- a/server-base/src/main/java/org/apache/kylin/rest/controller/CubeController.java
+++ b/server-base/src/main/java/org/apache/kylin/rest/controller/CubeController.java
@@ -441,10 +441,6 @@ public class CubeController extends BasicController {
throw new BadRequestException("Invalid Cube name, only letters, numbers and underline supported.");
}
- int aggSize = desc.getAggregationGroups().size();
- if (aggSize <= 0)
- throw new IllegalStateException("AggregationGroup size is: " + aggSize + ", there should be at least one AggregationGroup!");
-
try {
desc.setUuid(UUID.randomUUID().toString());
String projectName = (null == cubeRequest.getProject()) ? ProjectInstance.DEFAULT_PROJECT_NAME : cubeRequest.getProject();