Mercurial Hosting > luan
diff src/luan/modules/lucene/LuceneIndex.java @ 1395:9dfff82dfc59
finish postgres work
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 09 Sep 2019 01:22:23 -0600 |
parents | cc0dbca576dc |
children | 0dc9837c16be |
line wrap: on
line diff
--- a/src/luan/modules/lucene/LuceneIndex.java Sun Sep 08 22:13:08 2019 -0600 +++ b/src/luan/modules/lucene/LuceneIndex.java Mon Sep 09 01:22:23 2019 -0600 @@ -118,14 +118,14 @@ private static Map<String,LuceneIndex> indexes = new HashMap<String,LuceneIndex>(); - public static Object[] getLuceneIndex(Luan luan,File indexDir,FieldParser defaultFieldParser,String[] defaultFields,LuanTable postgresSpec) + public static Object[] getLuceneIndex(Luan luan,File indexDir,FieldParser defaultFieldParser,String[] defaultFields,LuanFunction completer,LuanTable postgresSpec) throws LuanException, IOException, ClassNotFoundException, SQLException { String key = indexDir.getCanonicalPath(); synchronized(indexes) { LuceneIndex li = indexes.get(key); if( li == null ) { - li = new LuceneIndex(luan,indexDir,defaultFieldParser,defaultFields,key,postgresSpec); + li = new LuceneIndex(luan,indexDir,defaultFieldParser,defaultFields,key,completer,postgresSpec); li.openCount = 1; indexes.put(key,li); } else { @@ -169,7 +169,7 @@ private final PostgresBackup postgresBackup; - private LuceneIndex(Luan luan,File indexDir,FieldParser defaultFieldParser,String[] defaultFields,String key,LuanTable postgresSpec) + private LuceneIndex(Luan luan,File indexDir,FieldParser defaultFieldParser,String[] defaultFields,String key,LuanFunction completer,LuanTable postgresSpec) throws LuanException, IOException, ClassNotFoundException, SQLException { this.luanLogger = luan.getLogger(LuceneIndex.class); @@ -190,8 +190,9 @@ if( postgresSpec == null ) { postgresBackup = null; } else { + if( completer == null ) + throw new LuanException("completer is required for postgres_spec"); Map spec = postgresSpec.asMap(); - LuanFunction completer = Utils.removeRequiredFunction(spec,"completer"); postgresBackup = new PostgresBackup(luan,spec); if( postgresBackup != null ) { if( !wasCreated && postgresBackup.wasCreated ) { @@ -876,6 +877,7 @@ long nextId = postgresBackup.maxId() + 1; postgresBackup.restoreLucene(this); id = idLim = nextId; + saveNextId(nextId); ok = true; writer.commit(); } finally { @@ -906,6 +908,7 @@ } private void checkPostgres(LuanFunction completer) throws IOException, SQLException, LuanException { + luanLogger.info("start postgres check"); final PostgresBackup.Checker postgresChecker; final IndexSearcher searcher; writeLock.lock();