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



##########
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:
       I agree. I am trying to reconcile this with the existing public toJson 
on SnapshotRefParser which serializes the ref (without the name as a field) 
object, the simplest way seemed to be add a new method which relies on the 
state of JsonGenerator.




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