|
10 | 10 | package org.elasticsearch.common.lucene.uid; |
11 | 11 |
|
12 | 12 | import org.apache.lucene.document.LongPoint; |
| 13 | +import org.apache.lucene.index.DocValuesSkipIndexType; |
| 14 | +import org.apache.lucene.index.DocValuesSkipper; |
| 15 | +import org.apache.lucene.index.FieldInfo; |
13 | 16 | import org.apache.lucene.index.LeafReader; |
14 | 17 | import org.apache.lucene.index.LeafReaderContext; |
15 | 18 | import org.apache.lucene.index.NumericDocValues; |
@@ -94,11 +97,19 @@ final class PerThreadIDVersionAndSeqNoLookup { |
94 | 97 | this.loadedTimestampRange = loadTimestampRange; |
95 | 98 | // Also check for the existence of the timestamp field, because sometimes a segment can only contain tombstone documents, |
96 | 99 | // which don't have any mapped fields (also not the timestamp field) and just some meta fields like _id, _seq_no etc. |
97 | | - if (loadTimestampRange && reader.getFieldInfos().fieldInfo(DataStream.TIMESTAMP_FIELD_NAME) != null) { |
98 | | - PointValues tsPointValues = reader.getPointValues(DataStream.TIMESTAMP_FIELD_NAME); |
99 | | - assert tsPointValues != null : "no timestamp field for reader:" + reader + " and parent:" + reader.getContext().parent.reader(); |
100 | | - minTimestamp = LongPoint.decodeDimension(tsPointValues.getMinPackedValue(), 0); |
101 | | - maxTimestamp = LongPoint.decodeDimension(tsPointValues.getMaxPackedValue(), 0); |
| 100 | + FieldInfo info = reader.getFieldInfos().fieldInfo(DataStream.TIMESTAMP_FIELD_NAME); |
| 101 | + if (loadTimestampRange && info != null) { |
| 102 | + if (info.docValuesSkipIndexType() == DocValuesSkipIndexType.RANGE) { |
| 103 | + DocValuesSkipper skipper = reader.getDocValuesSkipper(DataStream.TIMESTAMP_FIELD_NAME); |
| 104 | + minTimestamp = skipper.minValue(); |
| 105 | + maxTimestamp = skipper.maxValue(); |
| 106 | + } else { |
| 107 | + PointValues tsPointValues = reader.getPointValues(DataStream.TIMESTAMP_FIELD_NAME); |
| 108 | + assert tsPointValues != null |
| 109 | + : "no timestamp field for reader:" + reader + " and parent:" + reader.getContext().parent.reader(); |
| 110 | + minTimestamp = LongPoint.decodeDimension(tsPointValues.getMinPackedValue(), 0); |
| 111 | + maxTimestamp = LongPoint.decodeDimension(tsPointValues.getMaxPackedValue(), 0); |
| 112 | + } |
102 | 113 | } else { |
103 | 114 | minTimestamp = 0; |
104 | 115 | maxTimestamp = Long.MAX_VALUE; |
|
0 commit comments