use of datamodel.Market in project hazelcast-jet-reference-manual by hazelcast.
the class BuildComputation method s11.
static void s11() {
// tag::s11[]
Pipeline p = Pipeline.create();
// The stream to be enriched: trades
StreamStage<Trade> trades = p.drawFrom(Sources.mapJournal("trades", mapPutEvents(), mapEventNewValue(), START_FROM_CURRENT));
// The enriching streams: products, brokers and markets
BatchStage<Entry<Integer, Product>> prodEntries = p.drawFrom(Sources.map("products"));
BatchStage<Entry<Integer, Broker>> brokEntries = p.drawFrom(Sources.map("brokers"));
BatchStage<Entry<Integer, Market>> marketEntries = p.drawFrom(Sources.map("markets"));
// Obtain a hash-join builder object from the stream to be enriched
StreamHashJoinBuilder<Trade> builder = trades.hashJoinBuilder();
// Add enriching streams to the builder
Tag<Product> productTag = builder.add(prodEntries, joinMapEntries(Trade::productId));
Tag<Broker> brokerTag = builder.add(brokEntries, joinMapEntries(Trade::brokerId));
Tag<Market> marketTag = builder.add(marketEntries, joinMapEntries(Trade::marketId));
// Build the hash join pipeline
StreamStage<Tuple2<Trade, ItemsByTag>> joined = builder.build(Tuple2::tuple2);
// end::s11[]
// tag::s12[]
StreamStage<String> mapped = joined.map((Tuple2<Trade, ItemsByTag> tuple) -> {
Trade trade = tuple.f0();
ItemsByTag ibt = tuple.f1();
Product product = ibt.get(productTag);
Broker broker = ibt.get(brokerTag);
Market market = ibt.get(marketTag);
return trade + ": " + product + ", " + broker + ", " + market;
});
// end::s12[]
}