You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2021/11/17 09:32:05 UTC

[GitHub] [lucene] sonatype-lift[bot] commented on a change in pull request #438: LUCENE-10233: Store docIds as bitset when leafCardinality = 1 to speed up addAll

sonatype-lift[bot] commented on a change in pull request #438:
URL: https://github.com/apache/lucene/pull/438#discussion_r751055798



##########
File path: lucene/core/src/java/org/apache/lucene/util/SparseFixedBitSet.java
##########
@@ -530,4 +530,33 @@ public long ramBytesUsed() {
   public String toString() {
     return "SparseFixedBitSet(size=" + length + ",cardinality=~" + approximateCardinality();
   }
+
+  public static SparseFixedBitSet fromWords(int maxDoc, int base, long[] words) {
+    assert (base & 63) == 0;
+    SparseFixedBitSet sparseFixedBitSet = new SparseFixedBitSet(maxDoc + 1);
+    final int baseWord = base >> 6;
+    final long[] indices = sparseFixedBitSet.indices;
+    final long[][] bits = sparseFixedBitSet.bits;
+    int nonZeroWordCounts = 0;
+    int lastIndex = -1;
+    int bitsPos = 0;
+    long[] currentBits = null;
+    for (int i = 0; i < words.length; i++) {
+      long word = words[i];
+      if (word != 0) {
+        int actualI = i + baseWord;
+        int index = actualI >> 6;
+        if (index != lastIndex) {
+          currentBits = bits[index] = new long[64];
+          bitsPos = 0;
+          lastIndex = index;
+        }
+        nonZeroWordCounts++;
+        indices[index] |= 1L << actualI;
+        currentBits[bitsPos++] = word;

Review comment:
       *NULL_DEREFERENCE:*  object `currentBits` last assigned on line 543 could be null and is dereferenced at line 556.
   (at-me [in a reply](https://help.sonatype.com/lift/talking-to-lift) with `help` or `ignore`)




-- 
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: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org