xuyang1706 commented on a change in pull request #8776: [FLINK-12881][ml] Add
more functionalities for ML Params and ParamInfo class
URL: https://github.com/apache/flink/pull/8776#discussion_r296647178
##########
File path:
flink-ml-parent/flink-ml-api/src/main/java/org/apache/flink/ml/api/misc/param/Params.java
##########
@@ -25,16 +25,58 @@
import java.io.IOException;
import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
/**
* The map-like container class for parameter. This class is provided to unify
the interaction with
* parameters.
*/
@PublicEvolving
-public class Params implements Serializable {
- private final Map<String, Object> paramMap = new HashMap<>();
+public class Params implements Serializable, Cloneable {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * A mapping from param name to its value.
+ *
+ * <p>The value is stored in map using json format.
+ */
+ private final Map<String, String> params;
+
+ private transient ObjectMapper mapper;
+
+ public Params() {
+ this.params = new HashMap<>();
+ }
+
+ /**
+ * Return the number of params.
+ *
+ * @return Return the number of params.
+ */
+ public int size() {
+ return params.size();
+ }
+
+ /**
+ * Removes all of the params.
+ * The params will be empty after this call returns.
+ */
+ public void clear() {
+ params.clear();
+ }
+
+ /**
+ * Returns <tt>true</tt> if this params contains no mappings.
+ *
+ * @return <tt>true</tt> if this map contains no mappings
+ */
+ public boolean isEmpty() {
+ return params.isEmpty();
+ }
/**
* Returns the value of the specific parameter, or default value
defined in the {@code info} if
Review comment:
Changed.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services