comparison src/luan/modules/lucene/LuceneIndex.java @ 1420:225808b90cee

options handling
author Franklin Schmidt <fschmidt@gmail.com>
date Sat, 26 Oct 2019 22:21:09 -0600
parents dc625408def8
children 103d0ce70385
comparison
equal deleted inserted replaced
1419:59fd2e8b1b9d 1420:225808b90cee
141 private boolean wasCreated; 141 private boolean wasCreated;
142 142
143 private LuceneIndex(Luan luan,File indexDir,LuanTable options) 143 private LuceneIndex(Luan luan,File indexDir,LuanTable options)
144 throws LuanException, IOException, ClassNotFoundException, SQLException 144 throws LuanException, IOException, ClassNotFoundException, SQLException
145 { 145 {
146 Map map = options.asMap(); 146 options = new LuanTable(options);
147 this.version = map.remove("version"); 147 this.version = options.remove("version");
148 FieldParser defaultFieldParser = (FieldParser)map.remove("default_type"); 148 FieldParser defaultFieldParser = (FieldParser)options.remove("default_type");
149 LuanTable defaultFieldsTbl = Utils.removeTable(map,"default_fields"); 149 LuanTable defaultFieldsTbl = Utils.removeTable(options,"default_fields");
150 String[] defaultFields = defaultFieldsTbl==null ? null : (String[])defaultFieldsTbl.asList().toArray(new String[0]); 150 String[] defaultFields = defaultFieldsTbl==null ? null : (String[])defaultFieldsTbl.asList().toArray(new String[0]);
151 LuanFunction completer = Utils.removeFunction(map,"completer"); 151 LuanFunction completer = Utils.removeFunction(options,"completer");
152 LuanTable postgresSpec = Utils.removeTable(map,"postgres_spec"); 152 LuanTable postgresSpec = Utils.removeTable(options,"postgres_spec");
153 Utils.checkEmpty(map); 153 Utils.checkEmpty(options);
154 154
155 this.luanLogger = luan.getLogger(LuceneIndex.class); 155 this.luanLogger = luan.getLogger(LuceneIndex.class);
156 this.defaultFieldParser = defaultFieldParser; 156 this.defaultFieldParser = defaultFieldParser;
157 this.defaultFields = defaultFields; 157 this.defaultFields = defaultFields;
158 mfp = defaultFieldParser==null ? new MultiFieldParser() : new MultiFieldParser(defaultFieldParser,defaultFields); 158 mfp = defaultFieldParser==null ? new MultiFieldParser() : new MultiFieldParser(defaultFieldParser,defaultFields);
169 if( postgresSpec == null ) { 169 if( postgresSpec == null ) {
170 postgresBackup = null; 170 postgresBackup = null;
171 } else { 171 } else {
172 if( completer == null ) 172 if( completer == null )
173 throw new LuanException("completer is required for postgres_spec"); 173 throw new LuanException("completer is required for postgres_spec");
174 Map spec = postgresSpec.asMap(); 174 postgresBackup = new PostgresBackup(luan,postgresSpec);
175 postgresBackup = new PostgresBackup(luan,spec);
176 if( !wasCreated && postgresBackup.wasCreated ) { 175 if( !wasCreated && postgresBackup.wasCreated ) {
177 luanLogger.error("rebuilding postgres backup"); 176 luanLogger.error("rebuilding postgres backup");
178 rebuild_postgres_backup(completer); 177 rebuild_postgres_backup(completer);
179 /* 178 /*
180 } else if( wasCreated && !postgresBackup.wasCreated ) { 179 } else if( wasCreated && !postgresBackup.wasCreated ) {