예제 #1
0
  def get_estimated_size_and_observables(self, value, nested=False):
    if isinstance(value, observable.ObservableMixin):
      # FastPrimitivesCoderImpl can presumably encode the elements too.
      return 1, [(value, self)]

    out = ByteCountingOutputStream()
    self.encode_to_stream(value, out, nested)
    return out.get_count(), []
예제 #2
0
 def get_estimated_size_and_observables(self, value, nested=False):
     if isinstance(value, observable.ObservableMixin):
         # FastPrimitivesCoderImpl can presumably encode the elements too.
         return 1, [(value, self)]
     else:
         out = ByteCountingOutputStream()
         self.encode_to_stream(value, out, nested)
         return out.get_count(), []
예제 #3
0
 def estimate_size(self, value, nested=False):
   """Estimates the encoded size of the given value, in bytes."""
   out = ByteCountingOutputStream()
   self.encode_to_stream(value, out, nested)
   return out.get_count()
예제 #4
0
 def estimate_size(self, value, nested=False):
     """Estimates the encoded size of the given value, in bytes."""
     out = ByteCountingOutputStream()
     self.encode_to_stream(value, out, nested)
     return out.get_count()