Search in sources :

Example 1 with TridentMultiReducerContext

use of org.apache.storm.trident.operation.TridentMultiReducerContext in project storm by apache.

the class GroupedMultiReducerExecutor method prepare.

@Override
public void prepare(Map conf, TridentMultiReducerContext context) {
    for (int i = 0; i < _groupFields.size(); i++) {
        _groupFactories.add(context.makeProjectionFactory(i, _groupFields.get(i)));
        _inputFactories.add(context.makeProjectionFactory(i, _inputFields.get(i)));
    }
    _reducer.prepare(conf, new TridentMultiReducerContext((List) _inputFactories));
}
Also used : List(java.util.List) ArrayList(java.util.ArrayList) TridentMultiReducerContext(org.apache.storm.trident.operation.TridentMultiReducerContext)

Example 2 with TridentMultiReducerContext

use of org.apache.storm.trident.operation.TridentMultiReducerContext in project storm by apache.

the class MultiReducerProcessor method prepare.

@Override
public void prepare(Map<String, Object> conf, TopologyContext context, TridentContext tridentContext) {
    List<Factory> parents = tridentContext.getParentTupleFactories();
    this.context = tridentContext;
    streamToIndex = new HashMap<>();
    List<String> parentStreams = tridentContext.getParentStreams();
    for (int i = 0; i < parentStreams.size(); i++) {
        streamToIndex.put(parentStreams.get(i), i);
    }
    projectionFactories = new ProjectionFactory[projectFields.size()];
    for (int i = 0; i < projectFields.size(); i++) {
        projectionFactories[i] = new ProjectionFactory(parents.get(i), projectFields.get(i));
    }
    collector = new FreshCollector(tridentContext);
    reducer.prepare(conf, new TridentMultiReducerContext((List) Arrays.asList(projectionFactories)));
}
Also used : ProjectionFactory(org.apache.storm.trident.tuple.TridentTupleView.ProjectionFactory) Factory(org.apache.storm.trident.tuple.TridentTuple.Factory) ProjectionFactory(org.apache.storm.trident.tuple.TridentTupleView.ProjectionFactory) List(java.util.List) TridentMultiReducerContext(org.apache.storm.trident.operation.TridentMultiReducerContext)

Example 3 with TridentMultiReducerContext

use of org.apache.storm.trident.operation.TridentMultiReducerContext in project storm by apache.

the class MultiReducerProcessor method prepare.

@Override
public void prepare(Map conf, TopologyContext context, TridentContext tridentContext) {
    List<Factory> parents = tridentContext.getParentTupleFactories();
    _context = tridentContext;
    _streamToIndex = new HashMap<>();
    List<String> parentStreams = tridentContext.getParentStreams();
    for (int i = 0; i < parentStreams.size(); i++) {
        _streamToIndex.put(parentStreams.get(i), i);
    }
    _projectionFactories = new ProjectionFactory[_projectFields.size()];
    for (int i = 0; i < _projectFields.size(); i++) {
        _projectionFactories[i] = new ProjectionFactory(parents.get(i), _projectFields.get(i));
    }
    _collector = new FreshCollector(tridentContext);
    _reducer.prepare(conf, new TridentMultiReducerContext((List) Arrays.asList(_projectionFactories)));
}
Also used : ProjectionFactory(org.apache.storm.trident.tuple.TridentTupleView.ProjectionFactory) Factory(org.apache.storm.trident.tuple.TridentTuple.Factory) ProjectionFactory(org.apache.storm.trident.tuple.TridentTupleView.ProjectionFactory) List(java.util.List) TridentMultiReducerContext(org.apache.storm.trident.operation.TridentMultiReducerContext)

Example 4 with TridentMultiReducerContext

use of org.apache.storm.trident.operation.TridentMultiReducerContext in project storm by apache.

the class GroupedMultiReducerExecutor method prepare.

@Override
public void prepare(Map<String, Object> conf, TridentMultiReducerContext context) {
    for (int i = 0; i < groupFields.size(); i++) {
        groupFactories.add(context.makeProjectionFactory(i, groupFields.get(i)));
        inputFactories.add(context.makeProjectionFactory(i, inputFields.get(i)));
    }
    reducer.prepare(conf, new TridentMultiReducerContext((List) inputFactories));
}
Also used : List(java.util.List) ArrayList(java.util.ArrayList) TridentMultiReducerContext(org.apache.storm.trident.operation.TridentMultiReducerContext)

Aggregations

List (java.util.List)4 TridentMultiReducerContext (org.apache.storm.trident.operation.TridentMultiReducerContext)4 ArrayList (java.util.ArrayList)2 Factory (org.apache.storm.trident.tuple.TridentTuple.Factory)2 ProjectionFactory (org.apache.storm.trident.tuple.TridentTupleView.ProjectionFactory)2