public void read(ByteBuffer buffer) throws IOException {
    int totalBytesToBeRead = buffer.remaining();
    while (totalBytesToBeRead > 0) {
      if (dataBuffer.remaining() == 0) {
        loadNextSegment();
      }
      int currReadBytes = Math.min(dataBuffer.remaining(), totalBytesToBeRead);
      dataBuffer.get(buffer.array(), buffer.position(), currReadBytes);
      buffer.position(buffer.position() + currReadBytes);
      totalBytesToBeRead -= currReadBytes;
    }
    buffer.flip();
  }
Since current WAL file is compressed, but some part of the system need to skip the offset of an
uncompressed wal file, this method is used to skip to the given logical position.

@param pos The logical offset to skip to
@throws IOException If the file is broken or the given position is invalid
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/wal/io/WALInputStream.java