private void initWindow(final long byteStart, final long byteEnd) throws IOException {
        totalSegmentCount = (((SeekableInputStream) indexInputStream).getSize() / INT8) + 1;

        // If the window starts at 0 we start at segment 0 otherwise we need to
        // look at which segment includes byteStart
        long windowSegmentStart = 0;
        if (byteStart > 0) {
            windowSegmentStart = segmentAtByteOffset(byteStart, true);
        }
        // If the windows ends before the size of the file we end at
        // totalSegmentCount - 1,
        // otherwise find the segment including byteEnd
        long windowSegmentEnd = totalSegmentCount - 1;
        if (byteEnd < getDataSize()) {
            windowSegmentEnd = segmentAtByteOffset(byteEnd, false);
        }

        windowSegmentCount = windowSegmentEnd - windowSegmentStart + 1;

        this.windowSegmentStart = windowSegmentStart;

        windowByteStart = byteStart;
        windowByteEnd = byteEnd;

        if (windowByteStart > 0) {
            data.skip(windowByteStart);
        }

        windowPos = windowByteStart;

        // Make sure we are at the start of the window.
        doSeek(windowPos);
    }
This is an implementation of <code>SegmentInputStream</code> that uses random
access files for the data and index.
<p>
Also new handles working within a windows on the underlying data. With this
mode the segments are logical (i.e. they start at 0 regardless of the
window).
stroom-data/stroom-data-store-impl-fs/src/main/java/stroom/data/store/impl/fs/RASegmentInputStream.java