*******************************************************************************/
package org.simantics.db.indexing;
-import gnu.trove.map.hash.THashMap;
-import gnu.trove.set.hash.TLongHashSet;
-
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.CorruptIndexException;
import org.apache.lucene.index.IndexableField;
-import org.apache.lucene.queryparser.classic.ParseException;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.ScoreDoc;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.layer0.adapter.GenericRelation;
import org.simantics.utils.datastructures.Pair;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import gnu.trove.map.hash.THashMap;
+import gnu.trove.set.hash.TLongHashSet;
/**
* @author Tuukka Lehtonen
*/
public class IndexedRelationsMemorySearcher extends IndexedRelationsSearcherBase {
+ private static final Logger LOGGER = LoggerFactory.getLogger(IndexedRelationsMemorySearcher.class);
+
final IndexedRelationsSearcher backend;
final GenericRelation r;
super.removeIndex(monitor, r, processor, key, keyValues);
}
- public List<Object[]> allDocs(IProgressMonitor monitor, Session session) throws ParseException, IOException,
- DatabaseException {
+ public List<Object[]> allDocs(IProgressMonitor monitor, Session session) throws IOException {
Query query = new MatchAllDocsQuery();
}
for(ScoreDoc scoreDoc:scoreDocs) {
-
- try {
-
- Document doc = reader.document(scoreDoc.doc);
- List<IndexableField> fs = doc.getFields();
- Object[] o = new Object[fs.size()];
- int index = 0;
- for (IndexableField f : fs) {
- String clazz = classMap.get(f.name());
- if ("Long".equals(clazz)) {
- o[index++] = Long.parseLong(f.stringValue());
- } else {
- o[index++] = f.stringValue();
- }
+ Document doc = reader.document(scoreDoc.doc);
+ List<IndexableField> fs = doc.getFields();
+ Object[] o = new Object[fs.size()];
+ int index = 0;
+ for (IndexableField f : fs) {
+ String clazz = classMap.get(f.name());
+ if ("Long".equals(clazz)) {
+ o[index++] = Long.parseLong(f.stringValue());
+ } else {
+ o[index++] = f.stringValue();
}
- result.add(o);
- } catch (CorruptIndexException e) {
- throw new DatabaseException(e);
- } catch (IOException e) {
- throw new DatabaseException(e);
}
-
+ result.add(o);
}
changeState(monitor, session, State.READY);
@Override
Directory getDirectory(Session session) throws IOException {
MemoryIndexing mem = MemoryIndexing.getInstance(session);
- String path = indexPath.getAbsolutePath();
+ String path = indexPath.toAbsolutePath().toString();
return mem.getDirectory(path, Queries.getAnalyzer());
}
@Override
Throwable bestEffortClear(IProgressMonitor monitor, Session session) {
-
- setProblem(null);
-
MemoryIndexing mem = MemoryIndexing.getInstance(session);
changed.clear();
- String path = indexPath.getAbsolutePath();
+ String path = indexPath.toAbsolutePath().toString();
mem.remove(path);
return null;
protected boolean requireChangeInfoOnReplace() {
return false;
}
+
+ @Override
+ protected Logger getLogger() {
+ return LOGGER;
+ }
}