@Override protected NearCacheDataRecord createRecord(V value) { Data dataValue = toData(value); long creationTime = currentTimeMillis(); if (timeToLiveMillis > 0) { return new NearCacheDataRecord(dataValue, creationTime, creationTime + timeToLiveMillis); } else { return new NearCacheDataRecord(dataValue, creationTime, TIME_NOT_SET); } }
@Override protected void updateRecordValue(NearCacheDataRecord record, V value) { record.setValue(toData(value)); } }
@Override protected void updateRecordValue(NearCacheDataRecord record, V value) { record.setValue(toData(value)); }
@Override protected long getRecordStorageMemoryCost(NearCacheDataRecord record) { if (record == null) { return 0L; } // TODO: we don't handle object header (mark, class definition) for heap memory cost Data value = record.getValue(); // reference to this record inside map ("store" field) return REFERENCE_SIZE // reference to "value" field + REFERENCE_SIZE // partition Id + (Integer.SIZE / Byte.SIZE) // "uuid" ref size + 2 long in uuid + REFERENCE_SIZE + (2 * (Long.SIZE / Byte.SIZE)) // heap cost of this value data + (value != null ? value.getHeapCost() : 0) + NUMBER_OF_LONG_FIELD_TYPES * (Long.SIZE / Byte.SIZE) + NUMBER_OF_INTEGER_FIELD_TYPES * (Integer.SIZE / Byte.SIZE); }
@Override protected NearCacheDataRecord valueToRecord(V value) { Data dataValue = toData(value); long creationTime = currentTimeMillis(); if (timeToLiveMillis > 0) { return new NearCacheDataRecord(dataValue, creationTime, creationTime + timeToLiveMillis); } else { return new NearCacheDataRecord(dataValue, creationTime, TIME_NOT_SET); } }
@Override protected long getRecordStorageMemoryCost(NearCacheDataRecord record) { if (record == null) { return 0L; } // TODO: we don't handle object header (mark, class definition) for heap memory cost Data value = record.getValue(); // reference to this record inside map ("store" field) return REFERENCE_SIZE // reference to "value" field + REFERENCE_SIZE // partition Id + (Integer.SIZE / Byte.SIZE) // "uuid" ref size + 2 long in uuid + REFERENCE_SIZE + (2 * (Long.SIZE / Byte.SIZE)) // heap cost of this value data + (value != null ? value.getHeapCost() : 0) + NUMBER_OF_LONG_FIELD_TYPES * (Long.SIZE / Byte.SIZE) + NUMBER_OF_INTEGER_FIELD_TYPES * (Integer.SIZE / Byte.SIZE); }