cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Øyvind Harboe" <oyvind.har...@zylin.com>
Subject weakly referenced paged queries
Date Fri, 20 Jun 2008 13:46:06 GMT
I'm toying around with weak references in paged queries.

This turned out to be rather hairy from the point of view that
a query is supposed to return a List and this List has
to live up to a lot of expectations from the calling code +
promises of the List interfaces.



Consider two of the subList implementations in IncrementalFaultList:

a)

    public List<E> subList(int fromIndex, int toIndex) {
        synchronized (elements) {
            resolveInterval(fromIndex, toIndex);
            return elements.subList(fromIndex, toIndex);
        }
    }

b)

    public List<E> subList(int fromIndex, int toIndex) {
    	List<E> l=new LinkedList<E>();
    	for (int i=fromIndex; i<toIndex; i++)
    	{
    		l.add(get(i));
    	}
    	return l;
    }


1. JavaDoc states that list.subList(from, to).clear() will clear that
range.  Here b) is broken.

2. I was greatly surprised to see synchronized() for the list returned
from the query. Is the synchronisation for the benefit of the
calling code or the implementation?


Attached is the work in progress. First and foremost I'm after measuring
the performance of such an implementation. So far it doesn't look very
promising. It does use less memory but it is dog slow. Will tinker with it more.


-- 
Øyvind Harboe
http://www.zylin.com/zy1000.html
ARM7 ARM9 XScale Cortex
JTAG debugger and flash programmer

Mime
  • Unnamed multipart/mixed (inline, None, 0 bytes)
View raw message