walterddr commented on a change in pull request #9355: [FLINK-13577][ml] Add an 
util class to build result row and generate …
URL: https://github.com/apache/flink/pull/9355#discussion_r332207840
 
 

 ##########
 File path: 
flink-ml-parent/flink-ml-lib/src/main/java/org/apache/flink/ml/common/utils/OutputColsHelper.java
 ##########
 @@ -0,0 +1,190 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.flink.ml.common.utils;
+
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.table.api.TableSchema;
+import org.apache.flink.types.Row;
+
+import org.apache.commons.lang3.ArrayUtils;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+
+/**
+ * Util for generating output schema.
+ *
+ * <p>Need following information:
+ * 1) data schema
+ * 2) output column names
+ * 3) output column types
+ * 4) keep column names
+ *
+ * <p>The following roles are followed:
+ * 1)If reserved columns is null, then reserve all columns from the origin 
dataSet.
+ * 2)If some of the reserved column names are the same as output column names, 
then they are
 
 Review comment:
   hmm in this case the javadoc is confusing to me still (especially with the 
3rd line). Let's use an example:
   assume the output row is `["a":1, "b":2, "c":true, "d":3.4]`, is my 
assumptions below correct?
    
   there's only one option of the `dataSchema`:
   ```
   dataSchema: ["a":INT, "b":INT, "c":BOOL, "d":FLOAT]
   ```
   2. `outputColumnName` should be a subset of `{"a", "b", "c", "d"}`, but 
preserves the ordering defined.
   3. `outputColumnType` should match exactly the size of `outputColumnName` 
and should match the exact type at the corresponding index of `dataSchema` - 
(if point3 is true, why do we need outputColumnType?)
   4. `reserveColumnName` should be a subset of `{"a", "b", "c", "d"}`, but 
ordering follows how `dataSchema` defines.
   5. I am assuming you will output the result by first putting 
`reservedColumn`s then `outputColumn`s. (if point 2,4,5 are true, won't you 
have duplicate naming in your final output?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to