Andrea - Thanks for sharing! Those look great and are nice tricks to
have on hand. What ended up being the major bottleneck?
Here is my proof-of-concept cleaned up and simplified so I could share
it. Should work in Ashley's example if you pass it an ExecutorService
(e.g. Executors.newSingleThreadExecutor)
-Ryan
On 4/28/2011 11:46 PM, Andrea Aime wrote:
On Fri, Apr 29, 2011 at 1:38 AM, Jody Garnett<[email protected]> wrote:
What a great idea; wonder if we could make a "FeatureCollection" or
FeatureIterator wrapper that maintained an internal buffer of features that
it could fill with one thread; while providing access from another?
Internally WFS has some similar code; but doing it as a wrapper would be
great :-)
I wrote prefetching wrappers around feature source and feature collection
a couple of years ago to try and speedup GeoServer. Unfortunately that failed,
most likely because I was not really hitting the major bottleneck.
I still have the implementations lying around, no idea if they even still
compile, but back at the time they were functional.
If someone wants to take care of them they are attached to this mail
Cheers
Andrea
package org.geotools.demo.example;
import java.io.InputStream;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.parsers.ParserConfigurationException;
import org.geotools.xml.Configuration;
import org.geotools.xml.StreamingParser;
import org.xml.sax.SAXException;
/**
*
* @author ryan
*/
public class PrefetchStreamingParser extends StreamingParser
{
private ExecutorService es;
private Future<Object> onDeck = null;
public PrefetchStreamingParser(Configuration configuration, InputStream
input, Class type, ExecutorService executor)
throws ParserConfigurationException,
SAXException
{
super(configuration, input, type);
es = executor;
}
private Callable<Object> getNextFeature()
{
return new Callable<Object>()
{
@Override
public Object call() throws Exception
{
return PrefetchStreamingParser.super.parse();
}
};
}
@Override
public Object parse()
{
Object retval = null;
if (null == onDeck)
{
// Get the first parse started
onDeck = es.submit(getNextFeature());
}
try
{
retval = onDeck.get();
// Start prefetching the next parse before we return.
onDeck = es.submit(getNextFeature());
}
catch (InterruptedException ex)
{
Logger.getLogger(PrefetchStreamingParser.class.getName()).log(Level.SEVERE,
null, ex);
Thread.currentThread().interrupt();
}
catch (ExecutionException ex)
{
Logger.getLogger(PrefetchStreamingParser.class.getName()).log(Level.SEVERE,
null, ex);
}
return retval;
}
}
------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network
management toolset available today. Delivers lowest initial
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users