carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jack...@apache.org
Subject carbondata git commit: [CARBONDATA-1436] optimize concurrent control for datamap
Date Wed, 06 Sep 2017 02:03:20 GMT
Repository: carbondata
Updated Branches:
  refs/heads/master 892f1209e -> a85b4f4b1


[CARBONDATA-1436] optimize concurrent control for datamap

Synchronized by table.

Use double-checked locking to reduce lock overhead

This closes #1306


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

Branch: refs/heads/master
Commit: a85b4f4b1dbf112ebe1bae192a33cdee6cac7baa
Parents: 892f120
Author: xuchuanyin <xuchuanyin@hust.edu.cn>
Authored: Thu Aug 31 14:08:45 2017 +0800
Committer: Jacky Li <jacky.likun@qq.com>
Committed: Wed Sep 6 10:03:04 2017 +0800

----------------------------------------------------------------------
 .../carbondata/core/datamap/DataMapStoreManager.java  | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/carbondata/blob/a85b4f4b/core/src/main/java/org/apache/carbondata/core/datamap/DataMapStoreManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/datamap/DataMapStoreManager.java
b/core/src/main/java/org/apache/carbondata/core/datamap/DataMapStoreManager.java
index 36f7662..9974920 100644
--- a/core/src/main/java/org/apache/carbondata/core/datamap/DataMapStoreManager.java
+++ b/core/src/main/java/org/apache/carbondata/core/datamap/DataMapStoreManager.java
@@ -56,16 +56,24 @@ public final class DataMapStoreManager {
    * @param factoryClass
    * @return
    */
-  public synchronized TableDataMap getDataMap(AbsoluteTableIdentifier identifier,
+  public TableDataMap getDataMap(AbsoluteTableIdentifier identifier,
       String dataMapName, String factoryClass) {
     String table = identifier.uniqueName();
     List<TableDataMap> tableDataMaps = allDataMaps.get(table);
     TableDataMap dataMap;
     if (tableDataMaps == null) {
-      dataMap = createAndRegisterDataMap(identifier, factoryClass, dataMapName);
+      synchronized (table.intern()) {
+        tableDataMaps = allDataMaps.get(table);
+        if (tableDataMaps == null) {
+          dataMap = createAndRegisterDataMap(identifier, factoryClass, dataMapName);
+        } else {
+          dataMap = getTableDataMap(dataMapName, tableDataMaps);
+        }
+      }
     } else {
       dataMap = getTableDataMap(dataMapName, tableDataMaps);
     }
+
     if (dataMap == null) {
       throw new RuntimeException("Datamap does not exist");
     }
@@ -82,7 +90,6 @@ public final class DataMapStoreManager {
     List<TableDataMap> tableDataMaps = allDataMaps.get(table);
     if (tableDataMaps == null) {
       tableDataMaps = new ArrayList<>();
-      allDataMaps.put(table, tableDataMaps);
     }
     TableDataMap dataMap = getTableDataMap(dataMapName, tableDataMaps);
     if (dataMap != null) {
@@ -100,6 +107,7 @@ public final class DataMapStoreManager {
       throw new RuntimeException(e);
     }
     tableDataMaps.add(dataMap);
+    allDataMaps.put(table, tableDataMaps);
     return dataMap;
   }
 


Mime
View raw message