amogh-jahagirdar commented on a change in pull request #4294:
URL: https://github.com/apache/iceberg/pull/4294#discussion_r827118651



##########
File path: core/src/main/java/org/apache/iceberg/TableMetadataParser.java
##########
@@ -252,22 +248,7 @@ private static void toJson(TableMetadata metadata, 
JsonGenerator generator) thro
   private static void toJson(Map<String, SnapshotRef> refs, JsonGenerator 
generator) throws IOException {
     generator.writeObjectFieldStart(REFS);
     for (Map.Entry<String, SnapshotRef> refEntry : refs.entrySet()) {
-      generator.writeObjectFieldStart(refEntry.getKey());
-
-      SnapshotRef ref = refEntry.getValue();
-      generator.writeStringField(TYPE, 
ref.type().toString().toLowerCase(Locale.ROOT));
-      generator.writeNumberField(SNAPSHOT_ID, ref.snapshotId());
-      if (ref.maxRefAgeMs() != null) {
-        generator.writeNumberField(MAX_REF_AGE_MS, ref.maxRefAgeMs());
-      }
-      if (ref.maxSnapshotAgeMs() != null) {
-        generator.writeNumberField(MAX_SNAPSHOT_AGE_MS, 
ref.maxSnapshotAgeMs());
-      }
-      if (ref.minSnapshotsToKeep() != null) {
-        generator.writeNumberField(MIN_SNAPSHOTS_TO_KEEP, 
ref.minSnapshotsToKeep());
-      }
-
-      generator.writeEndObject();
+      SnapshotRefParser.toJson(refEntry.getKey(), refEntry.getValue(), 
generator);

Review comment:
       Updated. We can write the name field and leverage the existing toJson in 
SnapshotRefParser. I think this approach works because the ref can be 
serialized independently without any reliance on state. In TableMetadataParser 
we can serialize the name + ref entity together




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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to