Skip to content

Commit e3aba40

Browse files
Add test
1 parent 98bfbdf commit e3aba40

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
package org.elasticsearch.search.sort;
11+
12+
import org.apache.lucene.index.LeafReaderContext;
13+
import org.elasticsearch.search.DocValueFormat;
14+
15+
public class BucketedSortForIntsTests extends BucketedSortTestCase<BucketedSort.ForInts> {
16+
@Override
17+
public BucketedSort.ForInts build(
18+
SortOrder sortOrder,
19+
DocValueFormat format,
20+
int bucketSize,
21+
BucketedSort.ExtraData extra,
22+
double[] values
23+
) {
24+
return new BucketedSort.ForInts(bigArrays(), sortOrder, format, bucketSize, extra) {
25+
@Override
26+
public Leaf forLeaf(LeafReaderContext ctx) {
27+
return new Leaf(ctx) {
28+
int index = -1;
29+
30+
@Override
31+
protected boolean advanceExact(int doc) {
32+
index = doc;
33+
return doc < values.length;
34+
}
35+
36+
@Override
37+
protected int docValue() {
38+
return (int) values[index];
39+
}
40+
};
41+
}
42+
};
43+
}
44+
45+
@Override
46+
protected SortValue expectedSortValue(double v) {
47+
return SortValue.from((int) v);
48+
}
49+
50+
@Override
51+
protected double randomValue() {
52+
return randomInt();
53+
}
54+
}

server/src/test/java/org/elasticsearch/search/sort/BucketedSortForLongsTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ protected SortValue expectedSortValue(double v) {
5050
@Override
5151
protected double randomValue() {
5252
// 2L^50 fits in the mantisa of a double which the test sort of needs.
53-
return randomLongBetween(-2L ^ 50, 2L ^ 50);
53+
return randomLongBetween(-(1L << 50), (1L << 50));
5454
}
5555
}

0 commit comments

Comments
 (0)