[SPARK-2515][mllib] Chi Squared test

`indexOf` runs in linear time. Shall we change `features` to a feature to index map?