private static byte[] readBlobContent(Fileformat.Blob blob) {
    byte[] blobData;

    if (blob.hasRaw()) {
      blobData = blob.getRaw().toByteArray();
    } else if (blob.hasZlibData()) {
      Inflater inflater = new Inflater();
      inflater.setInput(blob.getZlibData().toByteArray());
      blobData = new byte[blob.getRawSize()];
      try {
        inflater.inflate(blobData);
      } catch (DataFormatException e) {
        throw new FileFormatException("Unable to decompress PBF blob.", e);
      }
      if (!inflater.finished()) {
        throw new FileFormatException("PBF blob contains incomplete compressed data.");
      }
      inflater.end();
    } else if (blob.hasLz4Data()) {
      final int decompressedLength = blob.getRawSize();
      LZ4Factory factory = LZ4Factory.fastestInstance();
      LZ4FastDecompressor decompressor = factory.fastDecompressor();
      blobData = new byte[decompressedLength];
      try {
        int compressedBytesRead =
          decompressor.decompress(blob.getLz4Data().toByteArray(), 0, blobData, 0, decompressedLength);
        int compressedBytesExpected = blob.getLz4Data().size();
        if (compressedBytesRead != compressedBytesExpected) {
          throw new FileFormatException("Unable to decompress PBF blob. read %d compressed bytes but expected %d"
            .formatted(decompressedLength, compressedBytesExpected));
        }
      } catch (LZ4Exception e) {
        throw new FileFormatException("Unable to decompress PBF blob.", e);
      }
    } else {
      throw new FileFormatException("PBF blob uses unsupported compression, only lz4, zlib, or raw may be used.");
    }

    return blobData;
  }
Converts PBF block data into decoded entities. This class was adapted from Osmosis to expose an iterator over blocks
to give more control over the parallelism.

@author Brett Henderson
planetiler-core/src/main/java/com/onthegomap/planetiler/reader/osm/PbfDecoder.java