mirror of https://github.com/apache/lucene.git
[SOLR-3902] - adding super constructor to FieldMappingException, adding final modifiers where possible, substituting StringBuffer with StringBuilder where possible, for each loops
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1397452 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
72a4fd2978
commit
2e01a46f8c
|
@ -18,9 +18,10 @@ package org.apache.solr.uima.processor;
|
|||
*/
|
||||
|
||||
/**
|
||||
* Exception thrown when an error happening while mapping UIMA CAS model to Solt fields
|
||||
* Exception thrown when an error happening while mapping UIMA CAS model to Solr fields
|
||||
*/
|
||||
public class FieldMappingException extends Exception {
|
||||
public FieldMappingException(Exception e) {
|
||||
super(e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,19 +26,19 @@ import java.util.Map;
|
|||
*/
|
||||
public class SolrUIMAConfiguration {
|
||||
|
||||
private String[] fieldsToAnalyze;
|
||||
private final String[] fieldsToAnalyze;
|
||||
|
||||
private boolean fieldsMerging;
|
||||
private final boolean fieldsMerging;
|
||||
|
||||
private Map<String, Map<String, MapField>> typesFeaturesFieldsMapping;
|
||||
private final Map<String, Map<String, MapField>> typesFeaturesFieldsMapping;
|
||||
|
||||
private String aePath;
|
||||
private final String aePath;
|
||||
|
||||
private Map<String, Object> runtimeParameters;
|
||||
private final Map<String, Object> runtimeParameters;
|
||||
|
||||
private boolean ignoreErrors;
|
||||
private final boolean ignoreErrors;
|
||||
|
||||
private String logField;
|
||||
private final String logField;
|
||||
|
||||
SolrUIMAConfiguration(String aePath, String[] fieldsToAnalyze, boolean fieldsMerging,
|
||||
Map<String, Map<String, MapField>> typesFeaturesFieldsMapping,
|
||||
|
@ -82,7 +82,8 @@ public class SolrUIMAConfiguration {
|
|||
|
||||
static final class MapField {
|
||||
|
||||
private String fieldName, fieldNameFeature;
|
||||
private String fieldName;
|
||||
private final String fieldNameFeature;
|
||||
private boolean prefix; // valid if dynamicField == true
|
||||
// false: *_s, true: s_*
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ import org.apache.solr.uima.processor.SolrUIMAConfiguration.MapField;
|
|||
*/
|
||||
public class SolrUIMAConfigurationReader {
|
||||
|
||||
private NamedList<Object> args;
|
||||
private final NamedList<Object> args;
|
||||
|
||||
public SolrUIMAConfigurationReader(NamedList<Object> args) {
|
||||
this.args = args;
|
||||
|
|
|
@ -38,9 +38,9 @@ public class UIMAToSolrMapper {
|
|||
|
||||
private final Logger log = LoggerFactory.getLogger(UIMAToSolrMapper.class);
|
||||
|
||||
private SolrInputDocument document;
|
||||
private final SolrInputDocument document;
|
||||
|
||||
private JCas cas;
|
||||
private final JCas cas;
|
||||
|
||||
public UIMAToSolrMapper(SolrInputDocument document, JCas cas) {
|
||||
this.document = document;
|
||||
|
@ -64,15 +64,15 @@ public class UIMAToSolrMapper {
|
|||
String fieldNameFeatureValue = fieldNameFeature == null ? null :
|
||||
fs.getFeatureValueAsString(type.getFeatureByBaseName(fieldNameFeature));
|
||||
String fieldName = mapField.getFieldName(fieldNameFeatureValue);
|
||||
log.info(new StringBuffer("mapping ").append(typeName).append("@").append(featureName)
|
||||
log.info(new StringBuilder("mapping ").append(typeName).append("@").append(featureName)
|
||||
.append(" to ").append(fieldName).toString());
|
||||
String featureValue = null;
|
||||
String featureValue;
|
||||
if (fs instanceof Annotation && "coveredText".equals(featureName)) {
|
||||
featureValue = ((Annotation) fs).getCoveredText();
|
||||
} else {
|
||||
featureValue = fs.getFeatureValueAsString(type.getFeatureByBaseName(featureName));
|
||||
}
|
||||
log.info(new StringBuffer("writing ").append(featureValue).append(" in ").append(
|
||||
log.info(new StringBuilder("writing ").append(featureValue).append(" in ").append(
|
||||
fieldName).toString());
|
||||
document.addField(fieldName, featureValue, 1.0f);
|
||||
}
|
||||
|
|
|
@ -73,9 +73,9 @@ public class UIMAUpdateRequestProcessor extends UpdateRequestProcessor {
|
|||
|
||||
/* get the fields to analyze */
|
||||
String[] texts = getTextsToAnalyze(solrInputDocument);
|
||||
for (int i = 0; i < texts.length; i++) {
|
||||
text = texts[i];
|
||||
if (text != null && text.length()>0) {
|
||||
for (String currentText : texts) {
|
||||
text = currentText;
|
||||
if (text != null && text.length() > 0) {
|
||||
/* process the text value */
|
||||
JCas jcas = processText(text);
|
||||
|
||||
|
@ -133,8 +133,8 @@ public class UIMAUpdateRequestProcessor extends UpdateRequestProcessor {
|
|||
String[] textVals;
|
||||
if (merge) {
|
||||
StringBuilder unifiedText = new StringBuilder("");
|
||||
for (int i = 0; i < fieldsToAnalyze.length; i++) {
|
||||
unifiedText.append(String.valueOf(solrInputDocument.getFieldValue(fieldsToAnalyze[i])));
|
||||
for (String aFieldsToAnalyze : fieldsToAnalyze) {
|
||||
unifiedText.append(String.valueOf(solrInputDocument.getFieldValue(aFieldsToAnalyze)));
|
||||
}
|
||||
textVals = new String[1];
|
||||
textVals[0] = unifiedText.toString();
|
||||
|
@ -150,7 +150,7 @@ public class UIMAUpdateRequestProcessor extends UpdateRequestProcessor {
|
|||
/* process a field value executing UIMA the CAS containing it as document text */
|
||||
private JCas processText(String textFieldValue) throws ResourceInitializationException,
|
||||
AnalysisEngineProcessException {
|
||||
log.info(new StringBuffer("Analyzing text").toString());
|
||||
log.info(new StringBuilder("Analyzing text").toString());
|
||||
/* get the UIMA analysis engine */
|
||||
AnalysisEngine ae = aeProvider.getAE();
|
||||
|
||||
|
@ -160,7 +160,7 @@ public class UIMAUpdateRequestProcessor extends UpdateRequestProcessor {
|
|||
|
||||
/* perform analysis on text field */
|
||||
ae.process(jcas);
|
||||
log.info(new StringBuilder("Text processing completed").toString());
|
||||
log.info("Text processing completed");
|
||||
return jcas;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue