int matrixsize = 0;
for(DBID id : distanceQuery.getRelation().iterDBIDs()) {
matrixsize = Math.max(matrixsize, id.getIntegerID() + 1);
if(id.getIntegerID() < 0) {
throw new AbortException("OnDiskMatrixCache does not allow negative DBIDs.");
}
}
OnDiskUpperTriangleMatrix matrix;
try {
matrix = new OnDiskUpperTriangleMatrix(out, DiskCacheBasedFloatDistanceFunction.FLOAT_CACHE_MAGIC, 0, FLOAT_SIZE, matrixsize);
}
catch(IOException e) {
throw new AbortException("Error creating output matrix.", e);
}
for(DBID id1 : distanceQuery.getRelation().iterDBIDs()) {
for(DBID id2 : distanceQuery.getRelation().iterDBIDs()) {
if(id2.getIntegerID() >= id1.getIntegerID()) {
float d = distanceQuery.distance(id1, id2).floatValue();
if(debugExtraCheckSymmetry) {
float d2 = distanceQuery.distance(id2, id1).floatValue();
if(Math.abs(d - d2) > 0.0000001) {
logger.warning("Distance function doesn't appear to be symmetric!");
}
}
try {
matrix.getRecordBuffer(id1.getIntegerID(), id2.getIntegerID()).putFloat(d);
}
catch(IOException e) {
throw new AbortException("Error writing distance record " + id1 + "," + id2 + " to matrix.", e);
}
}
}
}
}