Removes deprecated usage of the FieldStats API in a test that verifies
sequence number data in Lucene commit points. Instead, the test retrieves the _seq_no value from the commit point directly and converts it to a Long value.
This commit is contained in:
parent
41d0ff32c8
commit
dda68643b6
|
@ -48,6 +48,7 @@ import org.apache.lucene.index.LogDocMergePolicy;
|
||||||
import org.apache.lucene.index.MergePolicy;
|
import org.apache.lucene.index.MergePolicy;
|
||||||
import org.apache.lucene.index.NoMergePolicy;
|
import org.apache.lucene.index.NoMergePolicy;
|
||||||
import org.apache.lucene.index.NumericDocValues;
|
import org.apache.lucene.index.NumericDocValues;
|
||||||
|
import org.apache.lucene.index.PointValues;
|
||||||
import org.apache.lucene.index.Term;
|
import org.apache.lucene.index.Term;
|
||||||
import org.apache.lucene.index.TieredMergePolicy;
|
import org.apache.lucene.index.TieredMergePolicy;
|
||||||
import org.apache.lucene.search.IndexSearcher;
|
import org.apache.lucene.search.IndexSearcher;
|
||||||
|
@ -68,7 +69,6 @@ import org.apache.lucene.util.IOUtils;
|
||||||
import org.apache.lucene.util.TestUtil;
|
import org.apache.lucene.util.TestUtil;
|
||||||
import org.elasticsearch.ElasticsearchException;
|
import org.elasticsearch.ElasticsearchException;
|
||||||
import org.elasticsearch.Version;
|
import org.elasticsearch.Version;
|
||||||
import org.elasticsearch.action.fieldstats.FieldStats;
|
|
||||||
import org.elasticsearch.action.index.IndexRequest;
|
import org.elasticsearch.action.index.IndexRequest;
|
||||||
import org.elasticsearch.action.support.TransportActions;
|
import org.elasticsearch.action.support.TransportActions;
|
||||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||||
|
@ -2198,10 +2198,10 @@ public class InternalEngineTests extends ESTestCase {
|
||||||
assertThat(localCheckpoint, greaterThanOrEqualTo(prevLocalCheckpoint));
|
assertThat(localCheckpoint, greaterThanOrEqualTo(prevLocalCheckpoint));
|
||||||
assertThat(maxSeqNo, greaterThanOrEqualTo(prevMaxSeqNo));
|
assertThat(maxSeqNo, greaterThanOrEqualTo(prevMaxSeqNo));
|
||||||
try (IndexReader reader = DirectoryReader.open(commit)) {
|
try (IndexReader reader = DirectoryReader.open(commit)) {
|
||||||
FieldStats stats = SeqNoFieldMapper.SeqNoDefaults.FIELD_TYPE.stats(reader);
|
Long highest = getHighestSeqNo(reader);
|
||||||
final long highestSeqNo;
|
final long highestSeqNo;
|
||||||
if (stats != null) {
|
if (highest != null) {
|
||||||
highestSeqNo = (long) stats.getMaxValue();
|
highestSeqNo = highest.longValue();
|
||||||
} else {
|
} else {
|
||||||
highestSeqNo = SequenceNumbersService.NO_OPS_PERFORMED;
|
highestSeqNo = SequenceNumbersService.NO_OPS_PERFORMED;
|
||||||
}
|
}
|
||||||
|
@ -2223,6 +2223,16 @@ public class InternalEngineTests extends ESTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Long getHighestSeqNo(final IndexReader reader) throws IOException {
|
||||||
|
final String fieldName = SeqNoFieldMapper.NAME;
|
||||||
|
long size = PointValues.size(reader, fieldName);
|
||||||
|
if (size == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
byte[] max = PointValues.getMaxPackedValue(reader, fieldName);
|
||||||
|
return LongPoint.decodeDimension(max, 0);
|
||||||
|
}
|
||||||
|
|
||||||
private static FixedBitSet getSeqNosSet(final IndexReader reader, final long highestSeqNo) throws IOException {
|
private static FixedBitSet getSeqNosSet(final IndexReader reader, final long highestSeqNo) throws IOException {
|
||||||
// _seq_no are stored as doc values for the time being, so this is how we get them
|
// _seq_no are stored as doc values for the time being, so this is how we get them
|
||||||
// (as opposed to using an IndexSearcher or IndexReader)
|
// (as opposed to using an IndexSearcher or IndexReader)
|
||||||
|
|
Loading…
Reference in New Issue