move partitioning into a separate method with config, and add caching for name based comparator