You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@carbondata.apache.org by ja...@apache.org on 2018/04/24 16:14:57 UTC

carbondata git commit: [HOTFIX] Avoid adding status if there is no datamaps on table.

Repository: carbondata
Updated Branches:
  refs/heads/master 84267dc7a -> f2bb9f4eb


[HOTFIX] Avoid adding status if there is no datamaps on table.

This closes #2222


Project: http://git-wip-us.apache.org/repos/asf/carbondata/repo
Commit: http://git-wip-us.apache.org/repos/asf/carbondata/commit/f2bb9f4e
Tree: http://git-wip-us.apache.org/repos/asf/carbondata/tree/f2bb9f4e
Diff: http://git-wip-us.apache.org/repos/asf/carbondata/diff/f2bb9f4e

Branch: refs/heads/master
Commit: f2bb9f4eb39f0306cd83ecdad3e3dff34ec151e6
Parents: 84267dc
Author: ravipesala <ra...@gmail.com>
Authored: Tue Apr 24 17:02:21 2018 +0530
Committer: Jacky Li <ja...@qq.com>
Committed: Wed Apr 25 00:14:42 2018 +0800

----------------------------------------------------------------------
 .../core/datamap/status/DataMapStatusManager.java       | 12 ++++++------
 .../datamap/status/DiskBasedDataMapStatusProvider.java  |  4 ++++
 2 files changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/carbondata/blob/f2bb9f4e/core/src/main/java/org/apache/carbondata/core/datamap/status/DataMapStatusManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/datamap/status/DataMapStatusManager.java b/core/src/main/java/org/apache/carbondata/core/datamap/status/DataMapStatusManager.java
index 10ed80c..31ab4e4 100644
--- a/core/src/main/java/org/apache/carbondata/core/datamap/status/DataMapStatusManager.java
+++ b/core/src/main/java/org/apache/carbondata/core/datamap/status/DataMapStatusManager.java
@@ -53,11 +53,11 @@ public class DataMapStatusManager {
 
   public static void disableDataMap(String dataMapName) throws Exception {
     DataMapSchema dataMapSchema = getDataMapSchema(dataMapName);
-    List<DataMapSchema> list = new ArrayList<>();
     if (dataMapSchema != null) {
+      List<DataMapSchema> list = new ArrayList<>();
       list.add(dataMapSchema);
+      storageProvider.updateDataMapStatus(list, DataMapStatus.DISABLED);
     }
-    storageProvider.updateDataMapStatus(list, DataMapStatus.DISABLED);
   }
 
   public static void disableDataMapsOfTable(CarbonTable table) throws IOException {
@@ -68,11 +68,11 @@ public class DataMapStatusManager {
 
   public static void enableDataMap(String dataMapName) throws IOException, NoSuchDataMapException {
     DataMapSchema dataMapSchema = getDataMapSchema(dataMapName);
-    List<DataMapSchema> list = new ArrayList<>();
     if (dataMapSchema != null) {
+      List<DataMapSchema> list = new ArrayList<>();
       list.add(dataMapSchema);
+      storageProvider.updateDataMapStatus(list, DataMapStatus.ENABLED);
     }
-    storageProvider.updateDataMapStatus(list, DataMapStatus.ENABLED);
   }
 
   public static void enableDataMapsOfTable(CarbonTable table) throws IOException {
@@ -83,11 +83,11 @@ public class DataMapStatusManager {
 
   public static void dropDataMap(String dataMapName) throws IOException, NoSuchDataMapException {
     DataMapSchema dataMapSchema = getDataMapSchema(dataMapName);
-    List<DataMapSchema> list = new ArrayList<>();
     if (dataMapSchema != null) {
+      List<DataMapSchema> list = new ArrayList<>();
       list.add(dataMapSchema);
+      storageProvider.updateDataMapStatus(list, DataMapStatus.DROPPED);
     }
-    storageProvider.updateDataMapStatus(list, DataMapStatus.DROPPED);
   }
 
   private static DataMapSchema getDataMapSchema(String dataMapName)

http://git-wip-us.apache.org/repos/asf/carbondata/blob/f2bb9f4e/core/src/main/java/org/apache/carbondata/core/datamap/status/DiskBasedDataMapStatusProvider.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/datamap/status/DiskBasedDataMapStatusProvider.java b/core/src/main/java/org/apache/carbondata/core/datamap/status/DiskBasedDataMapStatusProvider.java
index 001af2d..83e141d 100644
--- a/core/src/main/java/org/apache/carbondata/core/datamap/status/DiskBasedDataMapStatusProvider.java
+++ b/core/src/main/java/org/apache/carbondata/core/datamap/status/DiskBasedDataMapStatusProvider.java
@@ -98,6 +98,10 @@ public class DiskBasedDataMapStatusProvider implements DataMapStatusStorageProvi
   @Override
   public void updateDataMapStatus(List<DataMapSchema> dataMapSchemas, DataMapStatus dataMapStatus)
       throws IOException {
+    if (dataMapSchemas == null || dataMapSchemas.size() == 0) {
+      // There is nothing to update
+      return;
+    }
     ICarbonLock carbonTableStatusLock = getDataMapStatusLock();
     boolean locked = false;
     try {