/** * Removes the mapping with the specified key/namespace composite key from this map, returning the state that was * found under the entry. * * @param key the key of the mapping to remove. Not null. * @param namespace the namespace of the mapping to remove. Not null. * @return the value of the removed mapping or {@code null} if no mapping * for the specified key was found. */ S removeAndGetOld(K key, N namespace) { final StateTableEntry<K, N, S> e = removeEntry(key, namespace); return e != null ? // copy-on-write check for state (e.stateVersion < highestRequiredSnapshotVersion ? getStateSerializer().copy(e.state) : e.state) : null; }
/** * Removes the mapping with the specified key/namespace composite key from this map, returning the state that was * found under the entry. * * @param key the key of the mapping to remove. Not null. * @param namespace the namespace of the mapping to remove. Not null. * @return the value of the removed mapping or {@code null} if no mapping * for the specified key was found. */ S removeAndGetOld(K key, N namespace) { final StateTableEntry<K, N, S> e = removeEntry(key, namespace); return e != null ? // copy-on-write check for state (e.stateVersion < highestRequiredSnapshotVersion ? getStateSerializer().copy(e.state) : e.state) : null; }
/** * Removes the mapping with the specified key/namespace composite key from this map, returning the state that was * found under the entry. * * @param key the key of the mapping to remove. Not null. * @param namespace the namespace of the mapping to remove. Not null. * @return the value of the removed mapping or {@code null} if no mapping * for the specified key was found. */ S removeAndGetOld(K key, N namespace) { final StateTableEntry<K, N, S> e = removeEntry(key, namespace); return e != null ? // copy-on-write check for state (e.stateVersion < highestRequiredSnapshotVersion ? getStateSerializer().copy(e.state) : e.state) : null; }
/** * Maps the specified key/namespace composite key to the specified value. Returns the previous state that was * registered under the composite key. * * @param key the key. Not null. * @param namespace the namespace. Not null. * @param value the value. Can be null. * @return the value of any previous mapping with the specified key or * {@code null} if there was no such mapping. */ S putAndGetOld(K key, N namespace, S value) { final StateTableEntry<K, N, S> e = putEntry(key, namespace); // copy-on-write check for state S oldState = (e.stateVersion < highestRequiredSnapshotVersion) ? getStateSerializer().copy(e.state) : e.state; e.state = value; e.stateVersion = stateTableVersion; return oldState; }
/** * Removes the mapping with the specified key/namespace composite key from this map, returning the state that was * found under the entry. * * @param key the key of the mapping to remove. Not null. * @param namespace the namespace of the mapping to remove. Not null. * @return the value of the removed mapping or {@code null} if no mapping * for the specified key was found. */ S removeAndGetOld(K key, N namespace) { final StateTableEntry<K, N, S> e = removeEntry(key, namespace); return e != null ? // copy-on-write check for state (e.stateVersion < highestRequiredSnapshotVersion ? getStateSerializer().copy(e.state) : e.state) : null; }
/** * Maps the specified key/namespace composite key to the specified value. Returns the previous state that was * registered under the composite key. * * @param key the key. Not null. * @param namespace the namespace. Not null. * @param value the value. Can be null. * @return the value of any previous mapping with the specified key or * {@code null} if there was no such mapping. */ S putAndGetOld(K key, N namespace, S value) { final StateTableEntry<K, N, S> e = putEntry(key, namespace); // copy-on-write check for state S oldState = (e.stateVersion < highestRequiredSnapshotVersion) ? getStateSerializer().copy(e.state) : e.state; e.state = value; e.stateVersion = stateTableVersion; return oldState; }
/** * Maps the specified key/namespace composite key to the specified value. Returns the previous state that was * registered under the composite key. * * @param key the key. Not null. * @param namespace the namespace. Not null. * @param value the value. Can be null. * @return the value of any previous mapping with the specified key or * {@code null} if there was no such mapping. */ S putAndGetOld(K key, N namespace, S value) { final StateTableEntry<K, N, S> e = putEntry(key, namespace); // copy-on-write check for state S oldState = (e.stateVersion < highestRequiredSnapshotVersion) ? getStateSerializer().copy(e.state) : e.state; e.state = value; e.stateVersion = stateTableVersion; return oldState; }
/** * Maps the specified key/namespace composite key to the specified value. Returns the previous state that was * registered under the composite key. * * @param key the key. Not null. * @param namespace the namespace. Not null. * @param value the value. Can be null. * @return the value of any previous mapping with the specified key or * {@code null} if there was no such mapping. */ S putAndGetOld(K key, N namespace, S value) { final StateTableEntry<K, N, S> e = putEntry(key, namespace); // copy-on-write check for state S oldState = (e.stateVersion < highestRequiredSnapshotVersion) ? getStateSerializer().copy(e.state) : e.state; e.state = value; e.stateVersion = stateTableVersion; return oldState; }
@Override public S get(K key, N namespace) { final int hash = computeHashForOperationAndDoIncrementalRehash(key, namespace); final int requiredVersion = highestRequiredSnapshotVersion; final StateTableEntry<K, N, S>[] tab = selectActiveTable(hash); int index = hash & (tab.length - 1); for (StateTableEntry<K, N, S> e = tab[index]; e != null; e = e.next) { final K eKey = e.key; final N eNamespace = e.namespace; if ((e.hash == hash && key.equals(eKey) && namespace.equals(eNamespace))) { // copy-on-write check for state if (e.stateVersion < requiredVersion) { // copy-on-write check for entry if (e.entryVersion < requiredVersion) { e = handleChainedEntryCopyOnWrite(tab, hash & (tab.length - 1), e); } e.stateVersion = stateTableVersion; e.state = getStateSerializer().copy(e.state); } return e.state; } } return null; }
@Override public S get(K key, N namespace) { final int hash = computeHashForOperationAndDoIncrementalRehash(key, namespace); final int requiredVersion = highestRequiredSnapshotVersion; final StateTableEntry<K, N, S>[] tab = selectActiveTable(hash); int index = hash & (tab.length - 1); for (StateTableEntry<K, N, S> e = tab[index]; e != null; e = e.next) { final K eKey = e.key; final N eNamespace = e.namespace; if ((e.hash == hash && key.equals(eKey) && namespace.equals(eNamespace))) { // copy-on-write check for state if (e.stateVersion < requiredVersion) { // copy-on-write check for entry if (e.entryVersion < requiredVersion) { e = handleChainedEntryCopyOnWrite(tab, hash & (tab.length - 1), e); } e.stateVersion = stateTableVersion; e.state = getStateSerializer().copy(e.state); } return e.state; } } return null; }
@Override public S get(K key, N namespace) { final int hash = computeHashForOperationAndDoIncrementalRehash(key, namespace); final int requiredVersion = highestRequiredSnapshotVersion; final StateTableEntry<K, N, S>[] tab = selectActiveTable(hash); int index = hash & (tab.length - 1); for (StateTableEntry<K, N, S> e = tab[index]; e != null; e = e.next) { final K eKey = e.key; final N eNamespace = e.namespace; if ((e.hash == hash && key.equals(eKey) && namespace.equals(eNamespace))) { // copy-on-write check for state if (e.stateVersion < requiredVersion) { // copy-on-write check for entry if (e.entryVersion < requiredVersion) { e = handleChainedEntryCopyOnWrite(tab, hash & (tab.length - 1), e); } e.stateVersion = stateTableVersion; e.state = getStateSerializer().copy(e.state); } return e.state; } } return null; }
@Override public S get(K key, N namespace) { final int hash = computeHashForOperationAndDoIncrementalRehash(key, namespace); final int requiredVersion = highestRequiredSnapshotVersion; final StateTableEntry<K, N, S>[] tab = selectActiveTable(hash); int index = hash & (tab.length - 1); for (StateTableEntry<K, N, S> e = tab[index]; e != null; e = e.next) { final K eKey = e.key; final N eNamespace = e.namespace; if ((e.hash == hash && key.equals(eKey) && namespace.equals(eNamespace))) { // copy-on-write check for state if (e.stateVersion < requiredVersion) { // copy-on-write check for entry if (e.entryVersion < requiredVersion) { e = handleChainedEntryCopyOnWrite(tab, hash & (tab.length - 1), e); } e.stateVersion = stateTableVersion; e.state = getStateSerializer().copy(e.state); } return e.state; } } return null; }
/** * @param key the key of the mapping to remove. Not null. * @param namespace the namespace of the mapping to remove. Not null. * @param value the value that is the second input for the transformation. * @param transformation the transformation function to apply on the old state and the given value. * @param <T> type of the value that is the second input to the {@link StateTransformationFunction}. * @throws Exception exception that happen on applying the function. * @see #transform(Object, Object, StateTransformationFunction). */ <T> void transform( K key, N namespace, T value, StateTransformationFunction<S, T> transformation) throws Exception { final StateTableEntry<K, N, S> entry = putEntry(key, namespace); // copy-on-write check for state entry.state = transformation.apply( (entry.stateVersion < highestRequiredSnapshotVersion) ? getStateSerializer().copy(entry.state) : entry.state, value); entry.stateVersion = stateTableVersion; }
/** * @param key the key of the mapping to remove. Not null. * @param namespace the namespace of the mapping to remove. Not null. * @param value the value that is the second input for the transformation. * @param transformation the transformation function to apply on the old state and the given value. * @param <T> type of the value that is the second input to the {@link StateTransformationFunction}. * @throws Exception exception that happen on applying the function. * @see #transform(Object, Object, StateTransformationFunction). */ <T> void transform( K key, N namespace, T value, StateTransformationFunction<S, T> transformation) throws Exception { final StateTableEntry<K, N, S> entry = putEntry(key, namespace); // copy-on-write check for state entry.state = transformation.apply( (entry.stateVersion < highestRequiredSnapshotVersion) ? getStateSerializer().copy(entry.state) : entry.state, value); entry.stateVersion = stateTableVersion; }
/** * @param key the key of the mapping to remove. Not null. * @param namespace the namespace of the mapping to remove. Not null. * @param value the value that is the second input for the transformation. * @param transformation the transformation function to apply on the old state and the given value. * @param <T> type of the value that is the second input to the {@link StateTransformationFunction}. * @throws Exception exception that happen on applying the function. * @see #transform(Object, Object, StateTransformationFunction). */ <T> void transform( K key, N namespace, T value, StateTransformationFunction<S, T> transformation) throws Exception { final StateTableEntry<K, N, S> entry = putEntry(key, namespace); // copy-on-write check for state entry.state = transformation.apply( (entry.stateVersion < highestRequiredSnapshotVersion) ? getStateSerializer().copy(entry.state) : entry.state, value); entry.stateVersion = stateTableVersion; }
/** * @param key the key of the mapping to remove. Not null. * @param namespace the namespace of the mapping to remove. Not null. * @param value the value that is the second input for the transformation. * @param transformation the transformation function to apply on the old state and the given value. * @param <T> type of the value that is the second input to the {@link StateTransformationFunction}. * @throws Exception exception that happen on applying the function. * @see #transform(Object, Object, StateTransformationFunction). */ <T> void transform( K key, N namespace, T value, StateTransformationFunction<S, T> transformation) throws Exception { final StateTableEntry<K, N, S> entry = putEntry(key, namespace); // copy-on-write check for state entry.state = transformation.apply( (entry.stateVersion < highestRequiredSnapshotVersion) ? getStateSerializer().copy(entry.state) : entry.state, value); entry.stateVersion = stateTableVersion; }