changeset 1529:e6d808f40bbc

minor
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 27 Jul 2020 12:54:31 -0600
parents 3bd4d7963456
children 447b7ef9197f
files src/luan/modules/lucene/LuceneIndex.java src/luan/modules/lucene/SupplementingConfig.java
diffstat 2 files changed, 36 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/src/luan/modules/lucene/LuceneIndex.java	Sun Jul 26 23:11:53 2020 -0600
+++ b/src/luan/modules/lucene/LuceneIndex.java	Mon Jul 27 12:54:31 2020 -0600
@@ -12,7 +12,6 @@
 import java.util.Iterator;
 import java.util.Map;
 import java.util.HashMap;
-import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Set;
@@ -579,35 +578,11 @@
 	}
 
 	static Map<String,Object> toLucene(LuanTable table) throws LuanException {
-		Map<String,Object> map = new LinkedHashMap<String,Object>();
-		for( Map.Entry<Object,Object> entry : table.iterable() ) {
-			String name = (String)entry.getKey();
-			Object value  = entry.getValue();
-			if( value instanceof LuanTable ) {
-				LuanTable list = (LuanTable)value;
-				if( !list.isList() )
-					throw new LuanException("table value for '"+name+"' must be a list");
-				value = list.asList();
-			}
-			map.put(name,value);
-		}
-		return map;
+		return SupplementingConfig.toLucene(table);
 	}
 
 	private static LuanTable toTable(Luan luan,Document doc) throws LuanException {
-		return doc==null ? null : toTable(luan,LuceneUtils.toMap(doc));
-	}
-
-	static LuanTable toTable(Luan luan,Map map) throws LuanException {
-		LuanTable table = new LuanTable(luan);
-		for( Object obj : map.entrySet() ) {
-			Map.Entry entry = (Map.Entry)obj;
-			Object value = entry.getValue();
-			if( value instanceof List )
-				value = new LuanTable(luan,(List)value);
-			table.rawPut( entry.getKey(), value );
-		}
-		return table;
+		return doc==null ? null : SupplementingConfig.toTable(luan,LuceneUtils.toMap(doc));
 	}
 
 
--- a/src/luan/modules/lucene/SupplementingConfig.java	Sun Jul 26 23:11:53 2020 -0600
+++ b/src/luan/modules/lucene/SupplementingConfig.java	Mon Jul 27 12:54:31 2020 -0600
@@ -1,6 +1,8 @@
 package luan.modules.lucene;
 
 import java.util.Map;
+import java.util.LinkedHashMap;
+import java.util.List;
 import java.util.Collections;
 import org.apache.lucene.index.IndexWriterConfig;
 import org.apache.lucene.index.SnapshotDeletionPolicy;
@@ -8,6 +10,7 @@
 import goodjava.lucene.queryparser.MultiFieldParser;
 import goodjava.lucene.api.MultiFieldParserConfig;
 import goodjava.lucene.api.MoreFieldInfo;
+import luan.Luan;
 import luan.LuanFunction;
 import luan.LuanTable;
 import luan.LuanCloner;
@@ -35,15 +38,44 @@
 		if( supplementer == null )
 			return super.getMoreFieldInfo(storedFields);
 		try {
-			LuanTable tbl = LuceneIndex.toTable(supplementer.luan(),storedFields);
+			LuanTable tbl = toTable(supplementer.luan(),storedFields);
 			tbl = (LuanTable)supplementer.call(tbl);
 			if( tbl == null ) {
 				return super.getMoreFieldInfo(storedFields);
 			} else {
-				return new MoreFieldInfo(LuceneIndex.toLucene(tbl),Collections.emptyMap());
+				return new MoreFieldInfo(toLucene(tbl),Collections.emptyMap());
 			}
 		} catch(LuanException e) {
 			throw new LuanRuntimeException(e);
 		}
 	}
+
+	static LuanTable toTable(Luan luan,Map map) throws LuanException {
+		LuanTable table = new LuanTable(luan);
+		for( Object obj : map.entrySet() ) {
+			Map.Entry entry = (Map.Entry)obj;
+			Object value = entry.getValue();
+			if( value instanceof List )
+				value = new LuanTable(luan,(List)value);
+			table.rawPut( entry.getKey(), value );
+		}
+		return table;
+	}
+
+	static Map<String,Object> toLucene(LuanTable table) throws LuanException {
+		Map<String,Object> map = new LinkedHashMap<String,Object>();
+		for( Map.Entry<Object,Object> entry : table.iterable() ) {
+			String name = (String)entry.getKey();
+			Object value  = entry.getValue();
+			if( value instanceof LuanTable ) {
+				LuanTable list = (LuanTable)value;
+				if( !list.isList() )
+					throw new LuanException("table value for '"+name+"' must be a list");
+				value = list.asList();
+			}
+			map.put(name,value);
+		}
+		return map;
+	}
+
 }