From c9c1bf21ae55214653a01d391d16643ad3061e5a Mon Sep 17 00:00:00 2001 From: Hadon Nash Date: Fri, 3 Mar 2023 09:57:34 -0800 Subject: [PATCH] Internal change PiperOrigin-RevId: 513854481 --- mediapipe/framework/tool/template_parser.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/mediapipe/framework/tool/template_parser.cc b/mediapipe/framework/tool/template_parser.cc index 6c7237f8e..e26275387 100644 --- a/mediapipe/framework/tool/template_parser.cc +++ b/mediapipe/framework/tool/template_parser.cc @@ -1676,15 +1676,18 @@ class TemplateParser::Parser::MediaPipeParserImpl } } - // Inserts one value into the specified field. - static void InsertFieldValue( + // Appends one value to the specified field. + static void AppendFieldValue( Message* message, const FieldDescriptor* field, const std::vector& args) { auto field_type = static_cast(field->type()); ProtoUtilLite::FieldValue message_bytes; CHECK(message->SerializePartialToString(&message_bytes)); + int count; + MEDIAPIPE_CHECK_OK(ProtoUtilLite::GetFieldCount( + message_bytes, {{field->number(), 0}}, field_type, &count)); MEDIAPIPE_CHECK_OK(ProtoUtilLite::ReplaceFieldRange( - &message_bytes, {{field->number(), 0}}, 0, field_type, args)); + &message_bytes, {{field->number(), count}}, 0, field_type, args)); CHECK(message->ParsePartialFromString(message_bytes)); } @@ -1701,7 +1704,7 @@ class TemplateParser::Parser::MediaPipeParserImpl // Leave a dummy value in place of the consumed field. std::vector args; GetEmptyFieldValue(field, &args); - InsertFieldValue(message, field, args); + AppendFieldValue(message, field, args); return true; } @@ -1718,7 +1721,7 @@ class TemplateParser::Parser::MediaPipeParserImpl // Leave a dummy value in place of the consumed field. std::vector args; GetEmptyFieldValue(field, &args); - InsertFieldValue(message, field, args); + AppendFieldValue(message, field, args); return true; }