/** * {@inheritDoc} */ @Override public long getSizeOf(String str) { if (null == str) { return 0; } long size = this.getSizeOfObjectHeader(); size += this.getPrimitiveTypesSize(1, 0, 2, 0, 0, 0); size += this.getSizeOfPrimitiveArray(str.length(), CHAR_SIZE); return alignTo8Bytes(size); }
/** * Returns size of the CAT object used in the high scale lib Counter. * * @return Size in bytes. */ private long getSizeOfHighScaleLibCAT() { long size = this.getSizeOfObjectHeader(); size += this.getPrimitiveTypesSize(2, 0, 0, 0, 4, 0); size = alignTo8Bytes(size); // always has an array of 4 longs attached size += this.getSizeOfPrimitiveArray(4, LONG_SIZE); return size; }
/** * Returns size of the CHM object used in the high scale lib NonBlockingHashMapLong. * * @param mapSize * Size of map. * @return Size in bytes. */ private long getSizeOfHighScaleLibCHM(int mapSize) { long size = this.getSizeOfObjectHeader(); size += this.getPrimitiveTypesSize(6, 0, 0, 0, 3, 0); size = alignTo8Bytes(size); // two counters in addition size += getSizeOfHighScaleLibCounter() << 1; // min 16, or next power of two int tablesSize = (mapSize <= MAP_INITIAL_CAPACITY) ? MAP_INITIAL_CAPACITY : 1 << (32 - Integer.numberOfLeadingZeros(mapSize - 1)); // long table[] size += this.getSizeOfPrimitiveArray(tablesSize, LONG_SIZE); // object table[] size += this.getSizeOfPrimitiveArray(tablesSize, getReferenceSize()); return size; }