Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Virtual Table Sorting is going into an infinite loop
Virtual Table Sorting is going into an infinite loop [message #454295] Tue, 19 April 2005 19:47 Go to next message
Chad is currently offline ChadFriend
Messages: 7
Registered: July 2009
Junior Member
Hello

First of all I got to say nice job on the Virtual table support. It has
dramatically improved the performance of our tables!

I am having a little problem though when I try to sort a large number of
records. In my particular test case I am trying to sort 28,000 records by a
date field. The CPU hovers around 50% until I finally get an exception
thrown in LazySortedCollection. I never actually see the full stack trace, I
only see the following line repeated numerous times (It looks like some kind
of recursive stack overflow or out of memory problem).
at
org.eclipse.jface.viewers.deferred.LazySortedCollection.getC hildren(LazySortedCollection.java:1450)

I added some debug into my comparator and I can see that it is performing
over 10 million comparison before it dies. It starts off fine, the first 3
million comparisions seems to be comparing different pieces of data but
after that it seems to get stuck onthe same date. Here is a sample of the
debug output.
Make the 9993000 comparison. Comapring 2001-04-05 00:00:00.0 to 2001-04-05
00:00:00.0

I am using a simple contentProvide that basically just extends from
DefferedContentProvider and my IConcurrentModel extends from
AbstarctConcurrentModel and was modeled after SetModel. Also, this works
when I compare a different set of data that happens to be unique integers. I
even converted the integers into string just to see if that had something to
do with it but it still worked. Maybe this has something to do with the fact
that the data has allot of duplicate entries (for example 2001-04-15 appears
around 4000 times in the set of 28,000 records). Here is the compare code in
my comparator:



public int compare(Object o1, Object o2) {
Object val1 = getField(o1);
Object val2 = getField(o2);

num++;
if ((num % 1000) == 0){
System.out.println("Make the " + num + " comparison. Comapring " + val1 +
" to " + val2 );
}

if (val1 == null && val2 == null){
return 0;
}
else if (val1 == null){
return -1;
}
else if (val2 == null){
return 1;
}

Assert.isTrue(val1 instanceof Comparable,"Item is not an instance of
Comparable ( " + val1.getClass() + ")");
Assert.isTrue(val2 instanceof Comparable,"Item is not an instance of
Comparable ( " + val2.getClass() + ")");

Comparable lhs;
Comparable rhs;

if (val1 instanceof String){
lhs = ((String) val1).toUpperCase();
}
else{
lhs = (Comparable) val1;
}

if (val2 instanceof String){
rhs = ((String) val2).toUpperCase();
}
else{
rhs = (Comparable) val2;
}

int answer;
if (ascending){
answer = lhs.compareTo(rhs);
}
else{
answer = rhs.compareTo(lhs);
}

if ((num % 1000) == 0){
System.out.println("Answer = " + answer);
}
return answer;
}

Thanks

Chad
Re: Virtual Table Sorting is going into an infinite loop [message #454335 is a reply to message #454295] Wed, 20 April 2005 16:41 Go to previous message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
I think you'll have to ansk this question on eclipse.platform.
LazySortedCollection is not an SWT class (although it is possible that the
problem is somewhere in SWT).

"Chad" <cgustafson@chessys.com> wrote in message
news:d43nqp$1im$1@news.eclipse.org...
>
>
> Hello
>
> First of all I got to say nice job on the Virtual table support. It has
> dramatically improved the performance of our tables!
>
> I am having a little problem though when I try to sort a large number of
> records. In my particular test case I am trying to sort 28,000 records by
a
> date field. The CPU hovers around 50% until I finally get an exception
> thrown in LazySortedCollection. I never actually see the full stack trace,
I
> only see the following line repeated numerous times (It looks like some
kind
> of recursive stack overflow or out of memory problem).
> at
>
org.eclipse.jface.viewers.deferred.LazySortedCollection.getC hildren(LazySort
edCollection.java:1450)
>
> I added some debug into my comparator and I can see that it is performing
> over 10 million comparison before it dies. It starts off fine, the first 3
> million comparisions seems to be comparing different pieces of data but
> after that it seems to get stuck onthe same date. Here is a sample of the
> debug output.
> Make the 9993000 comparison. Comapring 2001-04-05 00:00:00.0 to 2001-04-05
> 00:00:00.0
>
> I am using a simple contentProvide that basically just extends from
> DefferedContentProvider and my IConcurrentModel extends from
> AbstarctConcurrentModel and was modeled after SetModel. Also, this works
> when I compare a different set of data that happens to be unique integers.
I
> even converted the integers into string just to see if that had something
to
> do with it but it still worked. Maybe this has something to do with the
fact
> that the data has allot of duplicate entries (for example 2001-04-15
appears
> around 4000 times in the set of 28,000 records). Here is the compare code
in
> my comparator:
>
>
>
> public int compare(Object o1, Object o2) {
> Object val1 = getField(o1);
> Object val2 = getField(o2);
>
> num++;
> if ((num % 1000) == 0){
> System.out.println("Make the " + num + " comparison. Comapring " + val1
+
> " to " + val2 );
> }
>
> if (val1 == null && val2 == null){
> return 0;
> }
> else if (val1 == null){
> return -1;
> }
> else if (val2 == null){
> return 1;
> }
>
> Assert.isTrue(val1 instanceof Comparable,"Item is not an instance of
> Comparable ( " + val1.getClass() + ")");
> Assert.isTrue(val2 instanceof Comparable,"Item is not an instance of
> Comparable ( " + val2.getClass() + ")");
>
> Comparable lhs;
> Comparable rhs;
>
> if (val1 instanceof String){
> lhs = ((String) val1).toUpperCase();
> }
> else{
> lhs = (Comparable) val1;
> }
>
> if (val2 instanceof String){
> rhs = ((String) val2).toUpperCase();
> }
> else{
> rhs = (Comparable) val2;
> }
>
> int answer;
> if (ascending){
> answer = lhs.compareTo(rhs);
> }
> else{
> answer = rhs.compareTo(lhs);
> }
>
> if ((num % 1000) == 0){
> System.out.println("Answer = " + answer);
> }
> return answer;
> }
>
> Thanks
>
> Chad
>
>
Previous Topic:StyledText resets caret position, scrolls back up
Next Topic:HTML Editor
Goto Forum:
  


Current Time: Wed Sep 25 21:15:44 GMT 2024

Powered by FUDForum. Page generated in 0.04000 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top