Book Image

Learning Apache Flink

By : Tanmay Deshpande
Book Image

Learning Apache Flink

By: Tanmay Deshpande

Overview of this book

<p>With the advent of massive computer systems, organizations in different domains generate large amounts of data on a real-time basis. The latest entrant to big data processing, Apache Flink, is designed to process continuous streams of data at a lightning fast pace.</p> <p>This book will be your definitive guide to batch and stream data processing with Apache Flink. The book begins with introducing the Apache Flink ecosystem, setting it up and using the DataSet and DataStream API for processing batch and streaming datasets. Bringing the power of SQL to Flink, this book will then explore the Table API for querying and manipulating data. In the latter half of the book, readers will get to learn the remaining ecosystem of Apache Flink to achieve complex tasks such as event processing, machine learning, and graph processing. The final part of the book would consist of topics such as scaling Flink solutions, performance optimization and integrating Flink with other tools such as ElasticSearch.</p> <p>Whether you want to dive deeper into Apache Flink, or want to investigate how to get more out of this powerful technology, you’ll find everything you need inside.</p>
Table of Contents (17 chapters)
Learning Apache Flink
Credits
About the Author
About the Reviewers
www.PacktPub.com
Customer Feedback
Preface

Registering tables


In order to operate on datasets/datastreams, first we need to register a table in TableEnvironment. Once the table is registered with a unique name, it can be easily accessed from TableEnvironment.

TableEnvironment maintains an internal table catalogue for table registration. The following diagram shows the details:

It is very important to have unique table names, otherwise you will get an exception.

Registering a dataset

In order to perform SQL operations on a dataset, we need to register it as a table in BatchTableEnvironment. We need to define a Java POJO class while registering the table.

For instance, let's say we need to register a dataset called Word Count. Each record in this table will have word and frequency attributes. The Java POJO for the same would look like the following:

public static class WC { 
    public String word; 
    public long frequency; 
    public WC(){ 
    } 
 
    public WC(String word, long frequency) { 
      this.word = word; 
      this.frequency...