@Override final protected T getValueFromIdImpl(int id) { if (enableCache) { Object[] cache = idToValueCache.get(); // SoftReference to skip // cache gracefully when // short of memory if (cache != null) { int seq = calcSeqNoFromId(id); if (seq < 0 || seq >= nValues) throw new IllegalArgumentException("Not a valid ID: " + id); if (cache[seq] != null) return (T) cache[seq]; byte[] value = new byte[getSizeOfValue()]; int length = getValueBytesFromId(id, value, 0); T result = bytesConvert.convertFromBytes(value, 0, length); cache[seq] = result; return result; } } byte[] value = new byte[getSizeOfValue()]; int length = getValueBytesFromId(id, value, 0); return bytesConvert.convertFromBytes(value, 0, length); }
for (int i = 0; i < times; i++) { for (int j = 0; j < n; j++) { keep |= dict.getValueBytesFromId(j, valueBytes, 0);
assertNull(dict.getValueFromId(nullId)); int nullId2 = dict.getIdFromValueBytes(null, 0, 0); assertEquals(dict.getValueBytesFromId(nullId2, null, 0), -1); assertEquals(nullId, nullId2);
@Override final protected T getValueFromIdImpl(int id) { if (enableCache) { Object[] cache = idToValueCache.get(); // SoftReference to skip cache gracefully when short of memory if (cache != null) { int seq = calcSeqNoFromId(id); if (seq < 0 || seq >= nValues) throw new IllegalArgumentException("Not a valid ID: " + id); if (cache[seq] != null) return (T) cache[seq]; byte[] value = new byte[getSizeOfValue()]; int length = getValueBytesFromId(id, value, 0); T result = bytesConvert.convertFromBytes(value, 0, length); cache[seq] = result; return result; } } byte[] value = new byte[getSizeOfValue()]; int length = getValueBytesFromId(id, value, 0); return bytesConvert.convertFromBytes(value, 0, length); }