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:
Ali Beyad 2017-07-06 12:00:00 -04:00
parent 41d0ff32c8
commit dda68643b6
1 changed files with 14 additions and 4 deletions

View File

@ -48,6 +48,7 @@ import org.apache.lucene.index.LogDocMergePolicy;
import org.apache.lucene.index.MergePolicy;
import org.apache.lucene.index.NoMergePolicy;
import org.apache.lucene.index.NumericDocValues;
import org.apache.lucene.index.PointValues;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.TieredMergePolicy;
import org.apache.lucene.search.IndexSearcher;
@ -68,7 +69,6 @@ import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.TestUtil;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.Version;
import org.elasticsearch.action.fieldstats.FieldStats;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.support.TransportActions;
import org.elasticsearch.cluster.metadata.IndexMetaData;
@ -2198,10 +2198,10 @@ public class InternalEngineTests extends ESTestCase {
assertThat(localCheckpoint, greaterThanOrEqualTo(prevLocalCheckpoint));
assertThat(maxSeqNo, greaterThanOrEqualTo(prevMaxSeqNo));
try (IndexReader reader = DirectoryReader.open(commit)) {
FieldStats stats = SeqNoFieldMapper.SeqNoDefaults.FIELD_TYPE.stats(reader);
Long highest = getHighestSeqNo(reader);
final long highestSeqNo;
if (stats != null) {
highestSeqNo = (long) stats.getMaxValue();
if (highest != null) {
highestSeqNo = highest.longValue();
} else {
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 {
// _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)