Coding Sandbox - Tutorials and How Tos

  • Coding
  • No categories

Hadoop Developer – WordCount tutorial using Maven and NetBeans 7.3RC2

12th February 2013 in Coding, Uncategorized
I have adapted the WordCount tutorial to Maven based development as this probably the most popular way to develop in companies. I am not going to rewrite how the WordCount tutorial works but it aims to get you up-and-running with Hadoop development pretty quickly.

I used NetBeans 7.3RC2 because of its integration with Maven but feel free to use an IDE of your choice. I am also using Ubuntu 12.10 64Bit as a development enviroment. I installed the Hadoop debian distribution package.

When running your WordCount application, Hadoop might throw an out of memory exception, this is because the default settings are -Xmx100m. Apache website mentioned how to fix it but it’s not relevant if you install it using the Debian distribution. Here is a quick solution, open the /usr/bin/hadoop (changing this file has no effect and doesn’t fix the problem /etc/hadoop/

  1. set your JAVA to the actual JVM path that you want to use.
  2. set JAVA_HEAP_MAX to increase the available memory to the applications i.e. -Xmx3000m
Here are the steps to creating the WordCount tutorial in NetBeans:
  1. Create a new Maven based Java project
    • NetBeans will create an class, you can rename it to WordCount or leave it as it doesn’t affect the outcome of the tutorial. I will refer to the main class as
  2. Add the Hadoop dependencies, they are available in Maven Central. I used the hadoop-core.1.1.1 for this tutorial.
  3. Important: Maven doesn’t package dependencies when building application unless you are working with a “war” project where it will create a lib folder. In order to make sure that our libraries are available to the our program when packaged, we need to add the maven-assembly-plugin to our pom.xml. We also declare a our “Main” class which will be used to execute the program.
  4. Open (or whatever you have renamed it to) and write the following:

You can create your Hadoop “input” directory and mount it to be HDFS then execute the following:

$ hadoop dfs -ls input

$ hadoop dfs -cat input/file01 

$ hadoop jar WordCount.jar com.etapix.wordcount.App input output

This is assuming that you are running from your project home directory and that you have installed Hadoop using the Debian distribution or you can follow the rest of the tutorial from the Apache website

Big Data, Bigger Myths

2nd January 2013 in Coding
Working at a company which focuses in finding value in data, I often come across clients asking me about the following:

1.      How “BIG” should my data be in order to considered “Big Data”

Not every company has a petabyte worth of data stored, so does size really matter? The simple answer is no. Companies should not think about “Big Data” in term of sizes but as a new paradigm. Data is stored across multiple departments which do not know how to share it and therefore impacting data-driven decision. Big Data is about accounting all enterprise data to help make timely data-driven decisions. As it was once said, all information can be accessed through few mouse clicks.

2.      SQL based systems can’t do “Big Data”

This myth was created by inexperienced data “scientists” who were trying to sell their offerings. I was once in a meeting back in 2007 with a large client; they run casinos, betting sites, bingos and etc.., when a member of their tech team asked us; why can you not just run a set of SQL queries instead of exporting to an external application (built on top of Hadoop)? What I did was to take his question offline and run a demo for him. Here is what the requirement was: calculate the distance from all our members (>20m+) to each other, tell us what clubs casinos bingo are they member of, what is the closest clubs casinos bingo to them, how often do they visit the establishments and etc… Now just the distance calculation alone blew the
Oracle server away. Don’t get me wrong, SQL based systems are part of “Big Data” as they are the best way to store, retrieve the data. For simple analytics, SQL provides great tools and they are usually more mature than their NoSQL counterparts.

3.    NoSQL is the way forward and Hadoop is the Holy Grail

This is a funny one. The NoSQL started as death to traditional RDBMS. Startups companies started to jump on the buzz wagon. There were NoSQL evangelist at every street corner, ok maybe not but you
get the point. And the early adopters started to see problems in the movement. Experienced data admins from the SQL world started converting then they stopped, why? To run an enterprise system, you need reliable mature application with a wealth of talents and knowledge to support it. In the SQL world, you had books and courses available for over 30 years+. It was easy to attract new talents for new projects and not to mention the tools which made life easier. Let’s get it clear, NoSQL systems are mainly used for data storage just as their SQL counter parts. Many techniques developed through decades of research around
fault tolerance, data replication and security have passed maturity and let’s not forget the compliance of industry standard. Look at it this way, Twitter still use MySQL. Hadoop is a distributed data processing framework which can also be achieve with Grid Computing, Peer 2 Peer systems and others.

4.    Data scientists are to Big Data What DB admin are to RDBMS

What is a data scientist and how is it different to DB admin? No difference at all. They both do exactly the same job, trying to get value out of data. This is another of those buzzwords that publishers use to sell books and increase pages views on the net. I worked with great DB admins that new the data structure and understood it uses. We could ask the DB admin about any KPIs and he would retrieve if it was possible. If you need to write Java or any form of codes, then I’m sorry you no longer a data scientist but a programmer.

5.    Big Data is a silver bullet

First of all there is no such thing as a silver bullet and big data is not an application to be implemented. Big Data is mind-set to data: capture, storing and processing. We should not think in terms of; this data is owned by X department. The data need to be integrated to give us a single view of the company. The finance department can effectively assess revenues based on marketing campaign and marketing campaign can better understand the customer based on information from the customer support team. The possibilities are endless. There is no silver bullet but we can come very close to it if we change our mindset.
Feel free to share your views in the comments section.
Join the Big Data London group on Google+

Developers should not believe the HTML5 hype

6th May 2012 in Coding, Uncategorized

As an Architect and Lead developer, I have to sit down with the non-techie and convince them why I think a technology or framework is the right one for a project and then I build my team to deliver the solution. The past two years or so, the marketing engine of technology companies have been spinning at full throttle. HTML5 is a the future, everything will run in the browser and more blah blah blah.
Don’t get me wrong, HTML5 brings some good technologies to the web application developer. Nevertheless, I think there is a lot of hype as HTML5 doesn’t really bring anything new to the table.
First of all, there are multiple type of applications that we are all well-aware of;

  • Consumer
  • Business
  • Enterprise

Consumer Application

If you are building a consumer oriented application which doesn’t use any of the native functionality of OS, then I would recommend the application to be built in HTML5 and all the RIA fanfare that comes with it. You can best view this in the mobile space where developers build either native or web apps depending on the application requirement. Remember that web application (HTML5 ) do not have direct access to printers, USB port or any other hardware such as Bluetooth and network services. Simple word processing application that can be developed in HTML5 such as Google Doc (where this blog is typed from). I haven’t come across any serious application written in HTML5 or the likes yet (JavaFX, Flash and Silverlight are not HTML5).

Business Application

Critical business application such as POS which requires access to barcode scanner as an example can’t be written using HTML5. You can have a native application delivered through the browser such as Java Applets ( or JavaFX) using webstart. Java applets can access OS features and hardware and provides another layer of security. Business application are delivered in controlled environments, for example, the application can be deployed on Linux desktop in company “a” environment only. For as much “fanfare” one might create around HTML5, these type of application will not cease to exist.

Enterprise Application

Enterprise applications come in various forms, from desktop to servers. As this is a comparison to HTML5, I will only focus on desktop application. First, let take a financial company such as a stock brokerage firm. There is a reason why stock trading application run as closely to the OS as possible ( and also to the exchange), in one word, PERFORMANCE. Web browsers performance sucks regardless of which one you are using, JavaScript is just too slow to implement some of the logic. In the trading business, a millisecond is all that is required to lose millions of £. Can you for one second imagine building a Bloomberg trading platform using web technologies, that’s laughable. There is a reason why the finance industry are still using Java Swing as their desktop technology of choice.


HTML5 is a promising step in the right direction to building scalable robust web application but it will not obliterate desktop applications, not today, not tomorrow, not ever (really!?). We can already see it in the mobile space where developers rather write native application so that they can utilize OS features and hardware. Web applications cannot access you local files directory (I am not talking uploading a file to a site) to read or write.  A simple operation such as reading available space in a directory or writing a log to a local directory is not possible (again I am not talking about downloading or saving a page). Therefore, developers should not believe the hype. HTML5 is not the silver bullet and it is a shame when companies such as Adobe sends mix-messages by discontinuing their Flex offering. Anyway, Adobe has never been a big player in the enterprise desktop application market.

If you disagree with my points, feel free to share your thoughts.