From 684b222221ab0bb1a617b579f79fdf8c612fa16f Mon Sep 17 00:00:00 2001 From: Mike McCandless Date: Fri, 11 Mar 2016 18:43:34 -0500 Subject: [PATCH] Replace O(N^2) cost bitset clearing with O(N) --- .../org/apache/lucene/util/bkd/BKDWriter.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lucene/core/src/java/org/apache/lucene/util/bkd/BKDWriter.java b/lucene/core/src/java/org/apache/lucene/util/bkd/BKDWriter.java index f5a2d8107a8..f1aba9d1219 100644 --- a/lucene/core/src/java/org/apache/lucene/util/bkd/BKDWriter.java +++ b/lucene/core/src/java/org/apache/lucene/util/bkd/BKDWriter.java @@ -1126,6 +1126,14 @@ public class BKDWriter implements Closeable { byte[] maxSplitPackedValue = new byte[packedBytesLength]; System.arraycopy(maxPackedValue, 0, maxSplitPackedValue, 0, packedBytesLength); + // When we are on this dim, below, we clear the ordBitSet: + int dimToClear; + if (numDims - 1 == splitDim) { + dimToClear = numDims - 2; + } else { + dimToClear = numDims - 1; + } + for(int dim=0;dim 1) { - ordBitSet.clear(0, pointCount); - } - // Recurse on left tree: build(2*nodeID, leafNodeOffset, leftSlices, ordBitSet, out,