Class IndexWriter.SizeIndexCollectorUncompressed

    • Constructor Detail

      • SizeIndexCollectorUncompressed

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

      • 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