yupeng9 commented on a change in pull request #6845:
URL: https://github.com/apache/incubator-pinot/pull/6845#discussion_r631361540



##########
File path: 
pinot-spi/src/main/java/org/apache/pinot/spi/data/readers/GenericRow.java
##########
@@ -120,6 +126,49 @@ public boolean hasNullValues() {
     return !_nullValueFields.isEmpty();
   }
 
+  /**
+   * @return a deep copy of the generic row
+   */
+  public GenericRow copy() {
+    GenericRow copy = new GenericRow();
+    copy.init(this);
+    for (Map.Entry<String, Object> entry : new 
HashSet<>(copy._fieldToValueMap.entrySet())) {
+      copy.putValue(entry.getKey(), copy(entry.getValue()));
+    }
+    return copy;
+  }
+
+  /**
+   * @return a deep copy of the object.
+   */
+  private Object copy(Object value) {
+    if (value == null) {
+      return null;
+    } else if (value instanceof Map) {
+      Map<String, Object> map = new HashMap<>();
+      for (String key : ((Map<String, Object>) value).keySet()) {
+        map.put(key, copy(((Map<String, Object>) value).get(key)));
+      }

Review comment:
       this is less efficient?




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



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to