@Override public ReadableState<Boolean> contains(T t) { return ReadableStates.immediate(contents.contains(t)); }
@Override public ReadableState<V> get(K key) { return ReadableStates.immediate(contents.get(key)); }
@Override public ReadableState<Boolean> addIfAbsent(T t) { boolean alreadyContained = contents.contains(t); contents.add(t); return ReadableStates.immediate(!alreadyContained); }
@Override public ReadableState<V> putIfAbsent(K key, V value) { V v = contents.get(key); if (v == null) { v = contents.put(key, value); } return ReadableStates.immediate(v); }
@Override public ReadableState<ValueT> get(final KeyT input) { try { return ReadableStates.immediate( flinkStateBackend .getPartitionedState( namespace.stringKey(), StringSerializer.INSTANCE, flinkStateDescriptor) .get(input)); } catch (Exception e) { throw new RuntimeException("Error get from state.", e); } }
@Override public ReadableState<ValueT> get(final KeyT input) { try { return ReadableStates.immediate( flinkStateBackend .getPartitionedState( namespace.stringKey(), StringSerializer.INSTANCE, flinkStateDescriptor) .get(input)); } catch (Exception e) { throw new RuntimeException("Error get from state.", e); } }
@Override public ReadableState<Boolean> contains(final T t) { try { Boolean result = flinkStateBackend.getPartitionedState( namespace.stringKey(), StringSerializer.INSTANCE, flinkStateDescriptor).get(t); return ReadableStates.immediate(result != null ? result : false); } catch (Exception e) { throw new RuntimeException("Error contains value from state.", e); } }
@Override public ReadableState<ValueT> get(final KeyT input) { try { return ReadableStates.immediate( flinkStateBackend.getPartitionedState( namespace.stringKey(), StringSerializer.INSTANCE, flinkStateDescriptor).get(input)); } catch (Exception e) { throw new RuntimeException("Error get from state.", e); } }
@Override public ReadableState<Boolean> contains(final T t) { try { Boolean result = flinkStateBackend .getPartitionedState( namespace.stringKey(), StringSerializer.INSTANCE, flinkStateDescriptor) .get(t); return ReadableStates.immediate(result != null && result); } catch (Exception e) { throw new RuntimeException("Error contains value from state.", e); } }
@Override public ReadableState<Boolean> contains(final T t) { try { Boolean result = flinkStateBackend .getPartitionedState( namespace.stringKey(), StringSerializer.INSTANCE, flinkStateDescriptor) .get(t); return ReadableStates.immediate(result != null && result); } catch (Exception e) { throw new RuntimeException("Error contains value from state.", e); } }
@Override public ReadableState<Boolean> addIfAbsent(final T t) { try { org.apache.flink.api.common.state.MapState<T, Boolean> state = flinkStateBackend.getPartitionedState( namespace.stringKey(), StringSerializer.INSTANCE, flinkStateDescriptor); boolean alreadyContained = state.contains(t); if (!alreadyContained) { state.put(t, true); } return ReadableStates.immediate(!alreadyContained); } catch (Exception e) { throw new RuntimeException("Error addIfAbsent value to state.", e); } }
@Override public ReadableState<Boolean> addIfAbsent(final T t) { try { org.apache.flink.api.common.state.MapState<T, Boolean> state = flinkStateBackend.getPartitionedState( namespace.stringKey(), StringSerializer.INSTANCE, flinkStateDescriptor); boolean alreadyContained = state.contains(t); if (!alreadyContained) { state.put(t, true); } return ReadableStates.immediate(!alreadyContained); } catch (Exception e) { throw new RuntimeException("Error addIfAbsent value to state.", e); } }
@Override public ReadableState<Boolean> addIfAbsent(final T t) { try { org.apache.flink.api.common.state.MapState<T, Boolean> state = flinkStateBackend.getPartitionedState( namespace.stringKey(), StringSerializer.INSTANCE, flinkStateDescriptor); boolean alreadyContained = state.contains(t); if (!alreadyContained) { state.put(t, true); } return ReadableStates.immediate(!alreadyContained); } catch (Exception e) { throw new RuntimeException("Error addIfAbsent value to state.", e); } }
@Override public ReadableState<ValueT> putIfAbsent(final KeyT key, final ValueT value) { try { ValueT current = flinkStateBackend .getPartitionedState( namespace.stringKey(), StringSerializer.INSTANCE, flinkStateDescriptor) .get(key); if (current == null) { flinkStateBackend .getPartitionedState( namespace.stringKey(), StringSerializer.INSTANCE, flinkStateDescriptor) .put(key, value); } return ReadableStates.immediate(current); } catch (Exception e) { throw new RuntimeException("Error put kv to state.", e); } }
@Override public ReadableState<ValueT> putIfAbsent(final KeyT key, final ValueT value) { try { ValueT current = flinkStateBackend.getPartitionedState( namespace.stringKey(), StringSerializer.INSTANCE, flinkStateDescriptor).get(key); if (current == null) { flinkStateBackend.getPartitionedState( namespace.stringKey(), StringSerializer.INSTANCE, flinkStateDescriptor).put(key, value); } return ReadableStates.immediate(current); } catch (Exception e) { throw new RuntimeException("Error put kv to state.", e); } }
@Override public ReadableState<ValueT> putIfAbsent(final KeyT key, final ValueT value) { try { ValueT current = flinkStateBackend .getPartitionedState( namespace.stringKey(), StringSerializer.INSTANCE, flinkStateDescriptor) .get(key); if (current == null) { flinkStateBackend .getPartitionedState( namespace.stringKey(), StringSerializer.INSTANCE, flinkStateDescriptor) .put(key, value); } return ReadableStates.immediate(current); } catch (Exception e) { throw new RuntimeException("Error put kv to state.", e); } }