|
| 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 | +} |
0 commit comments