ahmedabu98 commented on code in PR #39750:
URL: https://github.com/apache/beam/pull/39750#discussion_r4286387335


##########
sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/SchemaUtils.java:
##########
@@ -284,24 +282,26 @@ static String toPrettyFieldValueString(Schema.FieldType 
fieldType, Object value,
           FieldType elementType = 
Objects.requireNonNull(fieldType.getCollectionElementType());
 
           @SuppressWarnings("unchecked")
-          List<Object> list = Lists.newArrayList((Iterable<Object>) value);
-          if (list.isEmpty()) {
-            return "[]";
-          }
+          Iterable<Object> elements = (Iterable<Object>) value;
+
+          // Rendered in a single pass. The previous shape asked the 
collection for isEmpty(),
+          // then size(), then iterated it -- three traversals, which a List 
absorbs for free but
+          // which an Iterable that can only be read once would not survive.

Review Comment:
   Please remove or trim this comment



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

Reply via email to