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 2018/01/03 05:38:14 UTC
kylin git commit: KYLIN-3081, fix potential NPE
Repository: kylin
Updated Branches:
refs/heads/master 3ec601004 -> 3e9bc5bd2
KYLIN-3081, fix potential NPE
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/3e9bc5bd
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/3e9bc5bd
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/3e9bc5bd
Branch: refs/heads/master
Commit: 3e9bc5bd2e818d9e855ac2b917c8942800e0788e
Parents: 3ec6010
Author: etherge <et...@163.com>
Authored: Wed Jan 3 10:22:45 2018 +0800
Committer: shaofengshi <sh...@apache.org>
Committed: Wed Jan 3 13:38:09 2018 +0800
----------------------------------------------------------------------
.../kylin/rest/controller/CubeController.java | 38 ++++++++++----------
1 file changed, 20 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kylin/blob/3e9bc5bd/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 f53189b..20ba9ae 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
@@ -797,27 +797,29 @@ public class CubeController extends BasicController {
HttpServletResponse response) throws IOException {
CubeInstance cube = cubeService.getCubeManager().getCube(cubeName);
if (cube == null) {
- logger.error("Get cube: [" + cubeName + "] failed when get recommend cuboids");
- throw new BadRequestException("Get cube: [" + cubeName + "] failed when get recommend cuboids");
- }
- Map<Long, Long> cuboidList = getRecommendCuboidList(cube);
- if (cuboidList == null || cuboidList.isEmpty()) {
- logger.warn("Cannot get recommend cuboid list for cube " + cubeName);
+ throw new BadRequestException("Cube: [" + cubeName + "] not exist.");
}
- if (cuboidList.size() < top) {
- logger.info("Only recommend " + cuboidList.size() + " cuboids less than topn " + top);
- }
- Iterator<Long> cuboidIterator = cuboidList.keySet().iterator();
- RowKeyColDesc[] rowKeyColDescList = cube.getDescriptor().getRowkey().getRowKeyColumns();
+ Map<Long, Long> cuboidList = getRecommendCuboidList(cube);
List<Set<String>> dimensionSetList = Lists.newLinkedList();
- while (top-- > 0 && cuboidIterator.hasNext()) {
- Set<String> dimensionSet = Sets.newHashSet();
- dimensionSetList.add(dimensionSet);
- long cuboid = cuboidIterator.next();
- for (int i = 0; i < rowKeyColDescList.length; i++) {
- if ((cuboid & (1L << rowKeyColDescList[i].getBitIndex())) > 0) {
- dimensionSet.add(rowKeyColDescList[i].getColumn());
+
+ if (cuboidList == null || cuboidList.isEmpty()) {
+ logger.info("Cannot get recommended cuboid list for cube " + cubeName);
+ }else {
+ if (cuboidList.size() < top) {
+ logger.info("Require " + top + " recommended cuboids, but only " + cuboidList.size() + " is found.");
+ }
+ Iterator<Long> cuboidIterator = cuboidList.keySet().iterator();
+ RowKeyColDesc[] rowKeyColDescList = cube.getDescriptor().getRowkey().getRowKeyColumns();
+
+ while (top-- > 0 && cuboidIterator.hasNext()) {
+ Set<String> dimensionSet = Sets.newHashSet();
+ dimensionSetList.add(dimensionSet);
+ long cuboid = cuboidIterator.next();
+ for (int i = 0; i < rowKeyColDescList.length; i++) {
+ if ((cuboid & (1L << rowKeyColDescList[i].getBitIndex())) > 0) {
+ dimensionSet.add(rowKeyColDescList[i].getColumn());
+ }
}
}
}