Commit 89eb86c3 authored by Tuukka Lehtonen's avatar Tuukka Lehtonen
Browse files

Fix IndexedRelationsSearcher to invalid memory-based cache upon remove

gitlab #725
parent 9f4f62a0
......@@ -72,7 +72,7 @@ public class IndexedRelationsSearcher extends IndexedRelationsSearcherBase {
void insertIndex(IProgressMonitor monitor, GenericRelation r, int boundLength, Collection<Object[]> documentsData)
throws CorruptIndexException, IOException, DatabaseException {
Collection<Object> keyValues = new ArrayList<Object>();
Collection<Object> keyValues = new ArrayList<>();
for(Object[] data : documentsData) {
keyValues.add(data[1]);
}
......@@ -81,11 +81,17 @@ public class IndexedRelationsSearcher extends IndexedRelationsSearcherBase {
//cache.commit();
}
@Override
void removeIndex(IProgressMonitor monitor) throws DatabaseException, CorruptIndexException, IOException {
super.removeIndex(monitor);
cache.removeIndex(monitor);
}
@Override
void removeIndex(IProgressMonitor monitor, GenericRelation r, RequestProcessor processor, String key, Collection<Object> keyValues) throws DatabaseException,CorruptIndexException, IOException {
Collection<Object[]> documentsData = new ArrayList<Object[]>();
Collection<Object[]> documentsData = new ArrayList<>();
Pair<String,String>[] fields = r.getFields();
......@@ -143,7 +149,7 @@ public class IndexedRelationsSearcher extends IndexedRelationsSearcherBase {
List<Map<String, Object>> results = super.doSearch(monitor, processor, search, maxResultCount);
if(cache == null) {
cache = new HashMap<String,List<Map<String,Object>>>();
cache = new HashMap<>();
mem.persistentCache.put(key, cache);
}
......@@ -171,7 +177,7 @@ public class IndexedRelationsSearcher extends IndexedRelationsSearcherBase {
List<Resource> results = super.doSearchResources(monitor, processor, search, maxResultCount);
if(cache == null) {
cache = new HashMap<String,List<Resource>>();
cache = new HashMap<>();
mem.persistentCacheResources.put(key, cache);
}
......@@ -199,7 +205,7 @@ public class IndexedRelationsSearcher extends IndexedRelationsSearcherBase {
List<Map<String,Object>> persistent = persistentCachedSearch(monitor, processor, search, maxResultCount);
List<Map<String,Object>> cached = cache.doSearch(monitor, processor, search, maxResultCount);
ArrayList<Map<String,Object>> result = new ArrayList<Map<String,Object>>();
ArrayList<Map<String,Object>> result = new ArrayList<>();
for(Map<String,Object> m : persistent) {
Resource r = (Resource)m.get("Resource");
......@@ -219,7 +225,7 @@ public class IndexedRelationsSearcher extends IndexedRelationsSearcherBase {
List<Resource> persistent = persistentCachedSearchResources(monitor, processor, search, maxResultCount);
List<Resource> cached = cache.doSearchResources(monitor, processor, search, maxResultCount);
ArrayList<Resource> result = new ArrayList<Resource>();
ArrayList<Resource> result = new ArrayList<>();
for(Resource r : persistent) {
if(!cache.changed.contains(r.getResourceId())) {
result.add(r);
......@@ -246,9 +252,9 @@ public class IndexedRelationsSearcher extends IndexedRelationsSearcherBase {
if(!os.isEmpty()) {
ArrayList<Object> replaceKeys = new ArrayList<Object>();
ArrayList<Object[]> replaceValues = new ArrayList<Object[]>();
ArrayList<Object> removeKeys = new ArrayList<Object>();
ArrayList<Object> replaceKeys = new ArrayList<>();
ArrayList<Object[]> replaceValues = new ArrayList<>();
ArrayList<Object> removeKeys = new ArrayList<>();
for(Object[] o : os) {
Long parent = (Long)o[0];
Long key = (Long)o[1];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment