simplify build_index_cpp interface. get back at the same intf as build_index
added train_push_back to avoid code duplication