-
Notifications
You must be signed in to change notification settings - Fork 45
Description
I just asked this question on StackOverflow: http://stackoverflow.com/questions/22307484/is-it-possible-to-create-an-in-memory-file-object-in-java
To summarize, the main issue is that due to the nature of our optimization code, we have to call HydraulicSim.simulate
and QualitySim.simulate
many times (hundreds of thousands or even millions of calls). Because these methods rely on reading/writing files, there's a big slowdown here. I believe a good solution would be to overload QualitySim.simulate
by adding the following method:
public void simulate(DataInput in, DataOutput out) throws IOException, ENException {
...
}
Here, because HydraulicSim.simulate
already accepts a DataOutput
, I can choose that output stream to be a ByteArrayOutputStream
, for example, so that the results get stored in memory. Additionally, I could do the same with QualitySim.simulate
. This would effectively remove the need to read/write files.
HydraulicReader
already supports reading from DataInput
objects, but QualityReader.open
would need to be altered slightly (although this is trivial since QualityReader.open
just converts the File
to a DataInputStream
).
Does this all make sense? Is what I'm thinking the right thing here?