Overflow the number of bins !!!

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
khanhlv
Posts: 21
Joined: Thu May 22, 2008 10:27 am

Overflow the number of bins !!!

Post by khanhlv » Thu May 22, 2008 10:42 am

Hi everyone! Is there anybody can help me !!!

I need to draw a histogram chart but the x-axis is the address of computer (in hexa number). So the number of bins is greater Integer.Maximum because the width of bin = 1.

I have not found the solution yet, please help me to solve this problem!!!
Thanks!
p/s: If impossible, is there any chart similar!??

Taqua
JFreeReport Project Leader
Posts: 698
Joined: Fri Mar 14, 2003 3:34 pm
Contact:

Post by Taqua » Thu May 22, 2008 11:35 am

Dont use a XYChart, use a CategoryChart (Barchart) instead and do your own aggregation before you fire up the chart.

I guess you do not receive messages from all 2^32 possible IP-addresses, you might be happy if there are a million or two different addresses show up. (As most IP addresses are part of non-public networks and therefore never show up anywhere.)

After all, it is not difficult to count the number of distinct numbers. And if your data comes from a database, then a simple aggregation query should do the trick for you.

khanhlv
Posts: 21
Joined: Thu May 22, 2008 10:27 am

Post by khanhlv » Fri May 23, 2008 4:02 am

Thanks for your answer!

But i mean that address is memory address because i want to make the statistic about the number of reading and writing for every memory address in a period. So the size of address is 4 byte.

What is the maximum of bin? Integer.MAXIMUM or ...?
In my program when i set : bins = (maxAddress - minAddress), it makes my program out of memory :(!
Any solution?!!

Thanks and BR!

Taqua
JFreeReport Project Leader
Posts: 698
Joined: Fri Mar 14, 2003 3:34 pm
Contact:

Post by Taqua » Fri May 23, 2008 11:58 am

well, I repeat: DO NOT USE XY-Charts and do not use the out-of-the-box bining.

If you look at your data closely, you will notice that you do not access each single address between min and max. I doubt that all 2 billion internet hosts talked to your network service and therefore you are dealing with a sparsely populated distribution.

Therefore, using a "bin" for each *used* address will greatly reduce your memory consumption. However, you have to use a Categorical-Chart instead of the out-of-the-box binning provided by JFreeChart for this to work. Like all "out-of-the-box" solutions, the built- in binning assumes that your data is *NOT* sparsely populated. Out-of-the-box solutions never work for large scale data cases.

You will have to provide your own dataset *or* have to switch to a different chart type.

Just imagine how your chart looks like if each bin is one pixel wide and you have 2^32 bins. That is 2^32 pixels, which at a resolution of 72dpi gives a image with a length of 59652323.6 inch, which is about a 1,515,169.02 meters or 1,515 kilometers.

So you might have more problems than just out-of-memory here. Maybe out-of-wood exceptions if you want to print it ;)

khanhlv
Posts: 21
Joined: Thu May 22, 2008 10:27 am

Post by khanhlv » Mon May 26, 2008 2:54 am

Thanks for your answer! I will try to do!

khanhlv
Posts: 21
Joined: Thu May 22, 2008 10:27 am

Post by khanhlv » Mon May 26, 2008 7:29 am

Thanks for your suggestion. It's ok for my problem and performance when i use barchart!

Thanks very much!

Locked