Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering Apache Cassandra - Second Edition

You're reading from   Mastering Apache Cassandra - Second Edition Build, manage, and configure high-performing, reliable NoSQL database for your application with Cassandra

Arrow left icon
Product type Paperback
Published in Mar 2015
Publisher Packt
ISBN-13 9781784392611
Length 350 pages
Edition 1st Edition
Languages
Arrow right icon
Toc

Cassandra and Hadoop in action


Now, with more than enough (rather boring) theory, we are ready to do something exciting. In this section, we will do a word count of a book. It will be more interesting than the grep example.

In this example, we load Lewis Carroll's novel Alice in Wonderland (http://en.wikipedia.org/wiki/Alice%27s_Adventures_in_Wonderland) in Cassandra. To prepare this data, we read the text file line by line and store 500 lines in one row. The row names are formatted as row_1, row_2, and so on, and the columns in each row have names such as col_1, col_2, and so on. Each row has almost 500 columns, and each column has one line from the file. To avoid noise, we have removed the punctuation from the lines during the load. We could certainly work on the noise reduction in the MapReduce code, but we wanted to keep it simple. What follows is the code and its explanation. It is recommended to download the code either from my GitHub account or from the book's website. Keep it handy...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime