You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gora.apache.org by le...@apache.org on 2015/08/28 22:11:09 UTC
gora git commit: GORA-228 java.util.ConcurrentModificationException
when using MemStore for concurrent tests this closes #30
Repository: gora
Updated Branches:
refs/heads/master ed768b4be -> 678307454
GORA-228 java.util.ConcurrentModificationException when using MemStore for concurrent tests this closes #30
Project: http://git-wip-us.apache.org/repos/asf/gora/repo
Commit: http://git-wip-us.apache.org/repos/asf/gora/commit/67830745
Tree: http://git-wip-us.apache.org/repos/asf/gora/tree/67830745
Diff: http://git-wip-us.apache.org/repos/asf/gora/diff/67830745
Branch: refs/heads/master
Commit: 678307454c0a2ab02a993bd8c25378c9e1a215b0
Parents: ed768b4
Author: Lewis John McGibbney <le...@jpl.nasa.gov>
Authored: Fri Aug 28 13:12:12 2015 -0700
Committer: Lewis John McGibbney <le...@jpl.nasa.gov>
Committed: Fri Aug 28 13:12:12 2015 -0700
----------------------------------------------------------------------
CHANGES.txt | 2 ++
.../org/apache/gora/memory/store/MemStore.java | 34 ++++++++++++--------
2 files changed, 22 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/gora/blob/67830745/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index ca79a6c..defcf19 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -4,6 +4,8 @@
Current Development
+* GORA-228 java.util.ConcurrentModificationException when using MemStore for concurrent tests (Yasin Kılınç, cihad güzel, lewismc)
+
* GORA-419: AccumuloStore.put deletes entire row when updating map/array field (gerhardgossen via lewismc)
* GORA-420: AccumuloStore.createSchema fails when table already exists (gerhardgossen via lewismc)
http://git-wip-us.apache.org/repos/asf/gora/blob/67830745/gora-core/src/main/java/org/apache/gora/memory/store/MemStore.java
----------------------------------------------------------------------
diff --git a/gora-core/src/main/java/org/apache/gora/memory/store/MemStore.java b/gora-core/src/main/java/org/apache/gora/memory/store/MemStore.java
index 56ba4e3..d1d18d6 100644
--- a/gora-core/src/main/java/org/apache/gora/memory/store/MemStore.java
+++ b/gora-core/src/main/java/org/apache/gora/memory/store/MemStore.java
@@ -24,7 +24,8 @@ import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.NavigableMap;
-import java.util.TreeMap;
+import java.util.concurrent.ConcurrentNavigableMap;
+import java.util.concurrent.ConcurrentSkipListMap;
import org.apache.avro.Schema.Field;
@@ -88,7 +89,9 @@ public class MemStore<K, T extends PersistentBase> extends DataStoreBase<K, T> {
}
}
- private TreeMap<K, T> map = new TreeMap<K, T>();
+ // This map behaves like DB, has to be static and concurrent collection
+ @SuppressWarnings("rawtypes")
+ public static ConcurrentSkipListMap map = new ConcurrentSkipListMap();
@Override
public String getSchemaName() {
@@ -110,35 +113,36 @@ public class MemStore<K, T extends PersistentBase> extends DataStoreBase<K, T> {
if(delete(result.getKey()))
deletedRows++;
}
- return 0;
- }
- catch(Exception e){
+ return deletedRows;
+ } catch (Exception e) {
return 0;
}
}
-
+
+ @SuppressWarnings("unchecked")
@Override
public Result<K, T> execute(Query<K, T> query) {
K startKey = query.getStartKey();
K endKey = query.getEndKey();
if(startKey == null) {
- startKey = map.firstKey();
+ startKey = (K) map.firstKey();
}
if(endKey == null) {
- endKey = map.lastKey();
+ endKey = (K) map.lastKey();
}
//check if query.fields is null
query.setFields(getFieldsToQuery(query.getFields()));
- NavigableMap<K, T> submap = map.subMap(startKey, true, endKey, true);
+ ConcurrentNavigableMap<K,T> submap = map.subMap(startKey, true, endKey, true);
return new MemResult<K,T>(this, query, submap);
}
-
+
+ @SuppressWarnings("unchecked")
@Override
public T get(K key, String[] fields) {
- T obj = map.get(key);
+ T obj = (T) map.get(key);
if (obj == null) {
return null;
}
@@ -169,7 +173,8 @@ public class MemStore<K, T extends PersistentBase> extends DataStoreBase<K, T> {
public Query<K, T> newQuery() {
return new MemQuery<K, T>(this);
}
-
+
+ @SuppressWarnings("unchecked")
@Override
public void put(K key, T obj) {
map.put(key, obj);
@@ -189,7 +194,6 @@ public class MemStore<K, T extends PersistentBase> extends DataStoreBase<K, T> {
@Override
public void close() {
- map.clear();
}
@Override
@@ -206,5 +210,7 @@ public class MemStore<K, T extends PersistentBase> extends DataStoreBase<K, T> {
}
@Override
- public void flush() { }
+ public void flush() {
+ map.clear();
+ }
}