public void add(SortableFeature entry) throws IOException {
      writer.write(entry);
      bytesInMemory +=
        // pointer to feature
        8 +
          // Feature class overhead
          16 +
          // long sort member of feature
          8 +
          // byte array pointer
          8 +
          // byte array size
          24 + entry.value().length;
      itemCount++;
    }
An output segment that can be sorted with a fixed amount of RAM.
planetiler-core/src/main/java/com/onthegomap/planetiler/collection/ExternalMergeSort.java