in = new ReadBinaryScoreGroupStream(path, numBoardCards, Helper.getBufferSize(MAX_SIMULT_FILES_OPEN));
} else {
throw new RuntimeException();
}
WriteBinaryClusterIDStream out = null;
if(phase == s_PhaseWriteClusteringToDisk) {
String outPath = outputDir + new Integer(i).toString() + "_" + new Integer(j).toString();
Helper.prepFilePath(outPath);
out = new WriteBinaryClusterIDStream(
outPath,
numBoardCards,
new byte[] {(byte) i, (byte) j},
Card.NUM_CLUSTERS[numBoardCards],
Helper.getBufferSize(MAX_SIMULT_FILES_OPEN));
}
HandRecord hrsm;
// if numBoardCards < 5 then in.readRecord() returns a HandRecordScoreGroups
// else, in.readRecord() returns a HandRecordScore
while((hrsm = in.readRecord()) != null) {
int[] sample;
if(numBoardCards == 5) {
sample = new int[] {((HandRecordScore)hrsm).score};
} else if(numBoardCards == 0 || numBoardCards == 3 || numBoardCards == 4) {
sample = ((HandRecordScoreGroups)hrsm).scoreGroups;
} else {
throw new RuntimeException();
}
switch(phase) {
case s_PhaseCalculateClusters:
int a= 1;
for(int k = 0; k < numClusterers; k++) {
if(!clustererDone[k]) {
clusterers[k].addSample(sample);
}
}
break;
case s_PhaseSelectClusterer:
for(int k = 0; k < numClusterers; k++) {
clusterers[k].addSample(sample);
}
break;
case s_PhaseWriteClusteringToDisk:
byte cluster_id = clusterers[minErrorCluster].getMembership(sample);
out.putClusterID(cluster_id);
break;
default:
throw new RuntimeException();
}
}
in.close();
in = null;
if(phase == s_PhaseWriteClusteringToDisk) {
out.close();
out = null;
}
System.runFinalization();
System.gc();
System.gc();