Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
8.5.1
-
None
-
None
-
New
Description
When a doc id is smaller than a previsou one, I obtain an AssertionError. I check the Lucene code, and find that it is thrown from the following code of EnumFieldSource:
public FunctionValues getValues(Map context, LeafReaderContext readerContext) throws IOException { final NumericDocValues arr = DocValues.getNumeric(readerContext.reader(), field); return new IntDocValues(this) { final MutableValueInt val = new MutableValueInt(); int lastDocID; private int getValueForDoc(int doc) throws IOException { if (doc < lastDocID) { throw new AssertionError("docs were sent out-of-order: lastDocID=" + lastDocID + " vs doc=" + doc); } lastDocID = doc; int curDocID = arr.docID(); if (doc > curDocID) { curDocID = arr.advance(doc); } if (doc == curDocID) { return (int) arr.longValue(); } else { return 0; } } }
My code does not catch the exception. It catches IllegalArgumentException, because Lucene throws the exceptions for similar problems:
DocTermsIndexDocValues:
protected int getOrdForDoc(int doc) throws IOException { if (doc < lastDocID) { throw new IllegalArgumentException("docs were sent out-of-order: lastDocID=" + lastDocID + " vs docID=" + doc); } lastDocID = doc; int curDocID = termsIndex.docID(); if (doc > curDocID) { curDocID = termsIndex.advance(doc); } if (doc == curDocID) { return termsIndex.ordValue(); } else { return -1; } }
BytesRefFieldSource:
private BytesRef getValueForDoc(int doc) throws IOException { if (doc < lastDocID) { throw new IllegalArgumentException("docs were sent out-of-order: lastDocID=" + lastDocID + " vs docID=" + doc); } lastDocID = doc; int curDocID = binaryValues.docID(); if (doc > curDocID) { curDocID = binaryValues.advance(doc); } if (doc == curDocID) { return binaryValues.binaryValue(); } else { return null; } }
FloatFieldSource:
private float getValueForDoc(int doc) throws IOException { if (doc < lastDocID) { throw new IllegalArgumentException("docs were sent out-of-order: lastDocID=" + lastDocID + " vs docID=" + doc); } lastDocID = doc; int curDocID = arr.docID(); if (doc > curDocID) { curDocID = arr.advance(doc); } if (doc == curDocID) { return Float.intBitsToFloat((int)arr.longValue()); } else { return 0f; } }
EnumFieldSource throws a wrong exception. Can this problem be fixed?