> private void compareElements(ArrElem elem1, ArrElem elem2) {
> int bitM = elem1.getFp().cardinality();
[quoted text clipped - 11 lines]
> }
> }
There you have it.
The index will be 0.0 unless bitM and bitN are both 0. So you end up
creating at least a new ArrayList element in each cycle.
"Goofball" <yuriytkach@gmail.com> wrote or quoted in
Message-ID: <1162197003.272982.154550@m73g2000cwd.googlegroups.com>:
> ---------- snip -------------
>
[quoted text clipped - 11 lines]
> }
> }
It is mere guesswork.
The above code calls 'compareElements' (10000 * 10000) times.
Namely, 100 M times.
> private void compareElements(ArrElem elem1, ArrElem elem2) {
> int bitM = elem1.getFp().cardinality();
[quoted text clipped - 5 lines]
>
> double index = bitCommon/(bitM+bitN+bitCommon);
Min of 'index' is 0.
Max of 'index' is smaller than 1.
> if (index < 0.8) {
If 'cardinality()' is random,
the probability of calling the bellow code will be about 8/10.
That is, 80 M times (10000 * 10000 * 0.8)
> if (! rez.containsKey(elem1))
> rez.put(elem1, new ArrayList<ArrElem>());
> rez.get(elem1).add(elem2);
> }
> }
> }
The above code adds an element to 'rez' whenever she is executed.
A total of 80 M elements.
320 MBytes memory (80M * 4) will be required at least.
Ingo Menger - 30 Oct 2006 12:55 GMT
> > double index = bitCommon/(bitM+bitN+bitCommon);
> >
> Min of 'index' is 0.
> Max of 'index' is smaller than 1.
Yes, it's 0!
Proof:
case 1) bitM and bitM are 0. Then so will bitComnmon. This will result
in zero divide. (BTW, this is a programming error)
case 2) bitM or bitM are > 0. Then the integer division will result in
0.
Thus, index will never be anything else than 0.0. And the programm will
crash occasionally.
> > if (index < 0.8) {
Thus, this is always true.
> If 'cardinality()' is random,
> the probability of calling the bellow code will be about 8/10.
1, to be exact.
> The above code adds an element to 'rez' whenever she is executed.
> A total of 80 M elements.
It adds an element everytime. A total of 100M elements.
Goofball - 08 Nov 2006 17:07 GMT
Thanks a lot. That helped. I redesigned the alsorithm. Now it works
fine. But when I test it on about 1 million of elements - it crashes.
Starting JVM with more memory helps, but that sometimes cannot be done
(because of the requirements). So, I decided to write my own
implementations of List and Map interfaces, that will flush the results
on disk. My requirements allow that. :)
Thanks again.
> > > double index = bitCommon/(bitM+bitN+bitCommon);
> > >
[quoted text clipped - 24 lines]
>
> It adds an element everytime. A total of 100M elements.