1

I am working with very large collections of small objects. I am using using ChronicleMap which is performing very well.

Is the maximum number of map entries limited to Integer.MAX_VALUE?

If not, how do I get the real size of a map as the map.size() returns Integer.MAX_VALUE if the number of entries is higher than Integer.MAX_VALUE?

Thanks in advance.

rghome
  • 8,529
  • 8
  • 43
  • 62
kem
  • 407
  • 1
  • 6
  • 20

2 Answers2

5

You can use ChronicleMap.longSize instead to get the size as a long. ChronicleMap.size will return Integer.MAX_VALUE when the size is greater then Integer.MAX_VALUE per the source: https://github.com/OpenHFT/Chronicle-Map/blob/master/src/main/java/net/openhft/chronicle/hash/impl/VanillaChronicleHash.java#L707

This is in accordance with the Collection.size interface:

Returns the number of elements in this collection. If this collection contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

jspcal
  • 50,847
  • 7
  • 72
  • 76
2

ChronicleMap size isn't limited to integer.MAX_VALUE as traditional map. To get the size, you can use longSize() which return a long value

ishimwe
  • 1,216
  • 12
  • 13