From 7fc572eea422486eaadc27b02a835e8d62e5a6e9 Mon Sep 17 00:00:00 2001 From: Zhong Date: Tue, 16 Aug 2016 16:11:18 +0800 Subject: [PATCH] KYLIN-1702: change the layout path of table snapshot with tablename --- .../org/apache/kylin/dict/lookup/SnapshotManager.java | 4 ++-- .../java/org/apache/kylin/dict/lookup/SnapshotTable.java | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/core-dictionary/src/main/java/org/apache/kylin/dict/lookup/SnapshotManager.java b/core-dictionary/src/main/java/org/apache/kylin/dict/lookup/SnapshotManager.java index c7b0d26..b15847b 100644 --- a/core-dictionary/src/main/java/org/apache/kylin/dict/lookup/SnapshotManager.java +++ b/core-dictionary/src/main/java/org/apache/kylin/dict/lookup/SnapshotManager.java @@ -115,7 +115,7 @@ public class SnapshotManager { } public SnapshotTable buildSnapshot(ReadableTable table, TableDesc tableDesc) throws IOException { - SnapshotTable snapshot = new SnapshotTable(table); + SnapshotTable snapshot = new SnapshotTable(table, tableDesc.getName()); snapshot.updateRandomUuid(); String dup = checkDupByInfo(snapshot); @@ -135,7 +135,7 @@ public class SnapshotManager { } public SnapshotTable rebuildSnapshot(ReadableTable table, TableDesc tableDesc, String overwriteUUID) throws IOException { - SnapshotTable snapshot = new SnapshotTable(table); + SnapshotTable snapshot = new SnapshotTable(table, tableDesc.getName()); snapshot.setUuid(overwriteUUID); snapshot.takeSnapshot(table, tableDesc); diff --git a/core-dictionary/src/main/java/org/apache/kylin/dict/lookup/SnapshotTable.java b/core-dictionary/src/main/java/org/apache/kylin/dict/lookup/SnapshotTable.java index b2306b2..1aea124 100644 --- a/core-dictionary/src/main/java/org/apache/kylin/dict/lookup/SnapshotTable.java +++ b/core-dictionary/src/main/java/org/apache/kylin/dict/lookup/SnapshotTable.java @@ -27,6 +27,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import com.google.common.base.Strings; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.ArrayUtils; import org.apache.kylin.common.persistence.ResourceStore; @@ -49,6 +50,8 @@ import com.fasterxml.jackson.annotation.JsonProperty; @JsonAutoDetect(fieldVisibility = Visibility.NONE, getterVisibility = Visibility.NONE, isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE) public class SnapshotTable extends RootPersistentEntity implements ReadableTable { + @JsonProperty("tableName") + private String tableName; @JsonProperty("signature") private TableSignature signature; @JsonProperty("useDictionary") @@ -61,7 +64,8 @@ public class SnapshotTable extends RootPersistentEntity implements ReadableTable public SnapshotTable() { } - SnapshotTable(ReadableTable table) throws IOException { + SnapshotTable(ReadableTable table, String tableName) throws IOException { + this.tableName = tableName; this.signature = table.getSignature(); this.useDictionary = true; } @@ -111,10 +115,18 @@ public class SnapshotTable extends RootPersistentEntity implements ReadableTable } public String getResourcePath() { - return ResourceStore.SNAPSHOT_RESOURCE_ROOT + "/" + new File(signature.getPath()).getName() + "/" + uuid + ".snapshot"; + return getResourceDir() + "/" + uuid + ".snapshot"; } public String getResourceDir() { + if (Strings.isNullOrEmpty(tableName)) { + return getOldResourceDir(); + } else { + return ResourceStore.SNAPSHOT_RESOURCE_ROOT + "/" + tableName; + } + } + + private String getOldResourceDir() { return ResourceStore.SNAPSHOT_RESOURCE_ROOT + "/" + new File(signature.getPath()).getName(); } -- 2.5.4 (Apple Git-61)