lindong28 commented on a change in pull request #54:
URL: https://github.com/apache/flink-ml/pull/54#discussion_r831080421



##########
File path: 
flink-ml-lib/src/main/java/org/apache/flink/ml/feature/minmaxscaler/MinMaxScalerModelData.java
##########
@@ -0,0 +1,119 @@
+/*
+ * 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.feature.minmaxscaler;
+
+import org.apache.flink.api.common.serialization.Encoder;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.connector.file.src.reader.SimpleStreamFormat;
+import org.apache.flink.core.fs.FSDataInputStream;
+import org.apache.flink.core.memory.DataInputView;
+import org.apache.flink.core.memory.DataInputViewStreamWrapper;
+import org.apache.flink.core.memory.DataOutputView;
+import org.apache.flink.core.memory.DataOutputViewStreamWrapper;
+import org.apache.flink.ml.linalg.DenseVector;
+import org.apache.flink.ml.linalg.typeinfo.DenseVectorSerializer;
+import org.apache.flink.streaming.api.datastream.DataStream;
+import org.apache.flink.table.api.Table;
+import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;
+import org.apache.flink.table.api.internal.TableImpl;
+
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * Model data of {@link MinMaxScalerModel}.
+ *
+ * <p>This class also provides methods to convert model data from Table to a 
data stream, and
+ * classes to save/load model data.
+ */
+public class MinMaxScalerModelData {
+    public DenseVector minVector;
+
+    public DenseVector maxVector;
+
+    public MinMaxScalerModelData() {}
+
+    public MinMaxScalerModelData(DenseVector minVector, DenseVector maxVector) 
{
+        this.minVector = minVector;
+        this.maxVector = maxVector;
+    }
+
+    /**
+     * Converts the table model to a data stream.
+     *
+     * @param modelDataTable The table model data.
+     * @return The data stream model data.
+     */
+    public static DataStream<MinMaxScalerModelData> getModelDataStream(Table 
modelDataTable) {
+        StreamTableEnvironment tEnv =
+                (StreamTableEnvironment) ((TableImpl) 
modelDataTable).getTableEnvironment();
+        return tEnv.toDataStream(modelDataTable)
+                .map(
+                        x ->
+                                new MinMaxScalerModelData(
+                                        (DenseVector) x.getField(0), 
(DenseVector) x.getField(1)));
+    }
+
+    /** Encoder for {@link MinMaxScalerModelData}. */
+    public static class ModelDataEncoder implements 
Encoder<MinMaxScalerModelData> {
+        @Override
+        public void encode(MinMaxScalerModelData minMaxScalerModelData, 
OutputStream outputStream)

Review comment:
       Super nits: all other classes (except `KnnModelData`) uses `modelData` 
as the input parameter name of this method. Any chance we can do the same here 
for consistency and shorten the code a little bit?
   
   And maybe update KnnModelData as well?

##########
File path: 
flink-ml-lib/src/main/java/org/apache/flink/ml/feature/minmaxscaler/MinMaxScalerModelData.java
##########
@@ -0,0 +1,119 @@
+/*
+ * 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.feature.minmaxscaler;
+
+import org.apache.flink.api.common.serialization.Encoder;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.connector.file.src.reader.SimpleStreamFormat;
+import org.apache.flink.core.fs.FSDataInputStream;
+import org.apache.flink.core.memory.DataInputView;
+import org.apache.flink.core.memory.DataInputViewStreamWrapper;
+import org.apache.flink.core.memory.DataOutputView;
+import org.apache.flink.core.memory.DataOutputViewStreamWrapper;
+import org.apache.flink.ml.linalg.DenseVector;
+import org.apache.flink.ml.linalg.typeinfo.DenseVectorSerializer;
+import org.apache.flink.streaming.api.datastream.DataStream;
+import org.apache.flink.table.api.Table;
+import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;
+import org.apache.flink.table.api.internal.TableImpl;
+
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * Model data of {@link MinMaxScalerModel}.
+ *
+ * <p>This class also provides methods to convert model data from Table to a 
data stream, and
+ * classes to save/load model data.
+ */
+public class MinMaxScalerModelData {
+    public DenseVector minVector;
+
+    public DenseVector maxVector;
+
+    public MinMaxScalerModelData() {}
+
+    public MinMaxScalerModelData(DenseVector minVector, DenseVector maxVector) 
{
+        this.minVector = minVector;
+        this.maxVector = maxVector;
+    }
+
+    /**
+     * Converts the table model to a data stream.
+     *
+     * @param modelDataTable The table model data.
+     * @return The data stream model data.
+     */
+    public static DataStream<MinMaxScalerModelData> getModelDataStream(Table 
modelDataTable) {
+        StreamTableEnvironment tEnv =
+                (StreamTableEnvironment) ((TableImpl) 
modelDataTable).getTableEnvironment();
+        return tEnv.toDataStream(modelDataTable)
+                .map(
+                        x ->
+                                new MinMaxScalerModelData(
+                                        (DenseVector) x.getField(0), 
(DenseVector) x.getField(1)));
+    }
+
+    /** Encoder for {@link MinMaxScalerModelData}. */
+    public static class ModelDataEncoder implements 
Encoder<MinMaxScalerModelData> {
+        @Override
+        public void encode(MinMaxScalerModelData minMaxScalerModelData, 
OutputStream outputStream)

Review comment:
       Super nits: all other classes (except `KnnModelData`) uses `modelData` 
as the input parameter name of this method. Any chance we can do the same here 
for consistency and shorten the code a little bit?
   
   And maybe update KnnModelData as well for consistency?




-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to