org.eclipse.mat.parser.index
Class IndexWriter.SizeIndexCollectorUncompressed

java.lang.Object
  extended by org.eclipse.mat.parser.index.IndexWriter.IntIndexCollectorUncompressed
      extended by 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 Summary
IndexWriter.SizeIndexCollectorUncompressed(int size)
           
 
Method Summary
static int compress(long y)
          Cope with objects bigger than Integer.MAX_VALUE.
static long expand(int x)
          Expand the result of the compression
 long getSize(int index)
           
 void set(int index, long value)
           
 IIndexReader.IOne2SizeIndex writeTo(java.io.File indexFile)
           
 
Methods inherited from class org.eclipse.mat.parser.index.IndexWriter.IntIndexCollectorUncompressed
get, set
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IndexWriter.SizeIndexCollectorUncompressed

public IndexWriter.SizeIndexCollectorUncompressed(int size)
Method Detail

compress

public static int compress(long y)
Cope with objects 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)

getSize

public long getSize(int index)

writeTo

public IIndexReader.IOne2SizeIndex writeTo(java.io.File indexFile)
                                    throws java.io.IOException
Overrides:
writeTo in class IndexWriter.IntIndexCollectorUncompressed
Throws:
java.io.IOException