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
This commit is contained in:
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user