iverase commented on a change in pull request #607:
URL: https://github.com/apache/lucene/pull/607#discussion_r787419417
##########
File path: lucene/core/src/java/org/apache/lucene/util/bkd/BKDReader.java
##########
@@ -105,6 +107,51 @@ public BKDReader(IndexInput metaIn, IndexInput indexIn,
IndexInput dataIn) throw
}
this.packedIndex = indexIn.slice("packedIndex", indexStartPointer,
numIndexBytes);
this.in = dataIn;
+ this.isTreeBalanced = isTreeBalanced();
+ }
+
+ private boolean isTreeBalanced() throws IOException {
+ if (version >= BKDWriter.VERSION_META_FILE || numLeaves == 1) {
+ // since lucene 8.6 all trees are unbalanced.
+ // for only one leaf we can assume unbalanced.
+ return false;
+ }
Review comment:
For Lucene pre-8.6 I added the following logic:
- if numDims > 1 then it will always be balanced.
- for numDims == 1:
if numLeaves != 1 << n, then we cannot fill the last level and
therefore is unbalanced.
finally the slow path: we count the number of points I the last leaf
node. If the number of points in theist leaf node == totalPoints % numLeaves
then is unbalanced, otherwise balanced.
--
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]