Class IndexWriter.SizeIndexCollectorUncompressed

java.lang.Object
org.eclipse.mat.parser.index.IndexWriter.IntIndexCollectorUncompressed
org.eclipse.mat.parser.index.IndexWriter.SizeIndexCollectorUncompressed
Enclosing class:
IndexWriter

public static class IndexWriter.SizeIndexCollectorUncompressed extends IndexWriter.IntIndexCollectorUncompressed
Store sizes of objects by compressing the size to a 32-bit int.
Since:
1.0
  • Constructor Details

    • SizeIndexCollectorUncompressed

      public SizeIndexCollectorUncompressed(int size)
      Create a collector of the required size.
      Parameters:
      size - the number of entries
  • Method Details

    • compress

      public static int compress(long y)
      Cope with objects of size in bytes bigger than Integer.MAX_VALUE. E.g. double[Integer.MAX_VALUE] The original problem was that the array to size mapping had an integer as the size (IntIndexCollectorUncompressed). This array would be approximately 0x18 + 0x8 * 0x7fffffff = 0x400000010 bytes, too big for an int. Expanding the array size array to longs could be overkill. Instead we do some simple compression - values 0 - 0x7fffffff convert as now, int values 0x80000000 to 0xffffffff convert to (n & 0x7fffffffL)*8 + 0x80000000L.
      Parameters:
      y - the long value in the range -1 to 0x7fffffff, 0x80000000L to 0x400000000L
      Returns:
      the compressed value as an int
    • expand

      public static long expand(int x)
      Expand the result of the compression
      Parameters:
      x - the compressed value
      Returns:
      the expanded value as a long in the range -1 to 0x7fffffff, 0x80000000L to 0x400000000L
    • set

      public void set(int index, long value)
      Set the size for an object.
      Parameters:
      index - the object ID
      value - the size
    • getSize

      public long getSize(int index)
      Get the expanded size.
      Parameters:
      index - the object ID
      Returns:
      the size
    • writeTo

      public IIndexReader.IOne2SizeIndex writeTo(File indexFile) throws IOException
      Description copied from class: IndexWriter.IntIndexCollectorUncompressed
      Store the collector to a file.
      Overrides:
      writeTo in class IndexWriter.IntIndexCollectorUncompressed
      Parameters:
      indexFile - the file
      Returns:
      an index which holds the same values as the collector
      Throws:
      IOException - if a problem occurred with the write