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/09/10 01:58:29 UTC
[kylin] branch master updated: KYLIN-3258 No check for duplicate
cube name when creating a hybrid cube
This is an automated email from the ASF dual-hosted git repository.
shaofengshi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kylin.git
The following commit(s) were added to refs/heads/master by this push:
new 7a77141 KYLIN-3258 No check for duplicate cube name when creating a hybrid cube
7a77141 is described below
commit 7a7714175a9d479678abb70740977c46e8507247
Author: GinaZhai <na...@kyligence.io>
AuthorDate: Fri Sep 7 11:33:13 2018 +0800
KYLIN-3258 No check for duplicate cube name when creating a hybrid cube
---
.../main/java/org/apache/kylin/rest/job/HybridCubeCLI.java | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/server-base/src/main/java/org/apache/kylin/rest/job/HybridCubeCLI.java b/server-base/src/main/java/org/apache/kylin/rest/job/HybridCubeCLI.java
index 48e7f40..e332e1d 100644
--- a/server-base/src/main/java/org/apache/kylin/rest/job/HybridCubeCLI.java
+++ b/server-base/src/main/java/org/apache/kylin/rest/job/HybridCubeCLI.java
@@ -20,11 +20,14 @@ package org.apache.kylin.rest.job;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
import java.util.List;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
+import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.kylin.common.KylinConfig;
import org.apache.kylin.common.persistence.ResourceStore;
@@ -145,6 +148,17 @@ public class HybridCubeCLI extends AbstractApplication {
realizationEntries.add(RealizationEntry.create(RealizationType.CUBE, cube.getName()));
}
+ int realizationEntriesLen = realizationEntries.size();
+ HashSet<RealizationEntry> hashSet = new HashSet<>();
+ for (int i = 0; i < realizationEntriesLen; i++) {
+ hashSet.add(realizationEntries.get(i));
+ }
+ int hashSetLen = hashSet.size();
+ if (realizationEntriesLen != hashSetLen) {
+ Collection<RealizationEntry> duplicateCubes = CollectionUtils.subtract(realizationEntries, hashSet);
+ throw new IllegalArgumentException("The Cubes name does duplicate, could not create: " + duplicateCubes);
+ }
+
if ("create".equals(action)) {
if (hybridInstance != null) {
throw new IllegalArgumentException("The Hybrid Cube does exist, could not create: " + hybridName);