@Override
    public void forEachBlock(Consumer<Block> consumer) {
      try (FileChannel channel = openChannel()) {
        final long size = channel.size();
        while (channel.position() < size) {
          BlobHeader header = readBlobHeader(channel);
          byte[] blockBytes = readBytes(channel, header.getDatasize());
          String headerType = header.getType();
          if ("OSMData".equals(headerType)) {
            consumer.accept(new EagerBlock(blockBytes));
          } else if ("OSMHeader".equals(headerType)) {
            validateHeader(blockBytes);
          } else {
            LOGGER.warn("Unrecognized OSM PBF blob header type: {}", headerType);
          }
        }
      } catch (IOException e) {
        throw new UncheckedIOException(e);
      }
    }
An OSM block reader that iterates through the input file in a single thread, reading the raw bytes of each block
and passing them off to worker threads.
planetiler-core/src/main/java/com/onthegomap/planetiler/reader/osm/OsmInputFile.java