Search in sources :

Example 6 with ProjectionFactory

use of org.apache.storm.trident.tuple.TridentTupleView.ProjectionFactory in project storm by apache.

the class AggregateProcessor 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("Aggregate operation can only have one parent");
    }
    this.context = tridentContext;
    collector = new FreshCollector(tridentContext);
    projection = new ProjectionFactory(parents.get(0), inputFields);
    agg.prepare(conf, new TridentOperationContext(context, projection));
}
Also used : ProjectionFactory(org.apache.storm.trident.tuple.TridentTupleView.ProjectionFactory) ProjectionFactory(org.apache.storm.trident.tuple.TridentTupleView.ProjectionFactory) Factory(org.apache.storm.trident.tuple.TridentTuple.Factory) TridentOperationContext(org.apache.storm.trident.operation.TridentOperationContext)

Example 7 with ProjectionFactory

use of org.apache.storm.trident.tuple.TridentTupleView.ProjectionFactory 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 8 with ProjectionFactory

use of org.apache.storm.trident.tuple.TridentTupleView.ProjectionFactory in project storm by apache.

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(org.apache.storm.trident.tuple.TridentTupleView.ProjectionFactory) ProjectionFactory(org.apache.storm.trident.tuple.TridentTupleView.ProjectionFactory) Factory(org.apache.storm.trident.tuple.TridentTuple.Factory) TridentOperationContext(org.apache.storm.trident.operation.TridentOperationContext)

Example 9 with ProjectionFactory

use of org.apache.storm.trident.tuple.TridentTupleView.ProjectionFactory in project storm by apache.

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(org.apache.storm.trident.tuple.TridentTupleView.ProjectionFactory) ProjectionFactory(org.apache.storm.trident.tuple.TridentTupleView.ProjectionFactory) Factory(org.apache.storm.trident.tuple.TridentTuple.Factory) TridentOperationContext(org.apache.storm.trident.operation.TridentOperationContext)

Example 10 with ProjectionFactory

use of org.apache.storm.trident.tuple.TridentTupleView.ProjectionFactory 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)

Aggregations

ProjectionFactory (org.apache.storm.trident.tuple.TridentTupleView.ProjectionFactory)13 Factory (org.apache.storm.trident.tuple.TridentTuple.Factory)10 TridentOperationContext (org.apache.storm.trident.operation.TridentOperationContext)8 List (java.util.List)2 TridentMultiReducerContext (org.apache.storm.trident.operation.TridentMultiReducerContext)2 TridentTuple (org.apache.storm.trident.tuple.TridentTuple)1