zhaih commented on a change in pull request #442:
URL: https://github.com/apache/lucene/pull/442#discussion_r752459454
##########
File path:
lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/TaxonomyIndexArrays.java
##########
@@ -130,6 +125,46 @@ private void initParents(IndexReader reader, int first)
throws IOException {
return;
}
+ if (getMajorVersion(reader) <= 8) {
+ loadParentUsingTermPosition(reader, first);
+ return;
+ }
+
+ for (LeafReaderContext leafContext : reader.leaves()) {
+ int leafDocNum = leafContext.reader().maxDoc();
+ if (leafContext.docBase + leafDocNum <= first) {
+ // skip this leaf if it does not contain new categories
+ continue;
+ }
+ NumericDocValues parentValues =
+
leafContext.reader().getNumericDocValues(Consts.FIELD_PARENT_ORDINAL_NDV);
+ if (parentValues == null) {
+ throw new CorruptIndexException(
+ "Parent data field " + Consts.FIELD_PARENT_ORDINAL_NDV + " not
exists",
+ leafContext.reader().toString());
+ }
+
+ for (int doc = Math.max(first - leafContext.docBase, 0); doc <
leafDocNum; doc++) {
+ if (parentValues.advanceExact(doc) == false) {
+ throw new CorruptIndexException(
+ "Missing parent data for category " + (doc +
leafContext.docBase), reader.toString());
+ }
+ // we're putting an int and converting it back so it should be safe
+ parents[doc + leafContext.docBase] =
Math.toIntExact(parentValues.longValue());
+ }
+ }
+ }
+
+ private static int getMajorVersion(IndexReader reader) {
+ return
reader.leaves().get(0).reader().getMetaData().getCreatedVersionMajor();
Review comment:
Yeah it is guaranteed to be non-empty, but it might be a good idea
adding an assertion (fortunately this is just a private method
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]