Hi,
I have a question concerning performance.
I need to select multilinestrings from a shape file (only the ones inside
given polygons), and calculate their lengths. The problem is that the
number of the polygons is big. So I decided to do it with multiple threads
(since I have many cores on the machine).
I did it as follows
ShapefileDataStore dataStore = new ShapefileDataStore(shapeUrl);
SimpleFeatureSource featureSource = dataStore.getFeatureSource();
FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);
ExecutorService service = Executors.newFixedThreadPool(processors);
DrainageDensityCalculatorThread densityCalculatorThread;
for(i = 0; i < nx; i++){
for(j = 0; j < ny; j++){
theCell = cells[i][j];
//select rivers intersecting the gridcell
densityCalculatorThread = new
DrainageDensityCalculatorThread(theCell, featureSource);
service.execute(densityCalculatorThread);
}
System.out.println("i/nx = " + i +"/"+nx);
}
service.shutdown();
try {
service.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
} catch (InterruptedException ex) {
Logger.getLogger(this.getClass().getName()).log(Level.SEVERE,
null, ex);
}
Inside the thread I apply the filter to the featureSource, and then using
a featurevisitor I visit the selected featurecollection and calculate its
total length.
It takes long even with 20 threads, is it possible to improve the
performance? It is not a problem to wait since the operation is not
performed that often, though it would be nice to make it faster.
Thanks.
--
Oleksandr (Sasha) Huziy
------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users