walterddr commented on code in PR #9006:
URL: https://github.com/apache/pinot/pull/9006#discussion_r920336334


##########
pinot-common/src/main/java/org/apache/pinot/common/lineage/SegmentLineage.java:
##########
@@ -146,4 +150,19 @@ public ZNRecord toZNRecord() {
     }
     return znRecord;
   }
+
+  /**
+   * Returns a json representation of the segment lineage.
+   * Segment lineage entries are sorted in chronological order by default.
+   */
+  public ObjectNode toJsonObject() {
+    ObjectNode jsonObject = JsonUtils.newObjectNode();
+    jsonObject.put("tableNameWithType", _tableNameWithType);
+    LinkedHashMap<String, LineageEntry> sortedLineageEntries = new 
LinkedHashMap<>();
+    _lineageEntries.entrySet().stream()
+        
.sorted(Map.Entry.comparingByValue(Comparator.comparingLong(LineageEntry::getTimestamp)))
+        .forEachOrdered(x -> sortedLineageEntries.put(x.getKey(), 
x.getValue()));

Review Comment:
   IMO sorting is not necessary. at least we shouldn't do this in the 
toJsonObject path. what do you think we add the timestamp processing when we 
support filtering arguments, for example: 
`segments/{tableName}/lineage?timestamp>-10days` 



-- 
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: commits-unsubscr...@pinot.apache.org

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