Mercurial Hosting > luan
diff src/luan/modules/lucene/LuceneIndex.java @ 1562:b89212fd04b5
remove table.luan
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 08 Nov 2020 16:50:59 -0700 |
parents | 52241b69c339 |
children | 8fbcc4747091 |
line wrap: on
line diff
--- a/src/luan/modules/lucene/LuceneIndex.java Thu Nov 05 20:24:09 2020 -0700 +++ b/src/luan/modules/lucene/LuceneIndex.java Sun Nov 08 16:50:59 2020 -0700 @@ -107,7 +107,7 @@ if( ref != null ) { LuceneIndex li = ref.get(); if( li != null ) { - Object version = options.get("version"); + Object version = options.get(luan,"version"); if( version==null || version.equals(li.version) ) return li; li.closeWriter(); @@ -287,10 +287,10 @@ } } - public void save(LuanTable doc) + public void save(Luan luan,LuanTable doc) throws LuanException, IOException, SQLException { - Object obj = doc.get("id"); + Object obj = doc.get(luan,"id"); Long id; try { id = (Long)obj; @@ -303,13 +303,13 @@ try { if( id == null ) { id = ++this.id; - doc.put("id",id); + doc.put(luan,"id",id); if( postgresBackup != null ) - postgresBackup.add(doc); + postgresBackup.add(luan,doc); writer.addDocument(toLucene(doc)); } else { if( postgresBackup != null ) - postgresBackup.update(doc); + postgresBackup.update(luan,doc); writer.updateDocument( "id", toLucene(doc) ); } if(commit) writer.commit(); @@ -413,7 +413,7 @@ IndexCommit ic = snapshotDeletionPolicy.snapshot(); try { String dir = fsDir.getDirectory().toString(); - LuanTable fileNames = new LuanTable(fn.luan(),new ArrayList(ic.getFileNames())); + LuanTable fileNames = new LuanTable(new ArrayList(ic.getFileNames())); return fn.call(dir,fileNames); } finally { snapshotDeletionPolicy.release(ic); @@ -472,7 +472,7 @@ @Override public Object call(Object[] args) throws LuanException { try { - LuanTable doc = toTable(luan(),searcher.doc(docID)); + LuanTable doc = toTable(searcher.doc(docID)); if( args.length > 0 && "explain".equals(args[0]) ) { Explanation explanation = searcher.explain(query,docID); return new Object[]{doc,explanation}; @@ -605,8 +605,8 @@ return SupplementingConfig.toLucene(table); } - private static LuanTable toTable(Luan luan,Document doc) throws LuanException { - return doc==null ? null : SupplementingConfig.toTable(luan,LuceneUtils.toMap(doc)); + private static LuanTable toTable(Document doc) throws LuanException { + return doc==null ? null : SupplementingConfig.toTable(LuceneUtils.toMap(doc)); } @@ -706,8 +706,8 @@ @Override public void collect(int iDoc) throws IOException { try { Document doc = searcher.doc( docBase + iDoc ); - LuanTable tbl = toTable(luan,doc); - postgresBackup.add(tbl); + LuanTable tbl = toTable(doc); + postgresBackup.add(luan,tbl); } catch(LuanException e) { throw new LuanRuntimeException(e); } catch(SQLException e) { @@ -872,7 +872,7 @@ final int nPostgres = idsPostgres.size(); int iLucene = 0; int iPostgres = 0; - LuanToString lts = new LuanToString(null,null); + LuanToString lts = new LuanToString(luan,null,null); lts.settingsInit.strict = true; lts.settingsInit.numberTypes = true; while( iLucene < nLucene && iPostgres < nPostgres ) { @@ -880,18 +880,18 @@ long idPostgres = idsPostgres.get(iPostgres); if( idLucene < idPostgres ) { iLucene++; - checkPostgres(luan,postgresChecker,lts,idLucene); + checkPostgres(postgresChecker,lts,idLucene); } else if( idLucene > idPostgres ) { iPostgres++; - checkPostgres(luan,postgresChecker,lts,idPostgres); + checkPostgres(postgresChecker,lts,idPostgres); } else { // == LuanTable docPostgres = postgresChecker.getDoc(idPostgres); TopDocs td = searcher.search(new TermQuery(term("id",idLucene)),1); if( td.totalHits != 1 ) throw new RuntimeException(); Document doc = searcher.doc( td.scoreDocs[0].doc ); - LuanTable docLucene = toTable(luan,doc); + LuanTable docLucene = toTable(doc); if( !equal(docPostgres,docLucene) ) { - checkPostgres(luan,postgresChecker,lts,idPostgres); + checkPostgres(postgresChecker,lts,idPostgres); } iLucene++; iPostgres++; @@ -899,11 +899,11 @@ } while( iLucene < nLucene ) { long idLucene = idsLucene.get(iLucene++); - checkPostgres(luan,postgresChecker,lts,idLucene); + checkPostgres(postgresChecker,lts,idLucene); } while( iPostgres < nPostgres ) { long idPostgres = idsPostgres.get(iPostgres++); - checkPostgres(luan,postgresChecker,lts,idPostgres); + checkPostgres(postgresChecker,lts,idPostgres); } } finally { close(searcher); @@ -911,7 +911,7 @@ } } - private void checkPostgres(Luan luan,PostgresBackup.Checker postgresChecker,LuanToString lts,long id) + private void checkPostgres(PostgresBackup.Checker postgresChecker,LuanToString lts,long id) throws IOException, SQLException, LuanException, ParseException { //logger.info("check id "+id); @@ -926,7 +926,7 @@ docLucene = null; } else if( td.totalHits == 1 ) { Document doc = searcher.doc( td.scoreDocs[0].doc ); - docLucene = toTable(luan,doc); + docLucene = toTable(doc); } else throw new RuntimeException(); if( docPostgres == null ) {