private static int firstNonZeroByteOffset(@NotNull ByteBuffer buffer,
                                            int startingOffset,
                                            int maxBytesToCheck) {
    for (int i = 0; i < maxBytesToCheck; i++) {
      byte b = buffer.get(startingOffset + i);
      if (b != 0) {
        return startingOffset + i;
      }
    }
    return -1;
  }
private static int firstNonZeroByteOffset(@NotNull ByteBuffer buffer,
                                            int startingOffset,
                                            int maxBytesToCheck)