}
// the last one caused the page to overflow.
leafCapacity = cap - 1;
}
catch(IOException e) {
throw new AbortException("Error determining page sizes.", e);
}
/* Simulate the creation of a directory page to get the capacity */
try {
int cap = 0;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
HyperBoundingBox hb = new HyperBoundingBox(new double[exampleLeaf.getDimensionality()], new double[exampleLeaf.getDimensionality()]);
SpatialDirectoryEntry sl = new SpatialDirectoryEntry(0, hb);
while(baos.size() <= getPageSize()) {
sl.writeExternal(oos);
oos.flush();
cap++;
}
dirCapacity = cap - 1;
}
catch(IOException e) {
throw new AbortException("Error determining page sizes.", e);
}
if(dirCapacity <= 1) {
throw new IllegalArgumentException("Node size of " + getPageSize() + " Bytes is chosen too small!");
}