added code for build index by partition