logstash-core/src/main/java/org/logstash/ackedqueue/io/MmapPageIOV1.java [101:138]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    @Override
    public SequencedList<byte[]> read(long seqNum, int limit) throws IOException {
        assert seqNum >= this.minSeqNum :
            String.format("seqNum=%d < minSeqNum=%d", seqNum, this.minSeqNum);
        assert seqNum <= maxSeqNum() :
            String.format("seqNum=%d is > maxSeqNum=%d", seqNum, maxSeqNum());

        List<byte[]> elements = new ArrayList<>();
        final LongVector seqNums = new LongVector(limit);

        int offset = this.offsetMap.get((int) (seqNum - this.minSeqNum));

        buffer.position(offset);

        for (int i = 0; i < limit; i++) {
            long readSeqNum = buffer.getLong();

            assert readSeqNum == (seqNum + i) :
                String.format("unmatched seqNum=%d to readSeqNum=%d", seqNum + i, readSeqNum);

            int readLength = buffer.getInt();
            byte[] readBytes = new byte[readLength];
            buffer.get(readBytes);
            int checksum = buffer.getInt();
            int computedChecksum = checksum(readBytes);
            if (computedChecksum != checksum) {
                throw new IOException(String.format("computed checksum=%d != checksum for file=%d", computedChecksum, checksum));
            }

            elements.add(readBytes);
            seqNums.add(readSeqNum);

            if (seqNum + i >= maxSeqNum()) {
                break;
            }
        }

        return new SequencedList<>(elements, seqNums);
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



logstash-core/src/main/java/org/logstash/ackedqueue/io/MmapPageIOV2.java [111:148]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    @Override
    public SequencedList<byte[]> read(long seqNum, int limit) throws IOException {
        assert seqNum >= this.minSeqNum :
            String.format("seqNum=%d < minSeqNum=%d", seqNum, this.minSeqNum);
        assert seqNum <= maxSeqNum() :
            String.format("seqNum=%d is > maxSeqNum=%d", seqNum, maxSeqNum());

        List<byte[]> elements = new ArrayList<>();
        final LongVector seqNums = new LongVector(limit);

        int offset = this.offsetMap.get((int) (seqNum - this.minSeqNum));

        buffer.position(offset);

        for (int i = 0; i < limit; i++) {
            long readSeqNum = buffer.getLong();

            assert readSeqNum == (seqNum + i) :
                String.format("unmatched seqNum=%d to readSeqNum=%d", seqNum + i, readSeqNum);

            int readLength = buffer.getInt();
            byte[] readBytes = new byte[readLength];
            buffer.get(readBytes);
            int checksum = buffer.getInt();
            int computedChecksum = checksum(readBytes);
            if (computedChecksum != checksum) {
                throw new IOException(String.format("computed checksum=%d != checksum for file=%d", computedChecksum, checksum));
            }

            elements.add(readBytes);
            seqNums.add(readSeqNum);

            if (seqNum + i >= maxSeqNum()) {
                break;
            }
        }

        return new SequencedList<>(elements, seqNums);
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



