Github user myui commented on a diff in the pull request:

    https://github.com/apache/incubator-hivemall/pull/145#discussion_r182357781
  
    --- Diff: 
core/src/main/java/hivemall/ftvec/trans/QuantifiedFeaturesUDTF.java ---
    @@ -87,30 +80,27 @@ public StructObjectInspector 
initialize(ObjectInspector[] argOIs) throws UDFArgu
     
         @Override
         public void process(Object[] args) throws HiveException {
    -        if (forwardObjs == null) {
    -            this.forwardObjs = new Object[] {Arrays.asList(columnValues)};
    -        }
    -
             boolean outputRow = boolOI.get(args[0]);
             if (outputRow) {
    -            final DoubleWritable[] values = this.columnValues;
    -            for (int i = 0, outputSize = args.length - 1; i < outputSize; 
i++) {
    +            int outputSize = args.length - 1;
    +            double[] values = new double[outputSize];
    +            for (int i = 0; i < outputSize; i++) {
                     Object arg = args[i + 1];
                     Identifier<String> identifier = identifiers[i];
                     if (identifier == null) {
                         double v = 
PrimitiveObjectInspectorUtils.getDouble(arg, doubleOIs[i]);
    -                    values[i].set(v);
    +                    values[i] = v;
                     } else {
                         if (arg == null) {
                             throw new HiveException("Found Null in the input: 
" + Arrays.toString(args));
                         } else {
                             String k = arg.toString();
                             int id = identifier.valueOf(k);
    -                        values[i].set(id);
    +                        values[i] = id;
                         }
                     }
                 }
    -            forward(forwardObjs);
    +            forward(new Object[] {WritableUtils.toWritableList(values)});
    --- End diff --
    
    Why you made this change? Creating object (calling 
`WritableUtils.toWritableList`) for each `forward` is costful.



---

Reply via email to