public long incRefToStreamAndSession(final int streamId, final int sessionId) { return refCountByStreamIdAndSessionIdMap.incrementAndGet(Hashing.compoundKey(streamId, sessionId)); }
public long decRefToStreamAndSession(final int streamId, final int sessionId) { final long key = Hashing.compoundKey(streamId, sessionId); final long count = refCountByStreamIdAndSessionIdMap.decrementAndGet(key); if (-1 == count) { refCountByStreamIdAndSessionIdMap.remove(key); throw new IllegalStateException( "could not find stream Id + session Id to decrement: " + streamId + " " + sessionId); } return count; }
/** * Retrieve a value from the map. * * @param keyPartA for the key * @param keyPartB for the key * @return value matching the key if found or null if not found. */ @SuppressWarnings("unchecked") public V get(final int keyPartA, final int keyPartB) { final long key = compoundKey(keyPartA, keyPartB); final int mask = values.length - 1; int index = Hashing.hash(key, mask); Object value; while (null != (value = values[index])) { if (key == keys[index]) { break; } index = ++index & mask; } return (V)value; }
/** * Remove a value from the map and return the value. * * @param keyPartA for the key * @param keyPartB for the key * @return the previous value if found otherwise null */ @SuppressWarnings("unchecked") public V remove(final int keyPartA, final int keyPartB) { final long key = compoundKey(keyPartA, keyPartB); final int mask = values.length - 1; int index = Hashing.hash(key, mask); Object value; while (null != (value = values[index])) { if (key == keys[index]) { values[index] = null; --size; compactChain(index); break; } index = ++index & mask; } return (V)value; }
public V put(final int keyPartA, final int keyPartB, final V value) final long key = compoundKey(keyPartA, keyPartB);
public long incRefToStreamAndSession(final int streamId, final int sessionId) { return refCountByStreamIdAndSessionIdMap.incrementAndGet(Hashing.compoundKey(streamId, sessionId)); }
public long incRefToStreamAndSession(final int streamId, final int sessionId) { return refCountByStreamIdAndSessionIdMap.incrementAndGet(Hashing.compoundKey(streamId, sessionId)); }
public long decRefToStreamAndSession(final int streamId, final int sessionId) { final long key = Hashing.compoundKey(streamId, sessionId); final long count = refCountByStreamIdAndSessionIdMap.decrementAndGet(key); if (-1 == count) { refCountByStreamIdAndSessionIdMap.remove(key); throw new IllegalStateException( "could not find stream Id + session Id to decrement: " + streamId + " " + sessionId); } return count; }
/** * Retrieve a value from the map. * * @param keyPartA for the key * @param keyPartB for the key * @return value matching the key if found or null if not found. */ @SuppressWarnings("unchecked") public V get(final int keyPartA, final int keyPartB) { final long key = compoundKey(keyPartA, keyPartB); final int mask = values.length - 1; int index = Hashing.hash(key, mask); Object value; while (null != (value = values[index])) { if (key == keys[index]) { break; } index = ++index & mask; } return (V)value; }
public long decRefToStreamAndSession(final int streamId, final int sessionId) { final long key = Hashing.compoundKey(streamId, sessionId); final long count = refCountByStreamIdAndSessionIdMap.decrementAndGet(key); if (-1 == count) { refCountByStreamIdAndSessionIdMap.remove(key); throw new IllegalStateException( "could not find stream Id + session Id to decrement: " + streamId + " " + sessionId); } return count; }
/** * Remove a value from the map and return the value. * * @param keyPartA for the key * @param keyPartB for the key * @return the previous value if found otherwise null */ @SuppressWarnings("unchecked") public V remove(final int keyPartA, final int keyPartB) { final long key = compoundKey(keyPartA, keyPartB); final int mask = values.length - 1; int index = Hashing.hash(key, mask); Object value; while (null != (value = values[index])) { if (key == keys[index]) { values[index] = null; --size; compactChain(index); break; } index = ++index & mask; } return (V)value; }
public V put(final int keyPartA, final int keyPartB, final V value) final long key = compoundKey(keyPartA, keyPartB);