diff --git a/sdks/python/apache_beam/coders/coder_impl.py b/sdks/python/apache_beam/coders/coder_impl.py index 3e0b5218b166..2a3ce2cc8828 100644 --- a/sdks/python/apache_beam/coders/coder_impl.py +++ b/sdks/python/apache_beam/coders/coder_impl.py @@ -316,6 +316,9 @@ def decode(self, encoded): proto_message.ParseFromString(encoded) # This is in effect "ParsePartial". return proto_message + def estimate_size(self, value, nested=False): + return self._get_nested_size(value.ByteSize(), nested) + class DeterministicProtoCoderImpl(ProtoCoderImpl): """For internal use only; no backwards-compatibility guarantees.""" @@ -335,6 +338,9 @@ def encode(self, value): def decode(self, value): return self.proto_plus_type.deserialize(value) + def estimate_size(self, value, nested=False): + return self._get_nested_size(type(value).pb(value).ByteSize(), nested) + UNKNOWN_TYPE = 0xFF NONE_TYPE = 0