Update to Lucene 5 (second step)

Change-Id: I6c2a6ceb4c24e5d99f22a1dde89cdb93d1aab891
diff --git a/Changes b/Changes
index 03ca302..707059d 100644
--- a/Changes
+++ b/Changes
@@ -1,4 +1,5 @@
 0.54 2015-09-25
+   	- [performance] Updated Lucene dependency from 4.10.3 to 5.0.0 (diewald)
 
 0.53 2015-09-25
         - [feature] Implemented new KrillCollection (diewald)
diff --git a/pom.xml b/pom.xml
index e27e37d..a72452b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -110,7 +110,7 @@
       <artifactId>lucene-core</artifactId>
       <groupId>org.apache.lucene</groupId>
       <type>jar</type>
-      <version>5.0.0</version>
+      <version>5.3.1</version>
     </dependency>
 
     <!-- Lucene queryparser dependency -->
@@ -118,7 +118,7 @@
       <artifactId>lucene-queryparser</artifactId>
       <groupId>org.apache.lucene</groupId>
       <type>jar</type>
-      <version>5.0.0</version>
+      <version>5.3.1</version>
     </dependency>
 
     <!-- Lucene analyzers dependency -->
@@ -126,7 +126,7 @@
       <artifactId>lucene-analyzers-common</artifactId>
       <groupId>org.apache.lucene</groupId>
       <type>jar</type>
-      <version>5.0.0</version>
+      <version>5.3.1</version>
     </dependency>
 
     <dependency>
diff --git a/src/main/java/de/ids_mannheim/korap/collection/BooleanGroupFilter.java b/src/main/java/de/ids_mannheim/korap/collection/BooleanGroupFilter.java
index b1cad93..d6a750e 100644
--- a/src/main/java/de/ids_mannheim/korap/collection/BooleanGroupFilter.java
+++ b/src/main/java/de/ids_mannheim/korap/collection/BooleanGroupFilter.java
@@ -11,6 +11,7 @@
 import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.LeafReader;
 import org.apache.lucene.util.Bits;
+import org.apache.lucene.util.BitDocIdSet;
 
 import de.ids_mannheim.korap.KrillCollection;
 
@@ -159,7 +160,7 @@
                             log.debug("- Filter to allow all documents");
 
                         bitset.set(0, maxDoc);
-                        return BitsFilteredDocIdSet.wrap(bitset, acceptDocs);
+                        return BitsFilteredDocIdSet.wrap(new BitDocIdSet(bitset), acceptDocs);
                     };
 
                     // There is no possible match
@@ -250,6 +251,6 @@
                     log.debug("- Subresult has card {} ", bitset.cardinality());
             };
         };
-        return BitsFilteredDocIdSet.wrap(bitset, acceptDocs);
+        return BitsFilteredDocIdSet.wrap(new BitDocIdSet(bitset), acceptDocs);
     };
 };
diff --git a/src/main/java/de/ids_mannheim/korap/index/Indexer.java b/src/main/java/de/ids_mannheim/korap/index/Indexer.java
index 1cc5221..33e5eb2 100644
--- a/src/main/java/de/ids_mannheim/korap/index/Indexer.java
+++ b/src/main/java/de/ids_mannheim/korap/index/Indexer.java
@@ -7,6 +7,7 @@
 import static de.ids_mannheim.korap.util.KrillProperties.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import java.nio.file.Paths;
 
 /**
  * Standalone indexer tool for Krill.
@@ -48,7 +49,7 @@
                 "1000");
 
         // Create a new index object based on the directory
-        this.index = new KrillIndex(new MMapDirectory(new File(this.path)));
+        this.index = new KrillIndex(new MMapDirectory(Paths.get(this.path)));
         this.count = 0;
         this.commitCount = Integer.parseInt(commitCount);
     };
diff --git a/src/main/java/de/ids_mannheim/korap/server/Node.java b/src/main/java/de/ids_mannheim/korap/server/Node.java
index 19554e4..058cf33 100644
--- a/src/main/java/de/ids_mannheim/korap/server/Node.java
+++ b/src/main/java/de/ids_mannheim/korap/server/Node.java
@@ -3,6 +3,8 @@
 import java.util.*;
 import java.io.*;
 import java.net.URL;
+import java.nio.file.Paths;
+import java.nio.file.Path;
 
 import org.glassfish.grizzly.http.server.HttpServer;
 import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
@@ -278,10 +280,10 @@
 
             // Get a MMap directory index
             else {
-                File file = new File(path);
+                Path file = Paths.get(path);
 
                 log.info("Loading index from {}", path);
-                if (!file.exists()) {
+                if (!file.toFile().exists()) {
                     log.error("Index not found at {}", path);
                     return null;
                 };
diff --git a/src/test/java/de/ids_mannheim/korap/benchmark/TestBenchmarkSpans.java b/src/test/java/de/ids_mannheim/korap/benchmark/TestBenchmarkSpans.java
index 922792e..6d7de11 100644
--- a/src/test/java/de/ids_mannheim/korap/benchmark/TestBenchmarkSpans.java
+++ b/src/test/java/de/ids_mannheim/korap/benchmark/TestBenchmarkSpans.java
@@ -21,6 +21,8 @@
 import org.junit.runner.RunWith;
 import org.junit.runners.JUnit4;
 
+import java.nio.file.Paths;
+
 @RunWith(JUnit4.class)
 public class TestBenchmarkSpans {
 
@@ -32,7 +34,7 @@
         prop.load(fr);
 
         // Get the real index
-        KrillIndex ki = new KrillIndex(new MMapDirectory(new File(
+        KrillIndex ki = new KrillIndex(new MMapDirectory(Paths.get(
                 prop.getProperty("krill.indexDir"))));
 
         // Create a container for virtual collections:
@@ -86,7 +88,7 @@
         prop.load(fr);
 
         // Get the real index
-        KrillIndex ki = new KrillIndex(new MMapDirectory(new File(
+        KrillIndex ki = new KrillIndex(new MMapDirectory(Paths.get(
                 prop.getProperty("krill.indexDir"))));
 
         // Create a container for virtual collections:
@@ -132,7 +134,7 @@
         prop.load(fr);
 
         // Get the real index
-        KrillIndex ki = new KrillIndex(new MMapDirectory(new File(
+        KrillIndex ki = new KrillIndex(new MMapDirectory(Paths.get(
                 prop.getProperty("krill.indexDir"))));
 
         // Create a container for virtual collections:
@@ -178,7 +180,7 @@
         prop.load(fr);
 
         // Get the real index
-        KrillIndex ki = new KrillIndex(new MMapDirectory(new File(
+        KrillIndex ki = new KrillIndex(new MMapDirectory(Paths.get(
                 prop.getProperty("krill.indexDir"))));
 
         // Create a container for virtual collections:
@@ -324,7 +326,7 @@
         prop.load(fr);
 
         // Get the real index
-        KrillIndex ki = new KrillIndex(new MMapDirectory(new File(
+        KrillIndex ki = new KrillIndex(new MMapDirectory(Paths.get(
                 prop.getProperty("krill.indexDir"))));
 
         // Create a container for virtual collections:
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestIndex.java
index b6119b4..9b08699 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestIndex.java
@@ -196,15 +196,14 @@
     public void indexLucene () throws Exception {
 
         // Base analyzer for searching and indexing
-        StandardAnalyzer analyzer = new StandardAnalyzer(Version.LUCENE_43);
+        StandardAnalyzer analyzer = new StandardAnalyzer();
 
         // Based on
         // http://lucene.apache.org/core/4_0_0/core/org/apache/lucene/
         // analysis/Analyzer.html?is-external=true
 
         // Create configuration with base analyzer
-        IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_43,
-                analyzer);
+        IndexWriterConfig config = new IndexWriterConfig(analyzer);
 
         // Add a document 1 with the correct fields
         IndexWriter w = new IndexWriter(index, config);
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestPosToOffset.java b/src/test/java/de/ids_mannheim/korap/index/TestPosToOffset.java
index 23f8bac..1b0803a 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestPosToOffset.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestPosToOffset.java
@@ -24,9 +24,6 @@
 import org.apache.lucene.search.spans.SpanQuery;
 import org.apache.lucene.search.spans.SpanTermQuery;
 import org.apache.lucene.index.TermContext;
-import org.apache.lucene.util.OpenBitSet;
-import org.apache.lucene.search.DocIdSet;
-import org.apache.lucene.util.DocIdBitSet;
 import org.apache.lucene.util.Bits;
 
 import java.nio.ByteBuffer;
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestRealIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestRealIndex.java
index 837da00..09fd4a5 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestRealIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestRealIndex.java
@@ -17,6 +17,7 @@
 import de.ids_mannheim.korap.response.Result;
 import de.ids_mannheim.korap.query.QueryBuilder;
 import de.ids_mannheim.korap.util.QueryException;
+import java.nio.file.Paths;
 
 public class TestRealIndex {
     KrillIndex ki;
@@ -31,7 +32,7 @@
 
         String indexPath = prop.getProperty("lucene.indexDir");
         System.err.println(indexPath);
-        MMapDirectory md = new MMapDirectory(new File(indexPath));
+        MMapDirectory md = new MMapDirectory(Paths.get(indexPath));
         ki = new KrillIndex(md);
     };
 
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestWPDIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestWPDIndex.java
index 3b96e13..a9fd222 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestWPDIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestWPDIndex.java
@@ -25,6 +25,8 @@
 import de.ids_mannheim.korap.query.SpanNextQuery;
 import de.ids_mannheim.korap.query.SpanRepetitionQuery;
 
+import java.nio.file.Paths;
+
 public class TestWPDIndex {
     long start, end;
     KrillIndex ki;
@@ -60,7 +62,7 @@
         prop.load(is);
 
         String indexPath = prop.getProperty("lucene.indexDir");
-        MMapDirectory md = new MMapDirectory(new File(indexPath));
+        MMapDirectory md = new MMapDirectory(Paths.get(indexPath));
         ki = new KrillIndex(md);
     }