Category: Uncategorized

  • Pig: yet another approach to handling big data

    In another post, I discussed how Java can be used to analyse data in a Big Data environment. The problem then lies with Java itsself. Java is not a tool for the faint hearted; it is difficult. Moreover, one must comply with a structure where one must write two programme’s: a mapping programme and a reduce programme. These programmes communicate with a key, value pair. This structure might be too strict for the problem at hand.
    (more…)

  • Python: another language to access Big Data

    In an earlier post, I showed how Java could be used to access Big Data. I also stated that I had many problems with Java itsself. I noted that I was not the only one to have issues with Java. A much easier language is Python. This language is really easy to learn and it can be used in more or less the same situation as the Java programme.
    (more…)

  • Hadoop: my first java programme

    Today, I created a Java programme to get myself acquainted with the usage of Hadoop. I took an existing java programme to start with. This existing programme can be found at ” https://github.com/tomwhite/hadoop-book/blob/master/ch02/src/main/java/OldMaxTemperature.java “. I tweaked this programme to adjust it to my existing situation.
    (more…)

  • AWK to investigate files on Unix

    Today, I worked with the Unix’ awk utility. This is an extremely potent utility to investigate text files on a Unix platform. It can be invoked from the terminal command line. The command must start with awk.

    The keyword awk is followed by a script that is positioned between quotes. After the quotes, the textfile is mentioned (say ww-ii-data.txt).

    When some items need to initialised, we have the begin clause. The beginclause is positioned between brackets {}.
    After that a selection can be made on lines with a selection between slashes. The actions on the line are then also positioned between brackets. Finaly after the END, an end-clause may be included. We then have:

    awk ‘BEGIN {} /selection/ {} END {}’ file.

    As an example:

    awk ' 
    BEGIN {count=0;max=0}
     //{
       temp = substr($0,37,3) + 0;
       count++;
       if (max< temp)
          max=temp
            }
    END {print "regels:  ", count," max in Celcius", (5/9)*(max-32);}
    '   ww-ii-data.txt
    

    I noticed that variables can be used. No declaration is needed. Nice.

    An alternative programme is written on a file where columns are separated by commas. In that case, the seperator must be included in the BEGIN clause. This is accomplished with "FS="separator code"". If that is done, the different columns are labelled as $1, $2, etc. This allows you to directly access such a column. If one would like to use this columns, one may use a variable $1, $2 that stands for this column.

    awk ' 
    BEGIN {count=0;max=0;FS=","}
     // {
       temp = $3 + 0;
       count++;
       if (max< temp)
          max=temp
            }
    END {print "regels:  ", count," max ", max;}
    '   /home/hadoop/a.csv
    

    Finally, a statement to remove end-of-line characters in a UNIX file:

     {Processed_File}
    
  • Hadoop

    Everyone talks about big data and Hadoop. Someone even compared it to teenage sex: everone talks about it, everyone knows someone who does it but no-one yet does it. I just tried hadoop to see what it is all about.

    Yahoo-hadoop-cluster_OSCON_2007
    I made two attempts to install hadoop.
    One attempt was about installing Hadoop 1.0.3. I relied on a paper from Michael Noll ( http://www.michael-noll.com/tutorials/running-hadoop-on-ubuntu-linux-single-node-cluster/ ). I noticed it was really important to use the correct versions of the jdk; I first tried to install Hadoop 1.0.3 with a recent version of the Jdk but that failed. A subsequent attempt was successfull. This could be established with help of the interface ( localhost:50070 ).
    A second attempt was about installing Hadoop 2.4. I used a blog from Matthew Sharpe ( http://dogdogfish.com/2014/04/26/installing-hadoop-2-4-on-ubuntu-14-04/ ) to get the necessary information. After the installion, I created a small example to check if this worked. It did work.

    Hence, I ended up with two working examples of Hadoop.

    The problem is that hadoop is now alive and kicking. I verified this by executing a small example. This worked out ok. But how to continue. Working with hadoop isn’t trivial. My next step will be is finding a means to work with Hadoop.

  • Slowly Changing Dimensions Type 2

    Just to get myself acquainted with the new Informatica version, I created a mapping in which SCD 2 was inplemented. The mapping is shown here.

    Informatica

    In the first step, the input data are read.Let us assume that these records are read. The records contain a number and a name:

    number Name
    1      Tom
    2      ine
    3      paula
    4      stella
    5      Bart
    

    The records may be different in two respects to the records that are tored in the database; the records may be completely new or the records might be an update to the existing records. Let us assume the database contains subsequent records:

    PK number name     DATE                DATE_TO
    1  2      'ine'    18-11-2014 16:23:10 NULL
    2  3      'paula'  18-11-2014 16:23:10 NULL
    3  4      'stella' 18-11-2014 16:23:10 NULL
    5  5      'Bartje' 18-11-2014 16:23:10 NULL
    

    The records contain a unique key, the number, a name, a data on which the records are read and a date until which the data are valid.

    Comparison between the records that are added and records that already stored show that we have one record that is new (1, Tom) and one record that must be updated (5, Bart). Such comparison is done in the Informatica flow by a lookup, that is followed by a procedure where it is established as to whether a record is unchanged (ine, paula, stella), a record is new (Tom) and a record that is changed (Bart).

    PK	NEW	OLD	CHANGE	NEW	DATE
    1.0	ine	ine	0	0	2014-11-21 15:11:09.0
    2.0	paula	paula	0	0	2014-11-21 15:11:09.0
    3.0	stella	stella	0	0	2014-11-21 15:11:09.0
    	Tom		0	1	2014-11-21 15:11:09.0
    5.0	Bart	Bartje	1	1	2014-11-21 15:11:09.0
    

    A record that is new, must be inserted in the database with a new key. It is established that such number must be higher than 5. Hence “Tom” will be inserted in the database.

    A record that is updated leads to two actions: the existing record will be updated as to indicate that it is not valid anymore and a new record will be inserted to store “Bart”.

    In total,

    • we have an update action: the old “Bartje” record will be updated as to indicate that it is not valid anymore.
    • we have an insert action that comes from:
      • the update on Bart that generates a new record
      • the insert of Tom.

     
    We then have this result:

    PK      number    name           DATE                    DATE_TO
    1	2	 'ine'	         '18-11-2014 16:23:10.'	 NULL	
    2	3	 'paula'	 '18-11-2014 16:23:10.'	 NULL	
    3	4	 'stella'	 '18-11-2014 16:23:10.'	 NULL	
    5	5	 'Bartje'	 '18-11-2014 16:23:10.'	 '21-11-2014 15:52:49.'	
    9	1	 'Tom'	         '21-11-2014 15:52:49.'	 NULL	
    10	5	 'Bart'	         '21-11-2014 15:52:49.'	 NULL