Mercurial Hosting > luan
diff lucene/src/luan/modules/lucene/LuceneSnapshot.java @ 230:4438cb2e04d0
start lucene
git-svn-id: https://luan-java.googlecode.com/svn/trunk@231 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Tue, 30 Sep 2014 20:03:56 +0000 |
parents | |
children | ef39bc4d3f70 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lucene/src/luan/modules/lucene/LuceneSnapshot.java Tue Sep 30 20:03:56 2014 +0000 @@ -0,0 +1,38 @@ +package luan.modules.lucene; + +import java.io.IOException; +import java.util.Collection; +import org.apache.lucene.index.IndexCommit; + + +public final class LuceneSnapshot { + private final LuceneIndex index; + private final IndexCommit ic; + + LuceneSnapshot(LuceneIndex index) { + this.index = index; + try { + this.ic = index.snapshotDeletionPolicy.snapshot(); + } catch(IOException e) { + throw new RuntimeException(e); + } + } + + // call in finally block + public void close() { + try { + index.snapshotDeletionPolicy.release(ic); + } catch(IOException e) { + throw new RuntimeException(e); + } + } + + public Collection<String> getFileNames() { + try { + return ic.getFileNames(); + } catch(IOException e) { + throw new RuntimeException(e); + } + } + +}