finish the partition and merge API for reducer