Mercurial Hosting > luan
diff src/luan/modules/lucene/LuceneIndex.java @ 1556:52241b69c339
lucene logging
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 11 Oct 2020 17:28:16 -0600 |
parents | 26c51acf00f3 |
children | b89212fd04b5 |
line wrap: on
line diff
--- a/src/luan/modules/lucene/LuceneIndex.java Tue Oct 06 20:53:43 2020 -0600 +++ b/src/luan/modules/lucene/LuceneIndex.java Sun Oct 11 17:28:16 2020 -0600 @@ -421,7 +421,14 @@ } public void tag(String tag) throws IOException { - writer.tag(tag); + boolean commit = !writeLock.isHeldByCurrentThread(); + writeLock.lock(); + try { + writer.tag(tag); + if(commit) writer.commit(); + } finally { + writeLock.unlock(); + } } @@ -770,6 +777,20 @@ writer.addDocument(toLucene(doc)); } + public void relog() + throws IOException, LuanException + { + logger.info("start relog"); + writeLock.lock(); + try { + LoggingIndexWriter loggingWriter = (LoggingIndexWriter)writer; + loggingWriter.logLucene(); + } finally { + writeLock.unlock(); + } + logger.info("end relog"); + } + public void restore_from_log(LuanFunction handler) throws IOException, LuanException, SQLException, ParseException { @@ -791,8 +812,6 @@ boolean ok = false; try { LoggingIndexWriter loggingWriter = (LoggingIndexWriter)writer; - IndexWriter iw = writer.getLuceneIndexWriter(); - iw.deleteAll(); loggingWriter.playLogs(opDoer); ok = true; wrote(); @@ -831,13 +850,6 @@ logger.info("end check"); } - public void rebuild_log() throws IOException { - logger.info("start rebuild_log"); - LoggingIndexWriter loggingWriter = (LoggingIndexWriter)writer; - loggingWriter.newLogs(); - logger.info("end rebuild_log"); - } - private void checkPostgres(Luan luan) throws IOException, SQLException, LuanException, ParseException {