Class FieldDescriptorCache

java.lang.Object
com.google.ads.googleads.lib.logging.scrub.FieldDescriptorCache

public class FieldDescriptorCache extends Object
Caches the results of looking up fields in a protobuf message's Descriptor.

Empirical testing suggests that the first request for a message's descriptor is quite slow, for instance GoogleAdsRow takes about 0.5 seconds. Future requests to the protobuf descriptor API take around 3 usec. This cache reduces the ongoing lookup time to around 1 usec, but still suffers from the slow initial request performance.

  • Method Details

    • getDefault

      public static FieldDescriptorCache getDefault()
      Obtains a global instance of the cache.
    • lookupField

      public Optional<com.google.protobuf.Descriptors.FieldDescriptor> lookupField(String fieldName, com.google.protobuf.MessageOrBuilder containingMessage)
      Retrieves a named field from a MessageOrBuilder. If the field is not in the cache then it is first populated and then returned.