hivemall-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From myui <...@git.apache.org>
Subject [GitHub] incubator-hivemall pull request #92: [HIVEMALL-5] Java code formatter
Date Sat, 01 Jul 2017 23:56:51 GMT
Github user myui commented on a diff in the pull request:

    https://github.com/apache/incubator-hivemall/pull/92#discussion_r125170781
  
    --- Diff: core/src/main/java/hivemall/classifier/KPAPredictUDAF.java ---
    @@ -40,189 +40,187 @@
     import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
     import org.apache.hadoop.hive.serde2.typeinfo.TypeInfo;
     
    -@Description(
    -        name = "kpa_predict",
    -        value = "_FUNC_(@Nonnull double xh, @Nonnull double xk, @Nullable float w0, @Nonnull
float w1, @Nonnull float w2, @Nullable float w3)"
    -                + " - Returns a prediction value in Double")
    +@Description(name = "kpa_predict", value = "_FUNC_(@Nonnull double xh, @Nonnull double
xk, @Nullable float w0, @Nonnull float w1, @Nonnull float w2, @Nullable float w3)"
    +    + " - Returns a prediction value in Double")
     public final class KPAPredictUDAF extends AbstractGenericUDAFResolver {
     
    -    @Override
    -    public GenericUDAFEvaluator getEvaluator(TypeInfo[] parameters) throws SemanticException
{
    -        if (parameters.length != 6) {
    -            throw new UDFArgumentException(
    -                "_FUNC_(double xh, double xk, float w0, float w1, float w2, float w3)
takes exactly 6 arguments but got: "
    -                        + parameters.length);
    -        }
    -        if (!HiveUtils.isNumberTypeInfo(parameters[0])) {
    -            throw new UDFArgumentTypeException(0, "Number type is expected for xh (1st
argument): "
    -                    + parameters[0].getTypeName());
    -        }
    -        if (!HiveUtils.isNumberTypeInfo(parameters[1])) {
    -            throw new UDFArgumentTypeException(1, "Number type is expected for xk (2nd
argument): "
    -                    + parameters[1].getTypeName());
    -        }
    -        if (!HiveUtils.isNumberTypeInfo(parameters[2])) {
    -            throw new UDFArgumentTypeException(2, "Number type is expected for w0 (3rd
argument): "
    -                    + parameters[2].getTypeName());
    -        }
    -        if (!HiveUtils.isNumberTypeInfo(parameters[3])) {
    -            throw new UDFArgumentTypeException(3, "Number type is expected for w1 (4th
argument): "
    -                    + parameters[3].getTypeName());
    -        }
    -        if (!HiveUtils.isNumberTypeInfo(parameters[4])) {
    -            throw new UDFArgumentTypeException(4, "Number type is expected for w2 (5th
argument): "
    -                    + parameters[4].getTypeName());
    -        }
    -        if (!HiveUtils.isNumberTypeInfo(parameters[5])) {
    -            throw new UDFArgumentTypeException(5, "Number type is expected for w3 (6th
argument): "
    -                    + parameters[5].getTypeName());
    -        }
    -
    -        return new Evaluator();
    +  @Override
    +  public GenericUDAFEvaluator getEvaluator(TypeInfo[] parameters) throws SemanticException
{
    +    if (parameters.length != 6) {
    +      throw new UDFArgumentException(
    +          "_FUNC_(double xh, double xk, float w0, float w1, float w2, float w3) takes
exactly 6 arguments but got: "
    +              + parameters.length);
    +    }
    +    if (!HiveUtils.isNumberTypeInfo(parameters[0])) {
    +      throw new UDFArgumentTypeException(0, "Number type is expected for xh (1st argument):
"
    +          + parameters[0].getTypeName());
    +    }
    +    if (!HiveUtils.isNumberTypeInfo(parameters[1])) {
    +      throw new UDFArgumentTypeException(1, "Number type is expected for xk (2nd argument):
"
    +          + parameters[1].getTypeName());
    +    }
    +    if (!HiveUtils.isNumberTypeInfo(parameters[2])) {
    +      throw new UDFArgumentTypeException(2, "Number type is expected for w0 (3rd argument):
"
    +          + parameters[2].getTypeName());
    +    }
    +    if (!HiveUtils.isNumberTypeInfo(parameters[3])) {
    +      throw new UDFArgumentTypeException(3, "Number type is expected for w1 (4th argument):
"
    +          + parameters[3].getTypeName());
    +    }
    +    if (!HiveUtils.isNumberTypeInfo(parameters[4])) {
    +      throw new UDFArgumentTypeException(4, "Number type is expected for w2 (5th argument):
"
    +          + parameters[4].getTypeName());
    +    }
    +    if (!HiveUtils.isNumberTypeInfo(parameters[5])) {
    +      throw new UDFArgumentTypeException(5, "Number type is expected for w3 (6th argument):
"
    +          + parameters[5].getTypeName());
         }
     
    -    public static class Evaluator extends GenericUDAFEvaluator {
    -
    -        @Nullable
    -        private transient PrimitiveObjectInspector xhOI, xkOI;
    -        @Nullable
    -        private transient PrimitiveObjectInspector w0OI, w1OI, w2OI, w3OI;
    -
    -        public Evaluator() {}
    +    return new Evaluator();
    +  }
     
    -        @Override
    -        public ObjectInspector init(Mode m, ObjectInspector[] parameters) throws HiveException
{
    -            super.init(m, parameters);
    +  public static class Evaluator extends GenericUDAFEvaluator {
     
    -            // initialize input
    -            if (m == Mode.PARTIAL1 || m == Mode.COMPLETE) {// from original data
    -                this.xhOI = HiveUtils.asNumberOI(parameters[0]);
    -                this.xkOI = HiveUtils.asNumberOI(parameters[1]);
    -                this.w0OI = HiveUtils.asNumberOI(parameters[2]);
    -                this.w1OI = HiveUtils.asNumberOI(parameters[3]);
    -                this.w2OI = HiveUtils.asNumberOI(parameters[4]);
    -                this.w3OI = HiveUtils.asNumberOI(parameters[5]);
    -            }
    +    @Nullable
    +    private transient PrimitiveObjectInspector xhOI, xkOI;
    +    @Nullable
    +    private transient PrimitiveObjectInspector w0OI, w1OI, w2OI, w3OI;
     
    -            return PrimitiveObjectInspectorFactory.writableDoubleObjectInspector;
    -        }
    +    public Evaluator() {
    --- End diff --
    
    `public Evaluator() {}` is preferred as seen in Google coding style.
    https://google.github.io/styleguide/javaguide.html#s4.1.3-braces-empty-blocks


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message