Streams naming conventions
Streams are an infinite sequence of tuples that are used to interconnect operators.
A stream identifier is written in camel case with the first character in uppercase (TradesAndQuotes). Appropriate stream names tend to be plural nouns or adjectives that describe how operators transform the tuples.
- Uses words that describe the data that flows in that stream.
- Uses only a few words. Lengthy stream names may indicate the program can be decomposed into composite operators.
The following code example illustrates the naming convention where stream identifiers describe the data that flows in that stream. The stream TradesAndQuotes (line 09) is the output of a FileSource operator that reads both trades and quotes transactions from a file. The stream Trades (line 13) is a filtered version of the TradesAndQuotes stream that includes only trade transactions. The stream Quotes (line 17) is a filtered version of the TradesAndQuotes stream that includes quote transactions only.
01: namespace example;
02:
03: composite Main {
04: type
05: TradeQuote = rstring ttype, rstring ticker, decimal64 price,
06: decimal64 volume;
07:
08: graph
09: stream<TradeQuote> TradesAndQuotes = FileSource() {
10: param file : "TradesAndQuotes.csv";
11: }
12:
13: stream<TradeQuote> Trades = Filter(TradesAndQuotes) {
14: param filter : ttype == "Trade";
15: }
16:
17: stream<TradeQuote> Quotes = Filter(TradesAndQuotes) {
18: param filter : ttype == "Quote";
19: }
20: }