use of org.apache.storm.trident.tuple.TridentTupleView.ProjectionFactory in project storm by apache.
the class ProjectedProcessor method prepare.
@Override
public void prepare(Map conf, TopologyContext context, TridentContext tridentContext) {
if (tridentContext.getParentTupleFactories().size() != 1) {
throw new RuntimeException("Projection processor can only have one parent");
}
_context = tridentContext;
_factory = new ProjectionFactory(tridentContext.getParentTupleFactories().get(0), _projectFields);
}
use of org.apache.storm.trident.tuple.TridentTupleView.ProjectionFactory in project storm by apache.
the class StateQueryProcessor method prepare.
@Override
public void prepare(Map<String, Object> 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");
}
this.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));
}
use of org.apache.storm.trident.tuple.TridentTupleView.ProjectionFactory in project storm by apache.
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);
}
Aggregations