Mercurial Hosting > luan
comparison src/luan/modules/lucene/SupplementingConfig.java @ 1563:8fbcc4747091
remove LuanFunction.luan
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 09 Nov 2020 01:37:57 -0700 |
parents | b89212fd04b5 |
children | c922446f53aa |
comparison
equal
deleted
inserted
replaced
1562:b89212fd04b5 | 1563:8fbcc4747091 |
---|---|
17 import luan.LuanException; | 17 import luan.LuanException; |
18 import luan.LuanRuntimeException; | 18 import luan.LuanRuntimeException; |
19 | 19 |
20 | 20 |
21 final class SupplementingConfig extends MultiFieldParserConfig { | 21 final class SupplementingConfig extends MultiFieldParserConfig { |
22 private final Luan luan; | |
22 private final LuanFunction supplementer; | 23 private final LuanFunction supplementer; |
23 | 24 |
24 SupplementingConfig(Version luceneVersion,MultiFieldParser mfp,LuanFunction supplementer) { | 25 SupplementingConfig(Version luceneVersion,MultiFieldParser mfp,Luan luan,LuanFunction supplementer) { |
25 super(luceneVersion,mfp); | 26 super(luceneVersion,mfp); |
26 LuanCloner cloner = new LuanCloner(LuanCloner.Type.COMPLETE); | 27 LuanCloner cloner = new LuanCloner(LuanCloner.Type.COMPLETE); |
28 this.luan = (Luan)cloner.get(luan); | |
27 this.supplementer = (LuanFunction)cloner.get(supplementer); | 29 this.supplementer = (LuanFunction)cloner.get(supplementer); |
28 } | 30 } |
29 | 31 |
30 public IndexWriterConfig newLuceneConfig() { | 32 @Override public IndexWriterConfig newLuceneConfig() { |
31 IndexWriterConfig luceneConfig = super.newLuceneConfig(); | 33 IndexWriterConfig luceneConfig = super.newLuceneConfig(); |
32 SnapshotDeletionPolicy snapshotDeletionPolicy = new SnapshotDeletionPolicy(luceneConfig.getIndexDeletionPolicy()); | 34 SnapshotDeletionPolicy snapshotDeletionPolicy = new SnapshotDeletionPolicy(luceneConfig.getIndexDeletionPolicy()); |
33 luceneConfig.setIndexDeletionPolicy(snapshotDeletionPolicy); | 35 luceneConfig.setIndexDeletionPolicy(snapshotDeletionPolicy); |
34 return luceneConfig; | 36 return luceneConfig; |
35 } | 37 } |
36 | 38 |
37 public MoreFieldInfo getMoreFieldInfo(Map<String,Object> storedFields) { | 39 @Override public MoreFieldInfo getMoreFieldInfo(Map<String,Object> storedFields) { |
38 if( supplementer == null ) | 40 if( supplementer == null ) |
39 return super.getMoreFieldInfo(storedFields); | 41 return super.getMoreFieldInfo(storedFields); |
40 try { | 42 try { |
41 LuanTable tbl = toTable(storedFields); | 43 LuanTable tbl = toTable(storedFields); |
42 tbl = (LuanTable)supplementer.call(tbl); | 44 tbl = (LuanTable)supplementer.call(luan,tbl); |
43 if( tbl == null ) { | 45 if( tbl == null ) { |
44 return super.getMoreFieldInfo(storedFields); | 46 return super.getMoreFieldInfo(storedFields); |
45 } else { | 47 } else { |
46 return new MoreFieldInfo(toLucene(tbl),Collections.emptyMap()); | 48 return new MoreFieldInfo(toLucene(tbl),Collections.emptyMap()); |
47 } | 49 } |
62 return table; | 64 return table; |
63 } | 65 } |
64 | 66 |
65 static Map<String,Object> toLucene(LuanTable table) throws LuanException { | 67 static Map<String,Object> toLucene(LuanTable table) throws LuanException { |
66 Map<String,Object> map = new LinkedHashMap<String,Object>(); | 68 Map<String,Object> map = new LinkedHashMap<String,Object>(); |
67 for( Map.Entry<Object,Object> entry : table.iterable() ) { | 69 for( Map.Entry<Object,Object> entry : table.rawIterable() ) { |
68 String name = (String)entry.getKey(); | 70 String name = (String)entry.getKey(); |
69 Object value = entry.getValue(); | 71 Object value = entry.getValue(); |
70 if( value instanceof LuanTable ) { | 72 if( value instanceof LuanTable ) { |
71 LuanTable list = (LuanTable)value; | 73 LuanTable list = (LuanTable)value; |
72 if( !list.isList() ) | 74 if( !list.isList() ) |