Building Data Streaming Applications with Apache Kafka by Manish Kumar & Chanchal Singh
Author:Manish Kumar & Chanchal Singh [Kumar, Manish]
Language: eng
Format: azw3
Tags: COM062000 - COMPUTERS / Data Modeling and Design, COM018000 - COMPUTERS / Data Processing, COM051280 - COMPUTERS / Programming Languages / Java
Publisher: Packt Publishing
Published: 2017-08-18T04:00:00+00:00
Wordcount Bolt: Example of Wordcount Bolt is given next:
import org.apache.Storm.task.OutputCollector import org.apache.Storm.task.TopologyContext import org.apache.Storm.topology.IRichBolt import org.apache.Storm.topology.OutputFieldsDeclarer import org.apache.Storm.tuple.Tuple import java.util.HashMap import java.util.Map class WordCountCalculatorBolt extends IRichBolt { var wordCountMap: Map[String, Integer] = _ private var collector: OutputCollector = _ def prepare(StormConf: Map[_, _], context: TopologyContext, collector: OutputCollector): Unit = { this.wordCountMap = new HashMap[String, Integer]() this.collector = collector } def execute(input: Tuple): Unit = { var str: String = input.getString(0) str = str.toLowerCase().trim() if (!wordCountMap.containsKey(str)) { wordCountMap.put(str, 1) } else { val c: java.lang.Integer = wordCountMap.get(str) + 1 wordCountMap.put(str, c) } collector.ack(input) } def cleanup(): Unit = { for ((key, value) <- wordCountMap) { println(key + " : " + value) } } override def declareOutputFields(declarer: OutputFieldsDeclarer): Unit = {} override def getComponentConfiguration(): Map[String, Any] = null }
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Hello! Python by Anthony Briggs(9914)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9795)
The Mikado Method by Ola Ellnestam Daniel Brolund(9777)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8295)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(7778)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7763)
Grails in Action by Glen Smith Peter Ledbrook(7696)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7557)
Windows APT Warfare by Sheng-Hao Ma(6821)
Layered Design for Ruby on Rails Applications by Vladimir Dementyev(6552)
Blueprints Visual Scripting for Unreal Engine 5 - Third Edition by Marcos Romero & Brenden Sewell(6418)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6413)
Kotlin in Action by Dmitry Jemerov(5062)
Hands-On Full-Stack Web Development with GraphQL and React by Sebastian Grebe(4316)
Functional Programming in JavaScript by Mantyla Dan(4038)
Solidity Programming Essentials by Ritesh Modi(3993)
WordPress Plugin Development Cookbook by Yannick Lefebvre(3785)
Unity 3D Game Development by Anthony Davis & Travis Baptiste & Russell Craig & Ryan Stunkel(3726)
The Ultimate iOS Interview Playbook by Avi Tsadok(3702)
