Commit 59d24da3 authored by mohamad.alturky's avatar mohamad.alturky

bug fixing

parent 32c043cd
......@@ -9,6 +9,7 @@ import com.search.lucene.engine.abstractions.ISearchEngine;
import com.search.lucene.engine.builder.abstractions.IEngineBuilder;
import com.search.lucene.engine.builder.implementations.LuceneEngineBuilder;
import com.search.lucene.indexers.implementations.TextFileIndexer;
import com.search.lucene.performance.Benchmarker;
import com.search.lucene.searchers.implementations.IndexedDocumentSearcher;
import com.search.lucene.settings.Constants;
import org.apache.lucene.document.Document;
......@@ -18,10 +19,14 @@ import org.apache.lucene.search.TopDocs;
public class Lucene {
public static void main(String[] args) throws IOException, ParseException {
public static void main(String[] args) throws Exception {
IEngineBuilder builder = new LuceneEngineBuilder();
ISearchEngine searchEngine = builder.build();
Benchmarker.benchmark(() -> {
searchEngine.createIndexesForDirectory("data");
});
ArrayList<Document> results = searchEngine.search("Julien Leclercq");
IDocumentRepresenterResolver<String> resolver = new DocumentToStringRepresenterResolver();
......
package com.search.lucene.performance;
import java.util.concurrent.Callable;
import java.util.function.Function;
public class Benchmarker {
public static <T> T benchmark(Callable<T> callable) throws Exception {
long startTime = System.currentTimeMillis();
T t = callable.call();
long endTime = System.currentTimeMillis();
long time = endTime - startTime;
System.out.println("The Function " + callable.getClass().getName() + " takes " + time +" ms");
return t;
}
public static void benchmark(RunnableTask callable) throws Exception {
long startTime = System.currentTimeMillis();
callable.run();
long endTime = System.currentTimeMillis();
long time = endTime - startTime;
System.out.println("The Function " + callable.getClass().getName() + " takes " + time +" ms");
}
}
package com.search.lucene.performance;
public interface RunnableTask {
void run() throws Exception;
}
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