private RawResult getSegmentedData(final SourceLocation sourceLocation,
                                       final SegmentInputStream segmentInputStream,
                                       final String encoding,
                                       final DisplayMode displayMode,
                                       final boolean limitChars) throws IOException {
//        // Get the appropriate encoding for the stream type.
//        final String encoding = feedProperties.getEncoding(feedName, streamTypeName);

        // Set the page total.
        if (segmentInputStream.count() > 2) {
            // Subtract 2 to account for the XML root elements (header and footer).
            pageTotal = segmentInputStream.count() - 2;
        } else {
            pageTotal = segmentInputStream.count();
        }
//        pageTotalIsExact = true;

        // Make sure we can't exceed the page total.
        recordIndex = sourceLocation.getRecordIndex();
        if (recordIndex >= pageTotal) {
            recordIndex = pageTotal - 1;
        }

        // Include start root element.
        segmentInputStream.include(0);

        // Include the requested segment, add one to allow for start root elm
        segmentInputStream.include(recordIndex + 1);

        // Include end root element.
        segmentInputStream.include(segmentInputStream.count() - 1);

        // Get the data from the stream.
//        return StreamUtil.streamToString(segmentInputStream, Charset.forName(encoding));
        final RawResult rawResult = switch (displayMode) {
            case TEXT -> extractDataRange(
                    sourceLocation,
                    segmentInputStream,
                    encoding,
                    segmentInputStream.size(),
                    limitChars);
            case HEX -> extractDataRangeAsHex(
                    sourceLocation,
                    segmentInputStream,
                    encoding,
                    segmentInputStream.size(),
                    DataType.SEGMENTED);
            default -> throw new IllegalArgumentException("Unexpected display mode " + displayMode);
        };

        // Override the page items range/total as we are dealing in segments/records
        rawResult.setItemRange(new OffsetRange(recordIndex, 1L));
        rawResult.setTotalItemCount(Count.of(segmentInputStream.count() - 2, true));
        return rawResult;
    }
How big our buffers are. This should always be a multiple of 8.
stroom-data/stroom-data-store-impl/src/main/java/stroom/data/store/impl/DataFetcher.java