mirror of https://github.com/apache/lucene.git
general cleanup to use java 8 feautures
This commit is contained in:
parent
d6b6e74703
commit
0feca1a974
|
@ -35,7 +35,7 @@ public interface DIHCache extends Iterable<Map<String,Object>> {
|
|||
* includes any parameters needed by the cache impl. This must be called
|
||||
* before any read/write operations are permitted.
|
||||
*/
|
||||
public void open(Context context);
|
||||
void open(Context context);
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
@ -43,14 +43,14 @@ public interface DIHCache extends Iterable<Map<String,Object>> {
|
|||
* but not destroyed.
|
||||
* </p>
|
||||
*/
|
||||
public void close();
|
||||
void close();
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Persists any pending data to the cache
|
||||
* </p>
|
||||
*/
|
||||
public void flush();
|
||||
void flush();
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
@ -67,7 +67,7 @@ public interface DIHCache extends Iterable<Map<String,Object>> {
|
|||
* update a key's documents, first call delete(Object key).
|
||||
* </p>
|
||||
*/
|
||||
public void add(Map<String,Object> rec);
|
||||
void add(Map<String, Object> rec);
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
@ -76,7 +76,7 @@ public interface DIHCache extends Iterable<Map<String,Object>> {
|
|||
* </p>
|
||||
*/
|
||||
@Override
|
||||
public Iterator<Map<String,Object>> iterator();
|
||||
Iterator<Map<String,Object>> iterator();
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
@ -84,20 +84,20 @@ public interface DIHCache extends Iterable<Map<String,Object>> {
|
|||
* match the given key in insertion order.
|
||||
* </p>
|
||||
*/
|
||||
public Iterator<Map<String,Object>> iterator(Object key);
|
||||
Iterator<Map<String,Object>> iterator(Object key);
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Delete all documents associated with the given key
|
||||
* </p>
|
||||
*/
|
||||
public void delete(Object key);
|
||||
void delete(Object key);
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Delete all data from the cache,leaving the empty cache intact.
|
||||
* </p>
|
||||
*/
|
||||
public void deleteAll();
|
||||
void deleteAll();
|
||||
|
||||
}
|
||||
|
|
|
@ -30,6 +30,6 @@ public interface EventListener {
|
|||
*
|
||||
* @param ctx the Context in which this event was called
|
||||
*/
|
||||
public void onEvent(Context ctx);
|
||||
void onEvent(Context ctx);
|
||||
|
||||
}
|
||||
|
|
|
@ -323,13 +323,7 @@ public class XPathEntityProcessor extends EntityProcessorBase {
|
|||
rowIterator = getRowIterator(data, s);
|
||||
} else {
|
||||
try {
|
||||
xpathReader.streamRecords(data, new XPathRecordReader.Handler() {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void handle(Map<String, Object> record, String xpath) {
|
||||
rows.add(readRow(record, xpath));
|
||||
}
|
||||
});
|
||||
xpathReader.streamRecords(data, (record, xpath) -> rows.add(readRow(record, xpath)));
|
||||
} catch (Exception e) {
|
||||
String msg = "Parsing failed for xml, url:" + s + " rows processed:" + rows.size();
|
||||
if (rows.size() > 0) msg += " last row: " + rows.get(rows.size() - 1);
|
||||
|
@ -433,10 +427,7 @@ public class XPathEntityProcessor extends EntityProcessorBase {
|
|||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
xpathReader.streamRecords(data, new XPathRecordReader.Handler() {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void handle(Map<String, Object> record, String xpath) {
|
||||
xpathReader.streamRecords(data, (record, xpath) -> {
|
||||
if (isEnd.get()) {
|
||||
throwExp.set(false);
|
||||
//To end the streaming . otherwise the parsing will go on forever
|
||||
|
@ -451,7 +442,6 @@ public class XPathEntityProcessor extends EntityProcessorBase {
|
|||
return;
|
||||
}
|
||||
offer(row);
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
if(throwExp.get()) exp.set(e);
|
||||
|
|
|
@ -162,12 +162,7 @@ public class XPathRecordReader {
|
|||
*/
|
||||
public List<Map<String, Object>> getAllRecords(Reader r) {
|
||||
final List<Map<String, Object>> results = new ArrayList<>();
|
||||
streamRecords(r, new Handler() {
|
||||
@Override
|
||||
public void handle(Map<String, Object> record, String s) {
|
||||
results.add(record);
|
||||
}
|
||||
});
|
||||
streamRecords(r, (record, s) -> results.add(record));
|
||||
return results;
|
||||
}
|
||||
|
||||
|
@ -182,8 +177,8 @@ public class XPathRecordReader {
|
|||
public void streamRecords(Reader r, Handler handler) {
|
||||
try {
|
||||
XMLStreamReader parser = factory.createXMLStreamReader(r);
|
||||
rootNode.parse(parser, handler, new HashMap<String, Object>(),
|
||||
new Stack<Set<String>>(), false);
|
||||
rootNode.parse(parser, handler, new HashMap<>(),
|
||||
new Stack<>(), false);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -657,7 +652,7 @@ public class XPathRecordReader {
|
|||
/**Implement this interface to stream records as and when one is found.
|
||||
*
|
||||
*/
|
||||
public static interface Handler {
|
||||
public interface Handler {
|
||||
/**
|
||||
* @param record The record map. The key is the field name as provided in
|
||||
* the addField() methods. The value can be a single String (for single
|
||||
|
@ -666,7 +661,7 @@ public class XPathRecordReader {
|
|||
* If there is any change all parsing will be aborted and the Exception
|
||||
* is propagated up
|
||||
*/
|
||||
public void handle(Map<String, Object> record, String xpath);
|
||||
void handle(Map<String, Object> record, String xpath);
|
||||
}
|
||||
|
||||
private static final Pattern ATTRIB_PRESENT_WITHVAL = Pattern
|
||||
|
|
|
@ -20,7 +20,6 @@ import java.io.File;
|
|||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -28,6 +27,7 @@ import org.apache.commons.io.FileUtils;
|
|||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
import org.apache.solr.common.util.SuppressForbidden;
|
||||
import org.apache.solr.common.util.Utils;
|
||||
import org.apache.solr.core.SolrCore;
|
||||
import org.apache.solr.request.LocalSolrQueryRequest;
|
||||
import org.apache.solr.request.SolrQueryRequest;
|
||||
|
@ -145,7 +145,7 @@ public abstract class AbstractDataImportHandlerTestCase extends
|
|||
if (resolver == null) resolver = new VariableResolver();
|
||||
final Context delegate = new ContextImpl(parent, resolver,
|
||||
parentDataSource, currProcess,
|
||||
new HashMap<String, Object>(), null, null);
|
||||
new HashMap<>(), null, null);
|
||||
return new TestContext(entityAttrs, delegate, entityFields, parent == null);
|
||||
}
|
||||
|
||||
|
@ -155,15 +155,7 @@ public abstract class AbstractDataImportHandlerTestCase extends
|
|||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Map createMap(Object... args) {
|
||||
Map result = new LinkedHashMap();
|
||||
|
||||
if (args == null || args.length == 0)
|
||||
return result;
|
||||
|
||||
for (int i = 0; i < args.length - 1; i += 2)
|
||||
result.put(args[i], args[i + 1]);
|
||||
|
||||
return result;
|
||||
return Utils.makeMap(args);
|
||||
}
|
||||
|
||||
@SuppressForbidden(reason = "Needs currentTimeMillis to set modified time for a file")
|
||||
|
|
|
@ -16,13 +16,13 @@
|
|||
*/
|
||||
package org.apache.solr.handler.dataimport;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* <p> Test for XPathRecordReader </p>
|
||||
*
|
||||
|
@ -138,13 +138,10 @@ public class TestXPathRecordReader extends AbstractDataImportHandlerTestCase {
|
|||
|
||||
final List<Map<String, Object>> a = new ArrayList<>();
|
||||
final List<Map<String, Object>> x = new ArrayList<>();
|
||||
rr.streamRecords(new StringReader(xml), new XPathRecordReader.Handler() {
|
||||
@Override
|
||||
public void handle(Map<String, Object> record, String xpath) {
|
||||
rr.streamRecords(new StringReader(xml), (record, xpath) -> {
|
||||
if (record == null) return;
|
||||
if (xpath.equals("/root/a")) a.add(record);
|
||||
if (xpath.equals("/root/x")) x.add(record);
|
||||
}
|
||||
});
|
||||
|
||||
assertEquals(1, a.size());
|
||||
|
|
Loading…
Reference in New Issue