This is an automated email from the ASF dual-hosted git repository.

srdo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/storm.git


The following commit(s) were added to refs/heads/master by this push:
     new d5434f5  STORM-3433: pmml: fix all checkstyle warnings
     new a4a1070  Merge pull request #3049 from krichter722/checkstyle-pmml
d5434f5 is described below

commit d5434f5e20effcea7be05c28416528470d90bc30
Author: Karl-Philipp Richter <krich...@posteo.de>
AuthorDate: Thu Jun 27 23:56:55 2019 +0200

    STORM-3433: pmml: fix all checkstyle warnings
---
 external/storm-pmml/pom.xml                        |  2 +-
 .../org/apache/storm/pmml/PMMLPredictorBolt.java   | 21 ++++---
 .../org/apache/storm/pmml/model/ModelOutputs.java  | 12 ++--
 .../storm/pmml/model/jpmml/JpmmlModelOutputs.java  | 20 +++---
 .../org/apache/storm/pmml/runner/ModelRunner.java  |  7 ++-
 .../apache/storm/pmml/runner/PmmlModelRunner.java  |  5 +-
 .../storm/pmml/runner/jpmml/JPmmlModelRunner.java  | 20 +++---
 .../storm/pmml/runner/jpmml/JpmmlFactory.java      | 73 +++++++++++++---------
 8 files changed, 89 insertions(+), 71 deletions(-)

diff --git a/external/storm-pmml/pom.xml b/external/storm-pmml/pom.xml
index 1c9278b..0a834ff 100644
--- a/external/storm-pmml/pom.xml
+++ b/external/storm-pmml/pom.xml
@@ -94,7 +94,7 @@
                 <!--Note - the version would be inherited-->
                 <configuration>
 
-                    <maxAllowedViolations>67</maxAllowedViolations>
+                    <maxAllowedViolations>0</maxAllowedViolations>
                 </configuration>
             </plugin>
             <plugin>
diff --git 
a/external/storm-pmml/src/main/java/org/apache/storm/pmml/PMMLPredictorBolt.java
 
b/external/storm-pmml/src/main/java/org/apache/storm/pmml/PMMLPredictorBolt.java
index e7825c0..0d9bc4c 100644
--- 
a/external/storm-pmml/src/main/java/org/apache/storm/pmml/PMMLPredictorBolt.java
+++ 
b/external/storm-pmml/src/main/java/org/apache/storm/pmml/PMMLPredictorBolt.java
@@ -18,6 +18,9 @@
 
 package org.apache.storm.pmml;
 
+import java.util.List;
+import java.util.Map;
+
 import org.apache.storm.pmml.model.ModelOutputs;
 import org.apache.storm.pmml.runner.ModelRunner;
 import org.apache.storm.pmml.runner.ModelRunnerFactory;
@@ -32,9 +35,7 @@ import org.apache.storm.utils.TupleUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.List;
-import java.util.Map;
-
+@SuppressWarnings("checkstyle:AbbreviationAsWordInName")
 public class PMMLPredictorBolt extends BaseTickTupleAwareRichBolt {
     protected static final Logger LOG = 
LoggerFactory.getLogger(PMMLPredictorBolt.class);
 
@@ -52,7 +53,7 @@ public class PMMLPredictorBolt extends 
BaseTickTupleAwareRichBolt {
      * Creates an instance of {@link PMMLPredictorBolt} that executes, for 
every tuple, the runner constructed with
      * the {@link ModelRunnerFactory} specified in the parameter
      * The {@link PMMLPredictorBolt} instantiated with this constructor 
declares the output fields as specified
-     * by the {@link ModelOutputs} parameter
+     * by the {@link ModelOutputs} parameter.
      */
     public PMMLPredictorBolt(ModelRunnerFactory modelRunnerFactory, 
ModelOutputs modelOutputs) {
         this.outputs = modelOutputs;
@@ -95,11 +96,11 @@ public class PMMLPredictorBolt extends 
BaseTickTupleAwareRichBolt {
 
     @Override
     public String toString() {
-        return "PMMLPredictorBolt{" +
-                "outputFields=" + outputs +
-                ", runnerFactory=" + runnerFactory.getClass().getName() +
-                ", runner=" + runner +
-                ", collector=" + collector +
-                "} ";
+        return "PMMLPredictorBolt{"
+                + "outputFields=" + outputs
+                + ", runnerFactory=" + runnerFactory.getClass().getName()
+                + ", runner=" + runner
+                + ", collector=" + collector
+                + "} ";
     }
 }
diff --git 
a/external/storm-pmml/src/main/java/org/apache/storm/pmml/model/ModelOutputs.java
 
b/external/storm-pmml/src/main/java/org/apache/storm/pmml/model/ModelOutputs.java
index 5f61045..8322a8a 100644
--- 
a/external/storm-pmml/src/main/java/org/apache/storm/pmml/model/ModelOutputs.java
+++ 
b/external/storm-pmml/src/main/java/org/apache/storm/pmml/model/ModelOutputs.java
@@ -18,25 +18,27 @@
 
 package org.apache.storm.pmml.model;
 
-import org.apache.storm.pmml.PMMLPredictorBolt;
-import org.apache.storm.tuple.Fields;
-
 import java.io.Serializable;
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.storm.pmml.PMMLPredictorBolt;
+import org.apache.storm.tuple.Fields;
+
 /**
- * Represents the streams and output fields declared by the {@link 
PMMLPredictorBolt}
+ * Represents the streams and output fields declared by the {@link 
PMMLPredictorBolt}.
  */
 public interface ModelOutputs extends Serializable {
+
     /**
+     * Stream fields.
      * @return a map with the output fields declared for each stream by the 
{@link PMMLPredictorBolt}
      */
     Map<String, ? extends Fields> streamFields();
 
     /**
      * Convenience method that returns a set with all the streams declared by 
the {@link PMMLPredictorBolt}.
-     * By default this this method calls {@link #streamFields()}{@code 
.keySet()}
+     * By default this this method calls {@link #streamFields()}{@code 
.keySet()}.
      * @return The set with all declared streams
      */
     default Set<String> streams() {
diff --git 
a/external/storm-pmml/src/main/java/org/apache/storm/pmml/model/jpmml/JpmmlModelOutputs.java
 
b/external/storm-pmml/src/main/java/org/apache/storm/pmml/model/jpmml/JpmmlModelOutputs.java
index 47ea66c..69cf3ec 100644
--- 
a/external/storm-pmml/src/main/java/org/apache/storm/pmml/model/jpmml/JpmmlModelOutputs.java
+++ 
b/external/storm-pmml/src/main/java/org/apache/storm/pmml/model/jpmml/JpmmlModelOutputs.java
@@ -18,14 +18,6 @@
 
 package org.apache.storm.pmml.model.jpmml;
 
-import org.apache.storm.pmml.model.ModelOutputs;
-import org.apache.storm.pmml.runner.jpmml.JpmmlFactory;
-import org.apache.storm.tuple.Fields;
-import org.apache.storm.utils.Utils;
-import org.dmg.pmml.FieldName;
-import org.dmg.pmml.PMML;
-import org.jpmml.evaluator.Evaluator;
-
 import java.io.File;
 import java.io.InputStream;
 import java.util.ArrayList;
@@ -38,6 +30,14 @@ import java.util.Set;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 
+import org.apache.storm.pmml.model.ModelOutputs;
+import org.apache.storm.pmml.runner.jpmml.JpmmlFactory;
+import org.apache.storm.tuple.Fields;
+import org.apache.storm.utils.Utils;
+import org.dmg.pmml.FieldName;
+import org.dmg.pmml.PMML;
+import org.jpmml.evaluator.Evaluator;
+
 public class JpmmlModelOutputs implements ModelOutputs {
     private final Map<String, ? extends Fields> declared;
 
@@ -60,7 +60,7 @@ public class JpmmlModelOutputs implements ModelOutputs {
     /**
      * Factory method that creates an instance of {@link ModelOutputs} that 
declares
      * the {@code predicted} and {@code output} fields specified in the {@link 
PMML} model
-     * specified as argument into the {@code default} stream
+     * specified as argument into the {@code default} stream.
      */
     public static ModelOutputs toDefaultStream(PMML pmmlModel) {
         Objects.requireNonNull(pmmlModel);
@@ -100,7 +100,7 @@ public class JpmmlModelOutputs implements ModelOutputs {
     /**
      * Factory method that creates an instance of {@link ModelOutputs} that 
declares
      * the {@code predicted} and {@code output} fields specified in the {@link 
PMML} model
-     * specified as argument into the list of streams specified
+     * specified as argument into the list of streams specified.
      */
     public static ModelOutputs toStreams(PMML pmmlModel, List<String> streams) 
{
         return create(pmmlModel, streams);
diff --git 
a/external/storm-pmml/src/main/java/org/apache/storm/pmml/runner/ModelRunner.java
 
b/external/storm-pmml/src/main/java/org/apache/storm/pmml/runner/ModelRunner.java
index 11da515..ef1e741 100644
--- 
a/external/storm-pmml/src/main/java/org/apache/storm/pmml/runner/ModelRunner.java
+++ 
b/external/storm-pmml/src/main/java/org/apache/storm/pmml/runner/ModelRunner.java
@@ -18,13 +18,14 @@
 
 package org.apache.storm.pmml.runner;
 
-import org.apache.storm.pmml.model.ModelOutputs;
-import org.apache.storm.tuple.Tuple;
-
 import java.util.List;
 import java.util.Map;
 
+import org.apache.storm.pmml.model.ModelOutputs;
+import org.apache.storm.tuple.Tuple;
+
 public interface ModelRunner {
+
     /**
      * Creates and returns a map with the predicted scores that are to be 
emitted on each stream.
      * The keys of this map are the stream ids, and the values the predicted 
scores.
diff --git 
a/external/storm-pmml/src/main/java/org/apache/storm/pmml/runner/PmmlModelRunner.java
 
b/external/storm-pmml/src/main/java/org/apache/storm/pmml/runner/PmmlModelRunner.java
index ae23c85..7d2ece8 100644
--- 
a/external/storm-pmml/src/main/java/org/apache/storm/pmml/runner/PmmlModelRunner.java
+++ 
b/external/storm-pmml/src/main/java/org/apache/storm/pmml/runner/PmmlModelRunner.java
@@ -21,7 +21,7 @@ package org.apache.storm.pmml.runner;
 import org.apache.storm.tuple.Tuple;
 
 /**
- * Runner for models defined using PMML
+ * Runner for models defined using PMML.
  *
  * @param <I> type of the input source.  For Storm it is typically a {@link 
Tuple}
  * @param <R> the type of extracted raw input
@@ -29,6 +29,7 @@ import org.apache.storm.tuple.Tuple;
  * @param <S> the type of predicted scores
  */
 public interface PmmlModelRunner<I, R, P, S> extends ModelRunner {
+
     /**
      * Extracts from the tuple the raw inputs that are to be scored according 
to the predictive model.
      *
@@ -46,7 +47,7 @@ public interface PmmlModelRunner<I, R, P, S> extends 
ModelRunner {
     P preProcessInputs(R rawInputs);
 
     /**
-     * Compute the predicted scores from the pre-processed inputs in the step 
above
+     * Compute the predicted scores from the pre-processed inputs in the step 
above.
      *
      * @param preProcInputs that are to be preprocessed
      * @return predicted scores
diff --git 
a/external/storm-pmml/src/main/java/org/apache/storm/pmml/runner/jpmml/JPmmlModelRunner.java
 
b/external/storm-pmml/src/main/java/org/apache/storm/pmml/runner/jpmml/JPmmlModelRunner.java
index 7431e36..ecdbbb4 100644
--- 
a/external/storm-pmml/src/main/java/org/apache/storm/pmml/runner/jpmml/JPmmlModelRunner.java
+++ 
b/external/storm-pmml/src/main/java/org/apache/storm/pmml/runner/jpmml/JPmmlModelRunner.java
@@ -18,6 +18,13 @@
 
 package org.apache.storm.pmml.runner.jpmml;
 
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
 import org.apache.storm.pmml.model.ModelOutputs;
 import org.apache.storm.pmml.runner.PmmlModelRunner;
 import org.apache.storm.tuple.Tuple;
@@ -28,19 +35,12 @@ import org.jpmml.evaluator.FieldValue;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
 /**
  * JPMML implementation of {@link PmmlModelRunner}. It extracts the raw inputs 
from the tuple for all
  * 'active fields', and builds a tuple with the predicted scores for the 
'predicted fields' and 'output fields'.
  * In this implementation all the declared streams will have the same scored 
tuple.
  *
- * The 'predicted', 'active', and 'output' fields are extracted from the PMML 
model.
+ * <p>The 'predicted', 'active', and 'output' fields are extracted from the 
PMML model.
  */
 public class JPmmlModelRunner implements PmmlModelRunner<Tuple,
         Map<FieldName, Object>,
@@ -64,6 +64,7 @@ public class JPmmlModelRunner implements 
PmmlModelRunner<Tuple,
     }
 
     /**
+     * Extract raw inputs.
      * @return The raw inputs extracted from the tuple for all 'active fields'
      */
     @Override
@@ -97,8 +98,9 @@ public class JPmmlModelRunner implements 
PmmlModelRunner<Tuple,
     }
 
     /**
+     * Retrieve scores.
      * @return the predicted scores for the 'predicted fields' and 'output 
fields'.
-     * All the declared streams will have the same scored tuple.
+     *     All the declared streams will have the same scored tuple.
      */
     @Override
     public Map<String, List<Object>> scoredTuplePerStream(Tuple input) {
diff --git 
a/external/storm-pmml/src/main/java/org/apache/storm/pmml/runner/jpmml/JpmmlFactory.java
 
b/external/storm-pmml/src/main/java/org/apache/storm/pmml/runner/jpmml/JpmmlFactory.java
index 8170e12..c0cca3a 100644
--- 
a/external/storm-pmml/src/main/java/org/apache/storm/pmml/runner/jpmml/JpmmlFactory.java
+++ 
b/external/storm-pmml/src/main/java/org/apache/storm/pmml/runner/jpmml/JpmmlFactory.java
@@ -18,6 +18,14 @@
 
 package org.apache.storm.pmml.runner.jpmml;
 
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+import java.util.Objects;
+
+import javax.xml.bind.JAXBException;
+
 import org.apache.storm.pmml.model.ModelOutputs;
 import org.apache.storm.pmml.runner.ModelRunner;
 import org.apache.storm.pmml.runner.ModelRunnerFactory;
@@ -30,21 +38,14 @@ import org.jpmml.evaluator.ModelEvaluatorFactory;
 import org.jpmml.manager.PMMLManager;
 import org.xml.sax.SAXException;
 
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Map;
-import java.util.Objects;
-
-import javax.xml.bind.JAXBException;
-
 /*
- * This class consists exclusively of static factory methods that create
- * object instances that are essential to work with the Jpmml library
+ * This class consists exclusively of static factory methods that create 
instances that are essential to work with the
+ *  Jpmml library.
  */
 public class JpmmlFactory {
+
     /**
-     * Creates a new {@link PMML} object representing the PMML model defined 
in the XML {@link File} specified as argument
+     * Creates a new {@link PMML} object representing the PMML model defined 
in the XML {@link File} specified as argument.
      */
     public static PMML newPmml(File file) throws JAXBException, SAXException, 
IOException {
         Objects.requireNonNull(file);
@@ -52,7 +53,7 @@ public class JpmmlFactory {
     }
 
     /**
-     * Creates a new {@link PMML} object representing the PMML model defined 
in the {@link InputStream} specified as argument
+     * Creates a new {@link PMML} object representing the PMML model defined 
in the {@link InputStream} specified as argument.
      */
     public static PMML newPmml(InputStream stream) throws JAXBException, 
SAXException, IOException {
         Objects.requireNonNull(stream);
@@ -60,16 +61,16 @@ public class JpmmlFactory {
     }
 
     /**
-     * Creates a new {@link PMML} object representing the PMML model uploaded 
to the Blobstore with key specified as argument.
-     * Uses Storm config as returned by {@code Utils.readStormConfig()} to get 
the Blobstore client
+     * Creates a new {@link PMML} object representing the PMML model uploaded 
to the Blobstore with key specified as
+     * argument. Uses Storm config as returned by {@code 
Utils.readStormConfig()} to get the Blobstore client.
      */
     public static PMML newPmml(String blobKey) throws JAXBException, 
SAXException, IOException {
         return newPmml(blobKey, Utils.readStormConfig());
     }
 
     /**
-     * Creates a new {@link PMML} object representing the PMML model uploaded 
to the Blobstore with key specified as argument.
-     * Uses the specified configuration to get the Blobstore client
+     * Creates a new {@link PMML} object representing the PMML model uploaded 
to the Blobstore with key specified as
+     * argument. Uses the specified configuration to get the Blobstore client.
      */
     public static PMML newPmml(String blobKey, Map<String, Object> config) 
throws JAXBException, SAXException, IOException {
         Objects.requireNonNull(blobKey);
@@ -80,7 +81,7 @@ public class JpmmlFactory {
     // ==================   Get PMML Model from Blobstore ==================
 
     /**
-     * Returns PMML model from Blobstore. Uses Storm config as returned by 
{@code Utils.readStormConfig()}
+     * Returns PMML model from Blobstore. Uses Storm config as returned by 
{@code Utils.readStormConfig()}.
      * @param blobKey key of PMML model in Blobstore
      */
     public static InputStream getPmmlModelBlob(String blobKey) {
@@ -88,7 +89,7 @@ public class JpmmlFactory {
     }
 
     /**
-     * Returns PMML model from Blobstore
+     * Returns PMML model from Blobstore.
      * @param blobKey key of PMML model in Blobstore
      * @param config Configuration to use to get Blobstore client
      */
@@ -98,14 +99,17 @@ public class JpmmlFactory {
         try {
             return Utils.getClientBlobStore(config).getBlob(blobKey);
         } catch (Exception e) {
-            throw new RuntimeException("Failed to download PMML Model from 
Blobstore using blob key [" + blobKey + "]", e);
+            throw new RuntimeException("Failed to download PMML Model from 
Blobstore using blob key ["
+                    + blobKey
+                    + "]",
+                    e);
         }
     }
 
     // ==================   Evaluator   ==================
 
     /**
-     * Creates a new {@link Evaluator} object representing the PMML model 
defined in the {@link PMML} argument
+     * Creates a new {@link Evaluator} object representing the PMML model 
defined in the {@link PMML} argument.
      */
     public static Evaluator newEvaluator(PMML pmml) {
         Objects.requireNonNull(pmml);
@@ -114,7 +118,8 @@ public class JpmmlFactory {
     }
 
     /**
-     * Creates a new {@link Evaluator} object representing the PMML model 
defined in the XML {@link File} specified as argument
+     * Creates a new {@link Evaluator} object representing the PMML model 
defined in the XML {@link File} specified as
+     * argument.
      */
     public static Evaluator newEvaluator(File file) throws IOException, 
JAXBException, SAXException {
         Objects.requireNonNull(file);
@@ -122,7 +127,8 @@ public class JpmmlFactory {
     }
 
     /**
-     * Creates a new {@link Evaluator} object representing the PMML model 
defined in the XML {@link File} specified as argument
+     * Creates a new {@link Evaluator} object representing the PMML model 
defined in the XML {@link File} specified as
+     * argument.
      */
     public static Evaluator newEvaluator(InputStream stream) throws 
IOException, JAXBException, SAXException {
         Objects.requireNonNull(stream);
@@ -130,8 +136,9 @@ public class JpmmlFactory {
     }
 
     /**
-     * Creates a new {@link Evaluator} object representing the PMML model 
uploaded to the Blobstore using the blob key specified as argument.
-     * Uses Storm config as returned by {@code Utils.readStormConfig()} to get 
the Blobstore client
+     * Creates a new {@link Evaluator} object representing the PMML model 
uploaded to the Blobstore using the blob key
+     * specified as argument. Uses Storm config as returned by {@code 
Utils.readStormConfig()} to get the Blobstore
+     * client.
      */
     public static Evaluator newEvaluator(String blobKey) throws IOException, 
JAXBException, SAXException {
         Objects.requireNonNull(blobKey);
@@ -139,8 +146,8 @@ public class JpmmlFactory {
     }
 
     /**
-     * Creates a new {@link Evaluator} object representing the PMML model 
uploaded to the Blobstore using the blob key specified as argument.
-     * Uses the specified configuration to get the Blobstore client
+     * Creates a new {@link Evaluator} object representing the PMML model 
uploaded to the Blobstore using the blob key
+     * specified as argument. Uses the specified configuration to get the 
Blobstore client.
      */
     public static Evaluator newEvaluator(String blobKey, Map<String, Object> 
config) throws IOException, JAXBException, SAXException {
         Objects.requireNonNull(blobKey);
@@ -163,7 +170,7 @@ public class JpmmlFactory {
         }
 
         /**
-         * Creates a {@link JPmmlModelRunner} writing to the default stream
+         * Creates a {@link JPmmlModelRunner} writing to the default stream.
          */
         @Override
         public ModelRunner newModelRunner() {
@@ -176,7 +183,7 @@ public class JpmmlFactory {
     }
 
     /**
-     * Creates a {@link JPmmlModelRunner} writing to the default stream. PMML 
Model is downloaded from Blobstore
+     * Creates a {@link JPmmlModelRunner} writing to the default stream. PMML 
Model is downloaded from Blobstore.
      */
     public static class ModelRunnerFromBlobStore implements ModelRunnerFactory 
{
         private final String blobKey;
@@ -184,7 +191,7 @@ public class JpmmlFactory {
         private final Map<String, Object> config;
 
         /**
-         * Uses Storm config as returned by {@code Utils.readStormConfig()}
+         * Uses Storm config as returned by {@code Utils.readStormConfig()}.
          * @param blobKey key of PMML model in Blobstore
          */
         public ModelRunnerFromBlobStore(String blobKey, ModelOutputs 
modelOutputs) {
@@ -192,6 +199,7 @@ public class JpmmlFactory {
         }
 
         /**
+         * Create a new {@code ModelRunnerFromBlobStore}.
          * @param blobKey key of PMML model in Blobstore
          * @param config Configuration to use to get Blobstore client
          */
@@ -210,8 +218,11 @@ public class JpmmlFactory {
             try {
                 return new JPmmlModelRunner(JpmmlFactory.newEvaluator(blobKey, 
config), modelOutputs);
             } catch (Exception e) {
-                throw new RuntimeException(String.format("Failed to create 
ModelRunner from model in Blobstore " +
-                        "using blob key [%s] and config [%s]", blobKey, 
config), e);
+                throw new RuntimeException(String.format("Failed to create 
ModelRunner from model in Blobstore "
+                        + "using blob key [%s] and config [%s]",
+                        blobKey,
+                        config),
+                        e);
             }
         }
     }

Reply via email to