@Override
  public Queue<ICachedMNode> getAllRecords() throws MetadataException {
    Queue<ICachedMNode> res = new ArrayDeque<>(recordNum);
    ByteBuffer roBuffer = this.buffer.asReadOnlyBuffer();

    short[] offsets = new short[recordNum];
    roBuffer.position(SchemaFileConfig.SEG_HEADER_SIZE);
    roBuffer.asShortBuffer().get(offsets);

    roBuffer.clear();

    short len;
    String key;
    for (short offset : offsets) {
      roBuffer.clear();
      roBuffer.position(offset);
      key = ReadWriteIOUtils.readString(roBuffer);
      len = RecordUtils.getRecordLength(roBuffer);
      roBuffer.limit(roBuffer.position() + len);
      res.add(RecordUtils.buffer2Node(key, roBuffer));
    }
    return res;
  }
<b>Segment Structure:</b>
<li>(25 byte: header)
<li>1 short: length, segment length
<li>1 short: freeAddr, start offset of records
<li>1 short: recordNum, amount of records in this segment
<li>1 short: pairLength, length of key-address in bytes
<li>1 long (8 bytes): prevSegIndex, previous segment index
<li>1 long (8 bytes): nextSegIndex, next segment index
<li>1 bit: delFlag, delete flag
<li>1 bit: aliasFlag, whether alias existed<br>
    (--- checksum, parent record address, max/min record key may be contained further ---)
<li><s>var length: key-address pairs, begin at 25 bytes offset, length of pairLength </s><br>
<li>var length: ORDERED record offset<br>
    ... empty space ...
<li>var length: (record key, record body) * recordNum
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/schemafile/WrappedSegment.java