public ByteBuffer encode() {
        int size = 1 /* magic code */ + snapshots.size() * (8 /* offset */ + 4 /* length */);
        for (ByteBuffer snapshot : snapshots.values()) {
            if (snapshot != null) {
                size += snapshot.remaining();
            }
        }
        ByteBuf buf = Unpooled.buffer(size);
        buf.writeByte(MAGIC_CODE);
        snapshots.forEach((offset, snapshot) -> {
            buf.writeLong(offset);
            buf.writeInt(snapshot.remaining());
            buf.writeBytes(snapshot.duplicate());
        });
        return buf.nioBuffer();
    }
refers to all valid snapshot files
core/src/main/scala/kafka/log/streamaspect/ElasticPartitionProducerSnapshotsMeta.java