public void readContinuously(final long iPosition, byte[] iBuffer, final int iSize) throws IOException { long[] pos = getRelativePosition(iPosition); // IT'S PREFERABLE TO FIND SPACE WITHOUT ENLARGE ANY FILES: FIND THE FIRST FILE WITH FREE SPACE // TO USE OFile file; int remainingSize = iSize; long offset = pos[1]; assert offset < Integer.MAX_VALUE; assert offset > -1; for (int i = (int) pos[0]; remainingSize > 0; ++i) { file = files[i]; if (remainingSize > file.getFilledUpTo() - offset) { if (file.getFilledUpTo() < offset) { throw new ODatabaseException("range check! " + file.getFilledUpTo() + " " + offset); } int toRead = file.getFilledUpTo() - (int) offset; file.read(offset, iBuffer, toRead, iSize - remainingSize); remainingSize -= toRead; } else { file.read(offset, iBuffer, remainingSize, iSize - remainingSize); remainingSize = 0; } offset = 0; } }