Mercurial Hosting > luan
diff lucene/src/luan/modules/lucene/LuceneIndex.java @ 707:1ed9e55f0be8
replace lucene.backup with lucene.zip implemented in luan, and add lucene.snapshot
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 18 May 2016 15:46:51 -0600 |
parents | 90c89138c234 |
children | 01e68da6983b |
line wrap: on
line diff
--- a/lucene/src/luan/modules/lucene/LuceneIndex.java Tue May 17 19:00:25 2016 -0600 +++ b/lucene/src/luan/modules/lucene/LuceneIndex.java Wed May 18 15:46:51 2016 -0600 @@ -276,7 +276,7 @@ return id; } - +/* public void backup(String zipFile) throws LuanException, IOException { if( !zipFile.endsWith(".zip") ) throw new LuanException("file "+zipFile+" doesn't end with '.zip'"); @@ -295,6 +295,17 @@ snapshotDeletionPolicy.release(ic); } } +*/ + public Object snapshot(LuanState luan,LuanFunction fn) throws LuanException, IOException { + IndexCommit ic = snapshotDeletionPolicy.snapshot(); + try { + String dir = fileDir.toString(); + LuanTable fileNames = new LuanTable(new ArrayList(ic.getFileNames())); + return fn.call(luan,new Object[]{dir,fileNames}); + } finally { + snapshotDeletionPolicy.release(ic); + } + }