comparison 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
comparison
equal deleted inserted replaced
706:30c87c859277 707:1ed9e55f0be8
274 wrote(); 274 wrote();
275 } 275 }
276 return id; 276 return id;
277 } 277 }
278 278
279 279 /*
280 public void backup(String zipFile) throws LuanException, IOException { 280 public void backup(String zipFile) throws LuanException, IOException {
281 if( !zipFile.endsWith(".zip") ) 281 if( !zipFile.endsWith(".zip") )
282 throw new LuanException("file "+zipFile+" doesn't end with '.zip'"); 282 throw new LuanException("file "+zipFile+" doesn't end with '.zip'");
283 IndexCommit ic = snapshotDeletionPolicy.snapshot(); 283 IndexCommit ic = snapshotDeletionPolicy.snapshot();
284 try { 284 try {
289 Utils.copyAll(in,out); 289 Utils.copyAll(in,out);
290 in.close(); 290 in.close();
291 out.closeEntry(); 291 out.closeEntry();
292 } 292 }
293 out.close(); 293 out.close();
294 } finally {
295 snapshotDeletionPolicy.release(ic);
296 }
297 }
298 */
299 public Object snapshot(LuanState luan,LuanFunction fn) throws LuanException, IOException {
300 IndexCommit ic = snapshotDeletionPolicy.snapshot();
301 try {
302 String dir = fileDir.toString();
303 LuanTable fileNames = new LuanTable(new ArrayList(ic.getFileNames()));
304 return fn.call(luan,new Object[]{dir,fileNames});
294 } finally { 305 } finally {
295 snapshotDeletionPolicy.release(ic); 306 snapshotDeletionPolicy.release(ic);
296 } 307 }
297 } 308 }
298 309