Friday, August 17, 2007

Pursuit...

This part of my life is called pursuit, pursuit of everything. Morning till night I run, I pursuit something that I don’t know. Some time I think myself have I pursuit for something? I never get any satisfy able answer from myself. But I can feel my pursuit.

Sometime I think that I pursuit for my past life. Everyone just passed from graduation school and enter into new job must pursuit his past life once a day. I am not a very much nostalgic though I feel that was my golden era.

Just after that I feel I pursuit for my future, for a better life. In a materialistic society everyone are in a rat race, some time I feel I am tired, I am tired within I years. Fucking life, Am I a looser? Nope, I am not a looser; I still know I can do whatever I want.

Thursday, July 26, 2007

Life in Dark...

It is almost 10 pm; we are sitting upon a rock and setting up for our next plan. Rokib, Shuvro: my two office colleague and I had leaved from Dhaka at Wednesday to wards Rumana para a tribal village in Bandarban. One of the relative of Rokib was sick, and we were going to help him from Dhaka. We were in hurry because we didn’t get enough vacation. We reached Bandarban about 6 am, and from that we are approaching for Rumana para through track, bus, jeep, boat and above all foot.

Bandarban is one of the hilly regions in Bangladesh. Journey to Rumana para takes almost two days, and we were intended to cover it within one day. There is no other option without walking for the last few paths, because road network cannot reach there to complicate tribal life. Most remarkable mistake we did, we just carried one torch, so we are approaching almost in dark. And it is almost 10 pm when we realize that we are lost, we lost in hills. Our single torch dimmed down and we can realize that it is quite random that people comes here. We reached a dead end, and the path we cross are over a canal, and water level is rising. And there is very high probability that we don’t find out the path by which we reached that dead end, because it was not a path actually.

We were very hungry, because we didn’t take any food. Lion is roaring inside our stomach. If everything was perfect then we were supposed to be in Darjiling para, and we were planned to take food from there.

So our next task becomes find any locality and begs some foods. But after one and half hour later we became sure there was no locality near that. And we don’t know the path to any locality. This is the most tentative night in my life. Then we decided to back, and we will back taking the path that goes along with the canal. We were weakening but we knew that we must find a locality. Otherwise the only path remains for us that go to hell directly. Sometime after that I feel only will power saved us from that situation, otherwise I should not.

The only will power was we knew that we were at best 10 kilo from nearest locality, but we couldn’t recognize that path. It is about 3 pm when I heard a pig. I never noticed before that pig could be such a beloved creature for me. I just feel I find the best things in my life.

We lead our daily life, but very few of us ever noticed that what a wonderful things it is. Life is the ultimate gift of God for any of us. This is some of my experience in my life of a dark uncertain night. What I feel, that the most vital things is survival. I know for myself that how much love I encompass for myself. Life is for living anything else.

"tentative life"

Friday, July 20, 2007

Too many bitter tears are raining down on me

I'm just the shadow of the man I used to be
And it seems like there's no way out of this for me

(Queen - Too Much Love Will Kill You)

Thursday, July 19, 2007

Life at KAZ

It is not a very long time I have completed my graduation, just November 2006. After that I joined KAZ Software Ltd, an unidentified outsourcing company in Bangladesh, at least towards BUET guys. I graduate from BUET. I was very confused about my decision. Merely I was one of the well known fellows in CSE department. Lots of people out there were confused about KAZ and asked me lot. Probably it was very courageous decision for me to join KAZ after interview. Because when I came for the interview I just found an apartment with three rooms at Eskaton. And when I was asked to solve a problem, they took me to a computer desk and I found that many of keys are missing in that keyboard, and it seems from big bang.

I was so sure that company will pack up their bags within one year. But I was wrong; they are not so deprived, they are growing, growing at great speed. Now the question is why they look so underprivileged. I don’t know, but now we shift our office to new office space “Nirvana”. I don’t think it is outstanding but it can instigate your mind for a few moments. Now it is about eight months I am here. I find myself lucky that they choose me to work with them. They are simply marvelous. They possess everything to set paradigm for Bangladeshi Software Company. All of them are so helpful that sometime I became confused that are they colleague, or elder brother.

So, times are passing on. Am I happy? May be, may be not? But life at KAZ is better than anywhere else in Bangladesh. We go for the party almost twice a week. We pass time by gossiping. When you are here you never feel that anybody have any kind of pressure here, but if you have association with software production then you must know that most of the time it is difficult for developer to meet the dead line. But I can announce; we never miss any deadline. We are such a team. Bad luck for me that I can’t stay here for a long time. I have to leave, to pursue new challenges of life.

Tuesday, July 17, 2007

Common C# Trick

C# does not support to update UI from any other thread. So update UI from any other thread have a common trick. I am so dumb that I discover it every time and forget again. So write it in my blog so that it will be easier for me to find out next time. This is just a kind of GUI that read the hex version of any file. That's it.

Code... ... ...

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using System.IO;

namespace HEXReader

{

public partial class MainForm : Form

{

public delegate void ReaderEventHandler(string hexText, string charText);

public event ReaderEventHandler ReadEvent;

public MainForm()

{

InitializeComponent();

ReadEvent += new ReaderEventHandler(MainForm_ReadEvent);

}

void MainForm_ReadEvent(string hexText, string charText)

{

if (hexText != null && charText != null)

{

this.richTextBox1.Text += hexText;

this.richTextBox2.Text += charText;

}

else

{

MessageBox.Show("Finished");

}

}

private void button2_Click(object sender, EventArgs e)

{

Application.Exit();

}

private FileStream _in;

private void button1_Click(object sender, EventArgs e)

{

OpenFileDialog opneFile = new OpenFileDialog();

DialogResult _res = opneFile.ShowDialog(this);

if (_res == DialogResult.OK)

{

this.richTextBox2.Text = "";

this.richTextBox1.Text = "";

_in = (FileStream)opneFile.OpenFile();

System.Threading.Thread operationThread = new System.Threading.Thread(new System.Threading.ThreadStart(Start));

operationThread.Start();

this.textBox1.Text = opneFile.FileName;

}

}

private void Start()

{

Reader newReader = new Reader();

newReader.ReadEvent += new Reader.ReaderEventHandler(newReader_ReadEvent);

newReader.Read(this._in);

}

void newReader_ReadEvent(string hexText, string charText)

{

object[] oarray = new object[2];

oarray[0] = hexText;

oarray[1] = charText;

this.BeginInvoke(ReadEvent, oarray);

}

}

public class Reader

{

public delegate void ReaderEventHandler(string hexText, string charText);

public event ReaderEventHandler ReadEvent;

public void Read(FileStream _in)

{

if (_in.CanRead)

{

int _count = 0;

byte[] data = new byte[1024 * 8];

do

{

string charText = "";

string hexText = "";

_count = _in.Read(data, 0, 1024 * 8);

for (int index = 0; index < _count; index++)

{

byte _curr = (byte)data[index];

int _val = (0x0F & ((0xF0 & _curr) >> 4));

if (_val < 10)

hexText += _val.ToString();

else

hexText += (char)('A' + (_val - 10));

_val = 0x0F & _curr;

if (_val < 10)

hexText += _val.ToString();

else

hexText += (char)('A' + (_val - 10));

hexText += " ";

charText += (char)_curr;

}

if (ReadEvent != null)

ReadEvent(hexText,charText);

} while (_count > 0);

}

if (ReadEvent != null)

ReadEvent(null, null);

}

}

}

Sunday, July 15, 2007

The Mayonnaise Jar and 2 Cups of Coffee

When things in your lives seem almost too much to handle, when 24 hours in a day are not enough, remember the mayonnaise jar and the 2 cups of coffee.

A professor stood before his philosophy class and had some items in front of him. When the class began, he wordlessly picked up a very large and empty mayonnaise jar and proceeded to fill it with golf balls. He then asked the students if the jar was full. They agreed that it was.

The professor then picked up a box of pebbles and poured them into the jar. He shook the jar lightly. The pebbles rolled into the open areas between the golf balls. He then asked the students again if the jar was full. They agreed it was.

The professor next picked up a box of sand and poured it into the jar. Of course, the sand filled up everything else. He asked once more if the jar was full. The students responded with an unanimous "yes."

The professor then produced two cups of coffee from under the table and poured the entire contents into the jar effectively filling the empty space between the sand. The students laughed.

"Now," said the professor as the laughter subsided, "I want you to recognize that this jar represents your life. The golf balls are the important things--your family, your children, your health, your friends and your favorite passions---and if everything else was lost and only they remained, your life would still be full.

The pebbles are the other things that matter like your job, your house and your car.

The sand is everything else---the small stuff. "If you put the sand into the jar first," he continued, "there is no room for the pebbles or the golf balls. The same goes for life. If you spend all your time and energy on the small stuff you will never have room for the things that are important to you.

"Pay attention to the things that are critical to your happiness. Play with your children. Take time to get medical checkups. Take your spouse out to dinner. Play another 18. There will always be time to clean the house and fix the disposal. Take care of the golf balls first---the things that really matter. Set your priorities. The rest is just sand."

One of the students raised her hand and inquired what the coffee represented. The professor smiled. "I'm glad you asked. It just goes to show you that no matter how full your life may seem, there's always room for a couple of cups of coffee with a friend."

(Collected)

I found it interesting. I think this is the major similarities between man and computer to sort out the right things at right time...

Results...

Different Data Cube generation time with different dimension, and different dimension number is given below:

These two curves are almost similar and they are linear with respect to the tuple size. And the data for the District wise Division Data line [Fig 1] is steeper than the Month wise year Data line [Fig 2]. Because Division level Hierarchy has more follower than the Year level Hierarchy. So, querying with hierarchy which is followed by more hierarchy, then the resulting line will be steeper. But both of them are linear with respect to tuple size.

These two curves are almost similar and they are linear with respect to tuple size. And the data for the District wise Division Data and smaller Range wise Range line [Fig 4] is steeper than the Data District wise Division Data and Month wise year Data line [Fig 3]. Because range hierarchy is concrete hierarchy wile Year hierarchy is a discrete hierarchy. So, Query with respect to concrete hierarchy will take more time than the discrete hierarchy.

In the Fig 5 all the curves seem to be straight line. That is all of them are linear with respect to tuple size. But the difference is the slope. Time with higher dimension has steeper line than the time with lower dimension count. And in the analysis of the algorithm we show that the slope is (number of dimension x average tuple count). So, the results support the mathematical analysis of the algorithm. Again from the analysis of the data we see that, for the fixed tuple size, time with respect to dimension number increases linearly. That also supports our mathematical analysis. So, the time is linear with respect to nay of them.

Fig 1: Cube generation time for District wise Division Data
Fig 2: Cube Generation time for Month wise Year Data
Fig 3: Cube generations time for Month wise year Data and District wise Division Data
Fig 4: Cube generations time for District wise Division Data and Smaller range wise Range Data
Fig 5: Cube generations time for different number of dimensions with different dimension value

In the Fig 6 the black line indicates the normal algorithm’s tuple vs. time relation and the cyne line indicates the hash mapped algorithm’s tuple vs. time relation, that we have developed. From the figure we found that normal algorithm is polynomial. We also found that our developed algorithm is linear.

Fig 6: Time comparison between normal and hash mapped algorithm

Here is the result of the space required to hold the data cube. In the Fig 7 we see the graph is almost linear, hence the space required is linear with respect to tuple size. This line cut the X-axis, but in reality the size will be fixed at 8KB, which is the block size of windows file system.

Fig 7: Transaction Table size vs Space required

Pseudo code and Mathematical Analysis

I have describe the cube generation algorithm based on HashMap. First we get the entire dimension in a vector. Then iterate over the vector and get the taransactionID and Amount for each dimension in the first while loop. And another HashMap is build with respect to DimensionID and previously build HashMap. Then we iterate through the second HashMap in the next while loop. And find the common transactionID which belongs to all the Map, and push them as final result.

Algorithm:

HashMap dimensionID2hashMapPointer;

Iterator dimensionIterator = dimension->begin();

while(dimensionIterator != dimension->end())

begin

HashMapPointer transactionID2Amount = new HashMap();

Query newQuery = BuildQuery();

ResultSet queryResult = get the query result which contain transactionID

and Amount;

Iterator dataIterator = queryResult->begin();

Repeat

tuple = dataIterator ->tuple();

transactionID2Amount = tuple;

dataIterator = dataIterator->next();

until (dataIterator != queryResult->end())

end

HashMapPointer firstDimension = dimensionID2hashMapPointer->begin();

Iterator mapIterator = firstDimension->begin();

While(mapIterator != firstDimension->end())

begin

Boolean found = true;

String resultString = DimensionID+”#”;

for all other dimension

begin

Boolean newfound = Is transactionID is in current HashMap;

found = found &&amp;amp;amp;amp;amp; newfound;

resultString += currentDimensionID+”#”;

end

If(found)

resultList->add(resultString+”TransactionID+amount”);

end


Complexity:

Let,

The query has Dimension Number = n;

The fact table has tuple count = t;

Average tuple count for any query = ta;

HashMap has constant searching time = s;

So, the first while loop has time = O(n x ta);

The second while loop has time = O( (ta) x (n-1) x s )

= O((ta) x (n-1)) [ as s is constant]

So, the total algorithm complexity = O(n x ta);

Time Complexity:

The cube access time is linear in this development. It should be polynomial as the dimension of the cube increases, but in this development Hash map algorithms were used to make the polynomial time linear. This can be considered as a great achievement in this system. So the cube generation time = O(n) here n is the number tuples in the fact table.

Space Complexity:

The space required for holding the cube is almost linear with respect to tuple size. Except if tuple size is too low. For very few tuple sizes the space will be constant and after a threshold value the space will increase linearly.

Schema

We have used snow-flake schema for storing the transactional data. In Fig the used schema diagram with the hierarchies are given, where we have shown the ERD of the schema. Here we have shown the hierarchy and the fact table. This is a sort of snowflake schema, and in the ERD there is two reference of BranchInfo related to the transaction table. They can be described as one is for where the transaction executed, and other branch reference through AccountInfo is for account to which the balance is changed. Thus they may not same. Hence this information is not redundant. And we get bank information from the account information. For inter bank transaction or inter account transaction here will be two entries in the fact table, one for debit and other for credit. In the diagram we see that there is a range hierarchy. Range is a concrete attribute but in the schema we made it discrete attribute to ensure faster query response. Query with a concrete attribute require more time than the query with discrete attribute. So, we transfer the concrete attribute into discrete attribute. Similarly we made the time hierarchy, and the last type hierarchy is for transaction type. This will define what type of transaction is defined by the entry.

All these are based on banking system. A data warehouse for banking system.

Comparative study of Data Warehouse and Data Mart

Before we are going to compare data warehouse and data mart first we have to define what “data mart” is.
In simple words we can define data mart as “specialized, subject-oriented, integrated, volatile, time-variant data store in support of a specific subset of management’s decisions”. It is actually a specialized version of a data warehouse, where it contains a snapshot of operational data, predicated on a specific, predefined need for a certain grouping and configuration of select data.
There can be multiple data marts inside a single corporation; each one relevant to one or more business units for which it was designed. Data Marts may or may not be dependent or related to other data marts in a single corporation. If the data marts are designed using conformed facts and dimensions, then they will be related. In some deployments, each department or business unit is considered the “owner” of their data mart which includes all the “hardware, software and data.” This enables each department to use, manipulate and develop their data any way they see fit; without altering information inside other data marts or the data warehouse. In other deployments where conformed dimensions are used, this business unit ownership will not hold true for shared dimensions like customer, product, etc.
So, we found that data marts are actually some sub-set of a Data Warehouse, where they are maintained for the ease of the business people. There is no way that, when a data mart reaches certain size, it becomes data warehouse, or some collections of data marts comprise or become a substitute for a data warehouse. No matter how many characteristics they have in common, data marts and data warehouses will always be different. They can not be used interchangeably, and it’s only when they’re paired together that they operate at their optimal potential.