Fixed sliced search tests that rely on BytesRef.hashCode output

This commit is contained in:
Jim Ferenczi 2017-03-30 10:14:41 +02:00
parent a49e1c0062
commit 3b559e01be
2 changed files with 4 additions and 2 deletions

View File

@ -48,7 +48,7 @@ import java.io.IOException;
*/
public final class TermsSliceQuery extends SliceQuery {
// Fixed seed for computing term hashCode
private static final int SEED = 7919;
public static final int SEED = 7919;
public TermsSliceQuery(String field, int id, int max) {
super(field, id, max);

View File

@ -34,6 +34,7 @@ import org.apache.lucene.search.QueryUtils;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.StringHelper;
import org.elasticsearch.common.UUIDs;
import org.elasticsearch.test.ESTestCase;
@ -72,7 +73,8 @@ public class TermsSliceQueryTests extends ESTestCase {
Document doc = new Document();
String uuid = UUIDs.base64UUID();
BytesRef br = new BytesRef(uuid);
int id = Math.floorMod(br.hashCode(), max);
int hashCode = StringHelper.murmurhash3_x86_32(br, TermsSliceQuery.SEED);
int id = Math.floorMod(hashCode, max);
sliceCounters[id] ++;
doc.add(new StringField("uuid", uuid, Field.Store.YES));
w.addDocument(doc);