@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 = keys.size();
    long chunk = key >>> 8;
    if (chunk != lastChunk) {
      while (offsets.size() <= chunk) {
        offsets.appendLong(idx);
      }
      lastChunk = chunk;
    }
    keys.appendLong(key);
    values.appendLong(value);
  }
A longlong map that stores keys and values sorted by key and does a binary search to lookup values.
planetiler-core/src/main/java/com/onthegomap/planetiler/collection/SortedTableLongLongMap.java