@Override public void add(T value) throws IOException { if (value == null) { clear(); return; } try { stateTable.transform(currentNamespace, value, foldTransformation); } catch (Exception e) { throw new IOException("Could not add value to folding state.", e); } }
@Override public void add(T value) throws IOException { if (value == null) { clear(); return; } try { stateTable.transform(currentNamespace, value, foldTransformation); } catch (Exception e) { throw new IOException("Could not add value to folding state.", e); } }
@Override public void add(IN value) throws IOException { final N namespace = currentNamespace; if (value == null) { clear(); return; } try { stateTable.transform(namespace, value, aggregateTransformation); } catch (Exception e) { throw new IOException("Exception while applying AggregateFunction in aggregating state", e); } }
@Override public void add(IN value) throws IOException { final N namespace = currentNamespace; if (value == null) { clear(); return; } try { stateTable.transform(namespace, value, aggregateTransformation); } catch (Exception e) { throw new IOException("Exception while applying AggregateFunction in aggregating state", e); } }
@Override public void add(V value) throws IOException { if (value == null) { clear(); return; } try { stateTable.transform(currentNamespace, value, reduceTransformation); } catch (Exception e) { throw new IOException("Exception while applying ReduceFunction in reducing state", e); } }
@Override public void add(V value) throws IOException { if (value == null) { clear(); return; } try { stateTable.transform(currentNamespace, value, reduceTransformation); } catch (Exception e) { throw new IOException("Exception while applying ReduceFunction in reducing state", e); } }
@Override public void add(V value) throws IOException { if (value == null) { clear(); return; } try { stateTable.transform(currentNamespace, value, reduceTransformation); } catch (Exception e) { throw new IOException("Exception while applying ReduceFunction in reducing state", e); } }
@Override public void add(V value) throws IOException { if (value == null) { clear(); return; } try { stateTable.transform(currentNamespace, value, reduceTransformation); } catch (Exception e) { throw new IOException("Exception while applying ReduceFunction in reducing state", e); } }
@Override public void add(T value) throws IOException { if (value == null) { clear(); return; } try { stateTable.transform(currentNamespace, value, foldTransformation); } catch (Exception e) { throw new IOException("Could not add value to folding state.", e); } }
@Override public void add(T value) throws IOException { if (value == null) { clear(); return; } try { stateTable.transform(currentNamespace, value, foldTransformation); } catch (Exception e) { throw new IOException("Could not add value to folding state.", e); } }
@Override public void add(IN value) throws IOException { final N namespace = currentNamespace; if (value == null) { clear(); return; } try { stateTable.transform(namespace, value, aggregateTransformation); } catch (Exception e) { throw new IOException("Exception while applying AggregateFunction in aggregating state", e); } }
@Override public void add(IN value) throws IOException { final N namespace = currentNamespace; if (value == null) { clear(); return; } try { stateTable.transform(namespace, value, aggregateTransformation); } catch (Exception e) { throw new IOException("Exception while applying AggregateFunction in aggregating state", e); } }
@Override public void addAll(List<V> values) throws Exception { Preconditions.checkNotNull(values, "List of values to add cannot be null."); if (!values.isEmpty()) { stateTable.transform(currentNamespace, values, (previousState, value) -> { if (previousState == null) { previousState = new ArrayList<>(); } for (V v : value) { Preconditions.checkNotNull(v, "You cannot add null to a ListState."); previousState.add(v); } return previousState; }); } } }
@Override public void addAll(List<V> values) throws Exception { Preconditions.checkNotNull(values, "List of values to add cannot be null."); if (!values.isEmpty()) { stateTable.transform(currentNamespace, values, (previousState, value) -> { if (previousState == null) { previousState = new ArrayList<>(); } for (V v : value) { Preconditions.checkNotNull(v, "You cannot add null to a ListState."); previousState.add(v); } return previousState; }); } }
@Override public void addAll(List<V> values) throws Exception { Preconditions.checkNotNull(values, "List of values to add cannot be null."); if (!values.isEmpty()) { stateTable.transform(currentNamespace, values, (previousState, value) -> { if (previousState == null) { previousState = new ArrayList<>(); } for (V v : value) { Preconditions.checkNotNull(v, "You cannot add null to a ListState."); previousState.add(v); } return previousState; }); } }
@Override public void mergeNamespaces(N target, Collection<N> sources) throws Exception { if (sources == null || sources.isEmpty()) { return; // nothing to do } final StateTable<K, N, SV> map = stateTable; SV merged = null; // merge the sources for (N source : sources) { // get and remove the next source per namespace/key SV sourceState = map.removeAndGetOld(source); if (merged != null && sourceState != null) { merged = mergeState(merged, sourceState); } else if (merged == null) { merged = sourceState; } } // merge into the target, if needed if (merged != null) { map.transform(target, merged, mergeTransformation); } }
@Override public void mergeNamespaces(N target, Collection<N> sources) throws Exception { if (sources == null || sources.isEmpty()) { return; // nothing to do } final StateTable<K, N, SV> map = stateTable; SV merged = null; // merge the sources for (N source : sources) { // get and remove the next source per namespace/key SV sourceState = map.removeAndGetOld(source); if (merged != null && sourceState != null) { merged = mergeState(merged, sourceState); } else if (merged == null) { merged = sourceState; } } // merge into the target, if needed if (merged != null) { map.transform(target, merged, mergeTransformation); } }
@Override public void mergeNamespaces(N target, Collection<N> sources) throws Exception { if (sources == null || sources.isEmpty()) { return; // nothing to do } final StateTable<K, N, SV> map = stateTable; SV merged = null; // merge the sources for (N source : sources) { // get and remove the next source per namespace/key SV sourceState = map.removeAndGetOld(source); if (merged != null && sourceState != null) { merged = mergeState(merged, sourceState); } else if (merged == null) { merged = sourceState; } } // merge into the target, if needed if (merged != null) { map.transform(target, merged, mergeTransformation); } }
@Override public void mergeNamespaces(N target, Collection<N> sources) throws Exception { if (sources == null || sources.isEmpty()) { return; // nothing to do } final StateTable<K, N, SV> map = stateTable; SV merged = null; // merge the sources for (N source : sources) { // get and remove the next source per namespace/key SV sourceState = map.removeAndGetOld(source); if (merged != null && sourceState != null) { merged = mergeState(merged, sourceState); } else if (merged == null) { merged = sourceState; } } // merge into the target, if needed if (merged != null) { map.transform(target, merged, mergeTransformation); } }