From fda99ada25864d51ec254ffaa05dad3764f093a0 Mon Sep 17 00:00:00 2001 From: Tom Copeland Date: Wed, 11 Sep 2002 19:20:02 +0000 Subject: [PATCH] added some more abstraction on the batch building process git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@916 51baf565-9d33-0410-a72c-fc3788e3496d --- .../src/net/sourceforge/pmd/dcpd/BatchBuilder.java | 14 +++++++------- pmd-dcpd/src/net/sourceforge/pmd/dcpd/DGST.java | 8 +++++--- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/pmd-dcpd/src/net/sourceforge/pmd/dcpd/BatchBuilder.java b/pmd-dcpd/src/net/sourceforge/pmd/dcpd/BatchBuilder.java index 965b9ded36..2b4ffafcb9 100644 --- a/pmd-dcpd/src/net/sourceforge/pmd/dcpd/BatchBuilder.java +++ b/pmd-dcpd/src/net/sourceforge/pmd/dcpd/BatchBuilder.java @@ -24,17 +24,17 @@ public class BatchBuilder { public List buildBatches() { List batches = new ArrayList(); - int tilesSoFar=0; + int batchesSoFar=0; for (Iterator i = occ.getTiles(); i.hasNext();) { Tile tile = (Tile)i.next(); - TileWrapper tw = new TileWrapper(tile, occ.getOccurrencesList(tile), null, null); + TileWrapper tileWrapper = new TileWrapper(tile, occ.getOccurrencesList(tile), null, null); List wrappers = new ArrayList(); - wrappers.add(tw); - Batch batch = new Batch(job.id, wrappers, Batch.NOT_DONE, new Integer(tilesSoFar)); + wrappers.add(tileWrapper); + Batch batch = new Batch(job.id, wrappers, Batch.NOT_DONE, new Integer(batchesSoFar)); batches.add(batch); - tilesSoFar++; - if (tilesSoFar % 100 == 0) { - System.out.println("Planted " + tilesSoFar + " batches so far"); + batchesSoFar++; + if (batchesSoFar % 100 == 0) { + System.out.println("Planted " + batchesSoFar + " batches so far"); } } diff --git a/pmd-dcpd/src/net/sourceforge/pmd/dcpd/DGST.java b/pmd-dcpd/src/net/sourceforge/pmd/dcpd/DGST.java index 0425fa92dc..48b8701aa2 100644 --- a/pmd-dcpd/src/net/sourceforge/pmd/dcpd/DGST.java +++ b/pmd-dcpd/src/net/sourceforge/pmd/dcpd/DGST.java @@ -37,7 +37,7 @@ public class DGST { TilePlanter planter = new TilePlanter(space, job); planter.plant(batches); space.write(job, null, Lease.FOREVER); - expand(occ); + expand(occ, batches.size()); System.out.println("Done"); } catch (Exception e) { e.printStackTrace(); @@ -45,10 +45,11 @@ public class DGST { return results; } - private void expand(Occurrences occ) throws RemoteException, UnusableEntryException, TransactionException, InterruptedException { + private void expand(Occurrences occ, int initialNumberOfBatches) throws RemoteException, UnusableEntryException, TransactionException, InterruptedException { + int batchCount = initialNumberOfBatches; while (!occ.isEmpty()) { TileHarvester tg = new TileHarvester(space, job); - occ = tg.harvest(occ.size()); + occ = tg.harvest(batchCount); addToResults(occ); if (!occ.isEmpty()) { System.out.println("**Season complete" + System.getProperty("line.separator") + "->Tile count: " + occ.size() + System.getProperty("line.separator") + "->Tile size: " + ((Tile)(occ.getTiles().next())).getTokenCount()); @@ -57,6 +58,7 @@ public class DGST { List batches = builder.buildBatches(); TilePlanter planter = new TilePlanter(space, job); planter.plant(batches); + batchCount = batches.size(); } }