finish merge and generate index and final data structure