Book Image

Storm Blueprints: Patterns for Distributed Real-time Computation

Book Image

Storm Blueprints: Patterns for Distributed Real-time Computation

Overview of this book

Table of Contents (17 chapters)
Storm Blueprints: Patterns for Distributed Real-time Computation
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Introducing Trident operations – filters and functions


Now that we have events being generated, the next step is to add the logic components that implement the business process. In Trident, these are known as operations. In our topology, we are using two different types of operations: filters and functions.

Operations are applied to streams via methods on the Stream object. In this example, we use the following methods on the Stream object:

public class Stream implements IAggregatableStream {
public Stream each(Fields inputFields, Filter filter) {
...
}

public IAggregatableStream each(Fields inputFields,
Function function,
Fields functionFields){
   ...
}
   
public GroupedStream groupBy(Fields fields) {
   ...
   }

public TridentState persistentAggregate(
StateFactory stateFactory,
CombinerAggregator agg, 
Fields functionFields) {
        ...
}
}

Note that the methods in the preceding code return forms of the Stream objects or TridentState that can be used to create additional streams. With...