Class HistogramRecord

java.lang.Object
org.eclipse.mat.snapshot.HistogramRecord
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
ClassHistogramRecord, ClassHistogramRecordBuilder, ClassLoaderHistogramRecord, ClassLoaderHistogramRecordBuilder, Histogram, HistogramBuilder

public class HistogramRecord extends Object implements Serializable
This class holds all basic data for a histogram record. Other classes inherit from it. It offers comparators to sort histogram records by their basic data. This pattern should be implemented by the classes inheriting from it as well.
See Also:
  • Field Details

  • Constructor Details

    • HistogramRecord

      public HistogramRecord(String label)
      Create histogram record just with a label identifying it.
      Parameters:
      label - label identifying the histogram record
    • HistogramRecord

      public HistogramRecord(String label, long numberOfObjects, long usedHeapSize, long retainedHeapSize)
      Create histogram record with a label identifying it and its basic data.
      Parameters:
      label - label identifying the histogram record
      numberOfObjects - number of objects this histogram record stands for
      usedHeapSize - number of bytes in heap area this histogram record stands for
  • Method Details

    • getLabel

      public String getLabel()
      Get label identifying the histogram record.
      Returns:
      label identifying the histogram record
    • setLabel

      public void setLabel(String label)
      Set label identifying the histogram record.
      Parameters:
      label - label identifying the histogram record
    • getNumberOfObjects

      public long getNumberOfObjects()
      Get number of objects this histogram record stands for.
      Returns:
      number of objects this histogram record stands for
    • setNumberOfObjects

      public void setNumberOfObjects(long numberOfObjects)
      Set number of objects this histogram record stands for.
      Parameters:
      numberOfObjects - number of objects this histogram record stands for
    • incNumberOfObjects

      public void incNumberOfObjects()
      Increment number of objects this histogram record stands for by 1.
    • incNumberOfObjects

      public void incNumberOfObjects(long inc)
      Increment number of objects this histogram record stands for.
      Parameters:
      inc - number of objects by which the number of objects should be incremented
    • getUsedHeapSize

      public long getUsedHeapSize()
      Get number of bytes in heap area this histogram record stands for.
      Returns:
      number of bytes in heap area this histogram record stands for
    • setUsedHeapSize

      public void setUsedHeapSize(long usedHeapSize)
      Set number of bytes in heap area this histogram record stands for.
      Parameters:
      usedHeapSize - number of bytes in heap area this histogram record stands for
    • incUsedHeapSize

      public void incUsedHeapSize(long inc)
      Increment number of bytes in heap area this histogram record stands for.
      Parameters:
      inc - number of bytes by which the number of bytes in heap area should be incremented
    • getRetainedHeapSize

      public long getRetainedHeapSize()
      Get number of retained bytes in heap area this histogram record stands for.

      Retained bytes means how much memory would be garbage collected if the references to the objects this histogram record stands for would be lost and the objects garbage collected.

      Returns:
      number of retained bytes in heap area this histogram record stands for
    • setRetainedHeapSize

      public void setRetainedHeapSize(long retainedHeapSize)
      Set number of retained bytes in heap area this histogram record stands for.

      Retained bytes means how much memory would be garbage collected if the references to the objects this histogram record stands for would be lost and the objects garbage collected.

      Parameters:
      retainedHeapSize - number of retained bytes in heap area this histogram record stands for
    • incRetainedHeapSize

      public void incRetainedHeapSize(long inc)
    • reverseComparator

      public static Comparator<HistogramRecord> reverseComparator(Comparator<HistogramRecord> comparator)
      Convenience method reversing the order of the given comparator. Be aware that each time you call this method a new comparator is returned and that this comparator delegates the call to the given comparator, but just switches the parameters. You can get the same result with the given comparator, by iterating from the last to the first element instead. From performance perspective using e.g. List.get(int) is anyhow faster compared to an Iterator.
      Parameters:
      comparator - comparator for which a reversed comparator should be returned
      Returns:
      comparator comparing in reverse order than the given comparator