@Override
  public void put(long key, long value) {
    if (key <= lastKey) {
      throw new IllegalArgumentException("Nodes must be sorted ascending by ID, " + key + " came after " + lastKey);
    }
    lastKey = key;
    long idx = values.size();
    int chunk = (int) (key >>> 8);
    int offset = (int) (key & 255);

    if (chunk != lastChunk) {
      // new chunk, store offset and leading zeros
      lastOffset = offset;
      while (offsets.size() <= chunk) {
        offsets.appendLong(idx);
        offsetStartPad.add((byte) offset);
      }
      lastChunk = chunk;
    } else {
      // same chunk, write not_founds until we get to right idx
      while (++lastOffset < offset) {
        values.appendLong(MISSING_VALUE);
      }
    }
    values.appendLong(value);
  }
A longlong map that only stores values and uses the key as an index into the array, with some tweaks to avoid storing
many sequential 0's.
planetiler-core/src/main/java/com/onthegomap/planetiler/collection/SparseArrayLongLongMap.java