Class Statistics


  • @PublicApi
    public class Statistics
    extends java.lang.Object
    This holds statistics on how a DataLoader has performed
    • Constructor Detail

      • Statistics

        public Statistics()
        Zero statistics
      • Statistics

        public Statistics​(long loadCount,
                          long loadErrorCount,
                          long batchInvokeCount,
                          long batchLoadCount,
                          long batchLoadExceptionCount,
                          long cacheHitCount)
    • Method Detail

      • ratio

        public double ratio​(long numerator,
                            long denominator)
        A helper to divide two numbers and handle zero
        Parameters:
        numerator - the top bit
        denominator - the bottom bit
        Returns:
        numerator / denominator returning zero when denominator is zero
      • getLoadCount

        public long getLoadCount()
        Returns:
        the number of objects DataLoader.load(Object) has been asked to load
      • getLoadErrorCount

        public long getLoadErrorCount()
        Returns:
        the number of times the DataLoader batch loader function return a specific object that was in error
      • getLoadErrorRatio

        public double getLoadErrorRatio()
        Returns:
        loadErrorCount / loadCount
      • getBatchInvokeCount

        public long getBatchInvokeCount()
        Returns:
        the number of times the DataLoader batch loader function has been called
      • getBatchLoadCount

        public long getBatchLoadCount()
        Returns:
        the number of objects that the DataLoader batch loader function has been asked to load
      • getBatchLoadRatio

        public double getBatchLoadRatio()
        Returns:
        batchLoadCount / loadCount
      • getBatchLoadExceptionCount

        public long getBatchLoadExceptionCount()
        Returns:
        the number of times the DataLoader batch loader function throw an exception when trying to get any values
      • getBatchLoadExceptionRatio

        public double getBatchLoadExceptionRatio()
        Returns:
        batchLoadExceptionCount / loadCount
      • getCacheHitCount

        public long getCacheHitCount()
        Returns:
        the number of times DataLoader.load(Object) resulted in a cache hit
      • getCacheMissCount

        public long getCacheMissCount()
        Returns:
        then number of times we missed the cache during DataLoader.load(Object)
      • getCacheHitRatio

        public double getCacheHitRatio()
        Returns:
        cacheHits / loadCount
      • combine

        public Statistics combine​(Statistics other)
        This will combine this set of statistics with another set of statistics so that they become the combined count of each
        Parameters:
        other - the other statistics to combine
        Returns:
        a new statistics object of the combined counts
      • toMap

        public java.util.Map<java.lang.String,​java.lang.Number> toMap()
        Returns:
        a map representation of the statistics, perhaps to send over JSON or some such
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object