Search in sources :

Example 6 with ProjectionFactory

use of storm.trident.tuple.TridentTupleView.ProjectionFactory in project jstorm by alibaba.

the class PartitionPersistProcessor method prepare.

@Override
public void prepare(Map conf, TopologyContext context, TridentContext tridentContext) {
    List<Factory> parents = tridentContext.getParentTupleFactories();
    if (parents.size() != 1) {
        throw new RuntimeException("Partition persist operation can only have one parent");
    }
    _context = tridentContext;
    _state = (State) context.getTaskData(_stateId);
    _projection = new ProjectionFactory(parents.get(0), _inputFields);
    _collector = new FreshCollector(tridentContext);
    _updater.prepare(conf, new TridentOperationContext(context, _projection));
}
Also used : ProjectionFactory(storm.trident.tuple.TridentTupleView.ProjectionFactory) Factory(storm.trident.tuple.TridentTuple.Factory) ProjectionFactory(storm.trident.tuple.TridentTupleView.ProjectionFactory) TridentOperationContext(storm.trident.operation.TridentOperationContext)

Example 7 with ProjectionFactory

use of storm.trident.tuple.TridentTupleView.ProjectionFactory in project jstorm by alibaba.

the class StateQueryProcessor method prepare.

@Override
public void prepare(Map conf, TopologyContext context, TridentContext tridentContext) {
    List<Factory> parents = tridentContext.getParentTupleFactories();
    if (parents.size() != 1) {
        throw new RuntimeException("State query operation can only have one parent");
    }
    _context = tridentContext;
    _state = (State) context.getTaskData(_stateId);
    _projection = new ProjectionFactory(parents.get(0), _inputFields);
    _collector = new AppendCollector(tridentContext);
    _function.prepare(conf, new TridentOperationContext(context, _projection));
}
Also used : ProjectionFactory(storm.trident.tuple.TridentTupleView.ProjectionFactory) Factory(storm.trident.tuple.TridentTuple.Factory) ProjectionFactory(storm.trident.tuple.TridentTupleView.ProjectionFactory) TridentOperationContext(storm.trident.operation.TridentOperationContext)

Example 8 with ProjectionFactory

use of storm.trident.tuple.TridentTupleView.ProjectionFactory in project jstorm by alibaba.

the class GroupedMultiReducerExecutor method execute.

@Override
public void execute(Map<TridentTuple, Object> state, int streamIndex, TridentTuple full, TridentCollector collector) {
    ProjectionFactory groupFactory = _groupFactories.get(streamIndex);
    ProjectionFactory inputFactory = _inputFactories.get(streamIndex);
    TridentTuple group = groupFactory.create(full);
    TridentTuple input = inputFactory.create(full);
    Object curr;
    if (!state.containsKey(group)) {
        curr = _reducer.init(collector, group);
        state.put(group, curr);
    } else {
        curr = state.get(group);
    }
    _reducer.execute(curr, streamIndex, group, input, collector);
}
Also used : ProjectionFactory(storm.trident.tuple.TridentTupleView.ProjectionFactory) TridentTuple(storm.trident.tuple.TridentTuple)

Example 9 with ProjectionFactory

use of storm.trident.tuple.TridentTupleView.ProjectionFactory in project jstorm by alibaba.

the class AggregateProcessor method prepare.

@Override
public void prepare(Map conf, TopologyContext context, TridentContext tridentContext) {
    List<Factory> parents = tridentContext.getParentTupleFactories();
    if (parents.size() != 1) {
        throw new RuntimeException("Aggregate operation can only have one parent");
    }
    _context = tridentContext;
    _collector = new FreshCollector(tridentContext);
    _projection = new ProjectionFactory(parents.get(0), _inputFields);
    _agg.prepare(conf, new TridentOperationContext(context, _projection));
}
Also used : ProjectionFactory(storm.trident.tuple.TridentTupleView.ProjectionFactory) ProjectionFactory(storm.trident.tuple.TridentTupleView.ProjectionFactory) Factory(storm.trident.tuple.TridentTuple.Factory) TridentOperationContext(storm.trident.operation.TridentOperationContext)

Example 10 with ProjectionFactory

use of storm.trident.tuple.TridentTupleView.ProjectionFactory in project jstorm by alibaba.

the class EachProcessor method prepare.

@Override
public void prepare(Map conf, TopologyContext context, TridentContext tridentContext) {
    List<Factory> parents = tridentContext.getParentTupleFactories();
    if (parents.size() != 1) {
        throw new RuntimeException("Each operation can only have one parent");
    }
    _context = tridentContext;
    _collector = new AppendCollector(tridentContext);
    _projection = new ProjectionFactory(parents.get(0), _inputFields);
    _function.prepare(conf, new TridentOperationContext(context, _projection));
}
Also used : ProjectionFactory(storm.trident.tuple.TridentTupleView.ProjectionFactory) ProjectionFactory(storm.trident.tuple.TridentTupleView.ProjectionFactory) Factory(storm.trident.tuple.TridentTuple.Factory) TridentOperationContext(storm.trident.operation.TridentOperationContext)

Aggregations

ProjectionFactory (storm.trident.tuple.TridentTupleView.ProjectionFactory)14 Factory (storm.trident.tuple.TridentTuple.Factory)10 TridentOperationContext (storm.trident.operation.TridentOperationContext)8 List (java.util.List)2 TridentMultiReducerContext (storm.trident.operation.TridentMultiReducerContext)2 TridentTuple (storm.trident.tuple.TridentTuple)2