Support loading mmapable indices by path

Change-Id: Iaaeb8dc987c3da4b3f72e84535dce975a22444cf
diff --git a/src/main/java/de/ids_mannheim/korap/KrillIndex.java b/src/main/java/de/ids_mannheim/korap/KrillIndex.java
index e19ebd1..2210167 100644
--- a/src/main/java/de/ids_mannheim/korap/KrillIndex.java
+++ b/src/main/java/de/ids_mannheim/korap/KrillIndex.java
@@ -3,6 +3,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.nio.ByteBuffer;
+import java.nio.file.Path;
 import java.time.LocalDate;
 // Java core classes
 import java.util.ArrayList;
@@ -44,6 +45,7 @@
 import org.apache.lucene.search.spans.Spans;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.RAMDirectory;
+import org.apache.lucene.store.MMapDirectory;
 import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.FixedBitSet;
@@ -225,6 +227,19 @@
 
 
     /**
+     * Constructs a new KrillIndex bound to a persistant index,
+     * that will be lifted as an mmap.
+     * 
+     * @param path
+     *            A path pointing to an mmapable index
+     * @throws IOException
+     */
+    public KrillIndex (Path path) throws IOException {
+        this.directory = new MMapDirectory(path);
+    };
+    
+
+    /**
      * Get the version number of the index.
      * 
      * @return A string containing the version number.
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestIndexRevision.java b/src/test/java/de/ids_mannheim/korap/index/TestIndexRevision.java
index 82fab27..c6b0f3c 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestIndexRevision.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestIndexRevision.java
@@ -93,7 +93,7 @@
     public void testIndexRevisionTempFile () throws IOException {
 
         Path tmpdir = Files.createTempDirectory("wiki");
-        KrillIndex ki = new KrillIndex(new MMapDirectory(tmpdir));
+        KrillIndex ki = new KrillIndex(tmpdir);
 
         assertEquals("null", ki.getFingerprint());
         
@@ -204,8 +204,8 @@
 
     @Ignore
     public void testIndexRevisionSample () throws IOException {
-        KrillIndex ki = new KrillIndex(new MMapDirectory(
-                Paths.get(getClass().getResource("/sample-index").getFile())));
+        KrillIndex ki = new KrillIndex(
+                Paths.get(getClass().getResource("/sample-index").getFile()));
 
         assertEquals("Wes8Bd4h1OypPqbWF5njeQ==",ki.getFingerprint());
     };