PowerExchange for Cassandra User Guide

PowerExchange for Cassandra User Guide

Example: Read Data from Flat Files Generated from Sensors and Write to Cassandra

Example: Read Data from Flat Files Generated from Sensors and Write to Cassandra

A weather channel uses flat files with comma-separated values to store real-time weather details generated from sensors. To provide better performance and scalability, the weather channel needs to migrate data from the flat file to a Cassandra database.
The weather channel stores the real-time temperature details in a flat file.
The following table describes the content of a flat file that stores temperature details:
WeatherStation_ID
String
Event_time
Timestamp
Temperature
String
Create a mapping to extract data from the flat file and load it to a Cassandra column family. Create a flat file data object in read mode and create a Cassandra data object in write mode. The following is the definition of the temperature column family:
CREATE TABLE temperature ( weatherstation_id text, event_time timestamp, temperature text, PRIMARY KEY (weatherstation_id,event_time) );
The following image shows the mapping:

Mapping Input

The mapping source is a comma-separated flat file. The source contains information on weather station, time, and temperature. Source columns include columns such as weatherstation_id, date, event_time, and temperature.

Mapping Output

The mapping output is a Cassandra data object to write data to the temperature column family in the Cassandra database. When you run the mapping, the Data Integration Service reads weather information from the flat file and writes the data to the Cassandra database.

0 COMMENTS

We’d like to hear from you!