ohh this certainly defeats the purpose of dot features. with dotfeatures you should create the hash index here using some tokenizer on-the-fly and then just do result += vec2[index] ; there is way too much overhead otherwise