Search in sources :

Example 61 with Fields

use of backtype.storm.tuple.Fields in project jstorm by alibaba.

the class GroupedStream method partitionAggregate.

@Override
public IAggregatableStream partitionAggregate(Fields inputFields, Aggregator agg, Fields functionFields) {
    Aggregator groupedAgg = new GroupedAggregator(agg, _groupFields, inputFields, functionFields.size());
    Fields allInFields = TridentUtils.fieldsUnion(_groupFields, inputFields);
    Fields allOutFields = TridentUtils.fieldsConcat(_groupFields, functionFields);
    Stream s = _stream.partitionAggregate(allInFields, groupedAgg, allOutFields);
    return new GroupedStream(s, _groupFields);
}
Also used : Fields(backtype.storm.tuple.Fields) GroupedAggregator(storm.trident.operation.impl.GroupedAggregator) CombinerAggregator(storm.trident.operation.CombinerAggregator) Aggregator(storm.trident.operation.Aggregator) ReducerAggregator(storm.trident.operation.ReducerAggregator) GroupedAggregator(storm.trident.operation.impl.GroupedAggregator) Stream(storm.trident.Stream)

Example 62 with Fields

use of backtype.storm.tuple.Fields in project jstorm by alibaba.

the class DelimitedRecordFormat method format.

@Override
public byte[] format(Tuple tuple) {
    StringBuilder sb = new StringBuilder();
    Fields fields = this.fields == null ? tuple.getFields() : this.fields;
    int size = fields.size();
    for (int i = 0; i < size; i++) {
        sb.append(tuple.getValueByField(fields.get(i)));
        if (i != size - 1) {
            sb.append(this.fieldDelimiter);
        }
    }
    sb.append(this.recordDelimiter);
    return sb.toString().getBytes();
}
Also used : Fields(backtype.storm.tuple.Fields)

Example 63 with Fields

use of backtype.storm.tuple.Fields in project storm by nathanmarz.

the class TridentSpoutExecutor method declareOutputFields.

@Override
public void declareOutputFields(OutputFieldsDeclarer declarer) {
    List<String> fields = new ArrayList(_spout.getOutputFields().toList());
    fields.add(0, ID_FIELD);
    declarer.declareStream(_streamName, new Fields(fields));
}
Also used : Fields(backtype.storm.tuple.Fields) ArrayList(java.util.ArrayList)

Example 64 with Fields

use of backtype.storm.tuple.Fields in project storm by nathanmarz.

the class MasterBatchCoordinator method declareOutputFields.

@Override
public void declareOutputFields(OutputFieldsDeclarer declarer) {
    // in partitioned example, in case an emitter task receives a later transaction than it's emitted so far,
    // when it sees the earlier txid it should know to emit nothing
    declarer.declareStream(BATCH_STREAM_ID, new Fields("tx"));
    declarer.declareStream(COMMIT_STREAM_ID, new Fields("tx"));
    declarer.declareStream(SUCCESS_STREAM_ID, new Fields("tx"));
}
Also used : Fields(backtype.storm.tuple.Fields)

Example 65 with Fields

use of backtype.storm.tuple.Fields in project storm by nathanmarz.

the class TridentUtils method getSingleOutputStreamFields.

public static Fields getSingleOutputStreamFields(IComponent component) {
    OutputFieldsGetter getter = new OutputFieldsGetter();
    component.declareOutputFields(getter);
    Map<String, StreamInfo> declaration = getter.getFieldsDeclaration();
    if (declaration.size() != 1) {
        throw new RuntimeException("Trident only supports components that emit a single stream");
    }
    StreamInfo si = declaration.values().iterator().next();
    if (si.is_direct()) {
        throw new RuntimeException("Trident does not support direct streams");
    }
    return new Fields(si.get_output_fields());
}
Also used : Fields(backtype.storm.tuple.Fields) OutputFieldsGetter(backtype.storm.topology.OutputFieldsGetter) StreamInfo(backtype.storm.generated.StreamInfo)

Aggregations

Fields (backtype.storm.tuple.Fields)130 TopologyBuilder (backtype.storm.topology.TopologyBuilder)41 Config (backtype.storm.Config)24 TridentTopology (storm.trident.TridentTopology)21 Map (java.util.Map)20 HashMap (java.util.HashMap)18 Test (org.junit.Test)17 JStormHelper (com.alibaba.starter.utils.JStormHelper)16 Values (backtype.storm.tuple.Values)15 ArrayList (java.util.ArrayList)13 LocalCluster (backtype.storm.LocalCluster)12 Stream (storm.trident.Stream)12 StreamInfo (backtype.storm.generated.StreamInfo)10 FixedBatchSpout (storm.trident.testing.FixedBatchSpout)9 HashSet (java.util.HashSet)8 LocalDRPC (backtype.storm.LocalDRPC)7 TridentState (storm.trident.TridentState)7 Count (storm.trident.operation.builtin.Count)7 GroupedStream (storm.trident.fluent.GroupedStream)6 IAggregatableStream (storm.trident.fluent.IAggregatableStream)6