Simple Lambda – Java8

public class LambdaSample {
  protected interface SimpleCalc {
    int operation(int a, int b);
  public static void main(String[] args) {
     * Old style
    SimpleCalc add = new SimpleCalc() {
    public int operation(int a, int b) {
      return a + b;
  System.out.println(add.operation(2, 5));
   * New style - Lambda Expression
  SimpleCalc multiply = (a, b) -> a * b;
  System.out.println(multiply.operation(2, 5));

In the above code you can see the old vs new style of anonymous function creation. Lambda expression makes it short, concise and readable. [its look readable to me :)]


Building Cloudera cdh5.1.3 – Hadoop Native – [Ubuntu 14.04 Server x64]

WARN: Unable to load native-hadoop library for your platform… using builtin-java classes where app

On starting Cloudera cdh5 hadoop if you get above warning – then either your hadoop native is not on path or you don’t have native library available in your distribution.

For case 1: solution is simple.

export HADOOP_OPTS="$HADOOP_OPTS -Djava.library.path=$HADOOP_HOME/lib/native"

For case 2: follow below steps

  1. Install jdk7 and maven [skip if already installed]
  2. sudo apt-get install build-essential
  3. apt-get install cmake
  4. apt-get install pkg-config
  5. apt-get install libcurl4-openssl-dev
  6. install protobuf-2.5.0.tar.gz
  7. Goto “hadoop-2.3.0-cdh5.1.3/src” folder and run
    mvn package -Pdist,native -DskipTests -Dtar

check “hadoop-2.3.0-cdh5.1.3/src/hadoop-dist/target/hadoop-2.3.0-cdh5.1.3/lib/native”
or you can use – “hadoop-2.3.0-cdh5.1.3/src/hadoop-dist/target/hadoop-2.3.0-cdh5.1.3.tar.gz”