<div dir="ltr"><div>The problem with files > 2GB in jevio is nasty. Java can "inherently" handle files greater than 2GB if they are read traditionally. It is the memory mapping that causes the problem. In jevio there is, for example, the call:</div>
<div><br></div><div><p>mappedByteBuffer = inputChannel.map(FileChannel.MapMode.READ_ONLY, 0L, sz);</p>
</div><div><br></div><div>This is creating the buffer, in memory, of a region of a file. The 0L argument is the offset (i.e., in this case the map begins at the beginning of the file) and the second argument is the length, which in jevio is essentially the size of the file.</div>
<div><br></div><div>The java documentation gives the weird bad news. The third argument (sz, in this case) is a long, but it is restricted to INTEGER.MAXINT (which is 2 GB). That's right: it is a long (64 bit) value that will throw an exception if it is bigger than the max for a 32 bit int.</div>
<div><br></div><div>To summarize: jevio assumes it can map the entire file to memory--but this will fail even if you have a 64 bit machine and sufficient (i.e. more than 2GB) of memory.</div><div><br></div><div>There is a request for a change at Oracle, but it doesn't seen to be high priority. They say the only workaround is to work your way through big files:</div>
<div><br></div><div>offset = 0L</div><div>while (!done) {</div><div> long sz = Math.min(remainingSize, INTEGER.MAXINT);</div><div> mappedByteBuffer = inputChannel.map(FileChannel.MapMode.READ_ONLY, offset, sz);<br>
</div><div> {do stuff}</div><div> offset += sz;</div><div> mappedByteBuffer = inputChannel.map(FileChannel.MapMode.READ_ONLY, 0L, sz);<br>
</div><div>}</div><div><br></div><div>I suspect that this would be a very nontrivial change to jevio withs lots of debugging. But I think we need to request it.</div><div><br></div><div>Note that we basically have to use memory mapped io--it is about 10x faster than traditional disk access IO.<br clear="all">
<div><br></div>-- <br><div dir="ltr">David P. Heddle, Ph.D.<br>
Associate Professor of Physics<br>
Christopher Newport University<br>
Newport News, VA 23606<div><br></div><div>757.594.8434 (CNU)</div><div>757.269.5719 (Jefferson Lab)</div></div>
</div></div>