@Override public Object update(Object stored) { if(stored==null) return arg; else return agg.combine(stored, arg); } }
@Override public void execute(TridentTuple tuple, TridentCollector collector) { collector.emit(new Values(_agg.init(tuple))); }
public Result init(Object batchId, TridentCollector collector) { Result ret = new Result(); ret.obj = _agg.zero(); return ret; }
public void aggregateValue(TridentTuple tuple) { K key = mapper.getKey(tuple); V value = mapper.getValue(tuple); V currentValue = aggregateValues.get(key); V newValue; if (currentValue == null) { newValue = aggregator.init(tuple); } else { newValue = aggregator.combine(currentValue, value); } LOG.debug("Updating state [{}] ==> [{}]", new Object[]{key, newValue}); aggregateValues.put(key, newValue); }
public void aggregate(Result val, TridentTuple tuple, TridentCollector collector) { Object v = tuple.getValue(0); if (val.obj == null) { val.obj = v; } else { val.obj = _agg.combine(val.obj, v); } }
public Object init(TridentTuple tuple) { List<Object> ret = new ArrayList(); for(CombinerAggregator agg: _aggs) { ret.add(agg.init(tuple)); } return ret; }
public Object zero() { List<Object> ret = new ArrayList(); for(CombinerAggregator agg: _aggs) { ret.add(agg.zero()); } return ret; } }
@Override public Object update(Object stored) { if(stored==null) return arg; else return agg.combine(stored, arg); } }
@Override public Object init(TridentTuple tuple) { try { return getDelegate().init(tuple); } catch (FrameworkException ex) { LOG.error("init() not delegated due to a Framework exception: ", ex); return null; } catch (Exception ex) { LOG.error("init() threw an uncaught exception: ", ex); return null; } }
public Result init(Object batchId, TridentCollector collector) { Result ret = new Result(); ret.obj = _agg.zero(); return ret; }
@Override public Object update(Object stored) { if(stored==null) return arg; else return agg.combine(stored, arg); } }
@Override public void execute(TridentTuple tuple, TridentCollector collector) { collector.emit(new Values(_agg.init(tuple))); }
public Result init(Object batchId, TridentCollector collector) { Result ret = new Result(); ret.obj = _agg.zero(); return ret; }
public Object combine(Object o1, Object o2) { List l1 = (List) o1; List l2 = (List) o2; List<Object> ret = new ArrayList(); for(int i=0; i<_aggs.length; i++) { ret.add( _aggs[i].combine( l1.get(i), l2.get(i))); } return ret; }
@Override public void execute(TridentTuple tuple, TridentCollector collector) { collector.emit(new Values(_agg.init(tuple))); }
@Override public Object zero() { try { return getDelegate().zero(); } catch (FrameworkException ex) { LOG.error("zero() not delegated due to a Framework exception: ", ex); return null; } catch (Exception ex) { LOG.error("zero() threw an uncaught exception: ", ex); return null; } } }
@Override public Object combine(Object val1, Object val2) { try { return getDelegate().combine(val1, val2); } catch (FrameworkException ex) { LOG.error("combine() not delegated due to a Framework exception: ", ex); return null; } catch (Exception ex) { LOG.error("combine() threw an uncaught exception: ", ex); return null; } }
public void aggregate(Result val, TridentTuple tuple, TridentCollector collector) { Object v = tuple.getValue(0); if(val.obj==null) { val.obj = v; } else { val.obj = _agg.combine(val.obj, v); } }
public void aggregate(Result val, TridentTuple tuple, TridentCollector collector) { Object v = tuple.getValue(0); if (val.obj == null) { val.obj = v; } else { val.obj = _agg.combine(val.obj, v); } }
private boolean updateState(Map.Entry<K, V> entry, Long txid) { Statement readStatement = mapper.read(entry.getKey()); LOG.debug("EXECUTING [{}]", readStatement.toString()); ResultSet results = clientFactory.getSession().execute(readStatement); List<Row> rows = results.all(); PersistedState<V> persistedState = mapper.currentState(entry.getKey(), rows); LOG.debug("Persisted value = [{}]", persistedState.getValue()); V combinedValue; if (persistedState.getValue() != null) combinedValue = aggregator.combine(entry.getValue(), persistedState.getValue()); else combinedValue = entry.getValue(); Statement updateStatement = mapper.update(entry.getKey(), combinedValue, persistedState, txid, partitionIndex); //mapper don't want to update if(updateStatement==null){ return true; } return applyUpdate(updateStatement, txid); }