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 2017/09/06 02:03:20 UTC
carbondata git commit: [CARBONDATA-1436] optimize concurrent control
for datamap
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 <xu...@hust.edu.cn>
Authored: Thu Aug 31 14:08:45 2017 +0800
Committer: Jacky Li <ja...@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;
}