package org.simantics.db.indexing;
-import java.io.File;
import java.io.IOException;
+import java.nio.file.Path;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.simantics.db.Resource;
import org.simantics.db.Session;
import org.simantics.db.common.request.Adapt;
-import org.simantics.db.common.utils.Logger;
import org.simantics.db.indexing.IndexedRelationsSearcherBase.State;
import org.simantics.db.layer0.adapter.GenericRelation;
+import org.slf4j.LoggerFactory;
/**
* @author Tuukka Lehtonen
*/
public class MemoryIndexing {
+ private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(MemoryIndexing.class);
+
final private Session session;
final Map<String,Map<String,List<Map<String, Object>>>> persistentCache = new HashMap<String,Map<String,List<Map<String, Object>>>>();
this.session = session;
}
- protected File getIndexDirectory(Resource relation, Resource input) {
+ protected Path getIndexDirectory(Resource relation, Resource input) {
return DatabaseIndexing.getIndexLocation(session, relation, input);
}
public IndexedRelationsSearcher get(RequestProcessor processor, Resource relation, Resource input) {
+ Path location = getIndexDirectory(relation, input);
try {
- File location = getIndexDirectory(relation, input);
- String key = location.getAbsolutePath();
+ String key = location.toAbsolutePath().toString();
IndexedRelationsSearcher searcher = searchers.get(key);
if (searcher == null) {
GenericRelation r = processor.sync(new Adapt<GenericRelation>(relation, GenericRelation.class));
}
return searcher;
} catch (Exception e) {
- Logger.defaultLogError(e);
+ LOGGER.error("Could not get searcher for relation {} and input {} in location {}", relation, input, location, e);
return null;
}
}
public IndexedRelationsSearcherBase getImmutable(RequestProcessor processor, Resource relation, Resource input) {
+ Path location = getIndexDirectory(relation, input);
try {
- File location = getIndexDirectory(relation, input);
- String key = location.getAbsolutePath();
+ String key = location.toAbsolutePath().toString();
IndexedRelationsSearcherBase searcher = immutableSearchers.get(key);
if (searcher == null) {
searcher = new ImmutableIndexedRelationsSearcher(processor, relation, input);
}
return searcher;
} catch (Exception e) {
- Logger.defaultLogError(e);
+ LOGGER.error("Could not get searcher base for relation {} and input {} in location {}", relation, input, location, e);
return null;
}
}