public int encode(String string) {
    // optimization to avoid more expensive computeIfAbsent call for the majority case when concurrent hash map already
    // contains the value.
    Integer result = stringToId.get(string);
    if (result == null) {
      result = stringToId.computeIfAbsent(string, s -> {
        int id = stringId.getAndIncrement();
        if (id >= maxStrings) {
          throw new IllegalArgumentException("Too many strings");
        }
        idToString[id] = string;
        return id;
      });
    }
    return result;
  }
Returns a int value to each unique string passed in.

@param string the string to store
@return an int that can be converted back to a string by {@link #decode(int)}.
@throws IllegalArgumentException if called for too many values
planetiler-core/src/main/java/com/onthegomap/planetiler/util/CommonStringEncoder.java