Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

remove 32 bit case (all our int values are >= 0)

Michael McCandlessae8787358a96
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/block/BlockPostingsFormat.java b/lucene/core/src/java/org/apache/lucene/codecs/block/BlockPostingsFormat.java
index 1ae3829edb7..e6e0f63d39e 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/block/BlockPostingsFormat.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/block/BlockPostingsFormat.java
@@ -42,6 +42,7 @@ public final class BlockPostingsFormat extends PostingsFormat {
private final int minTermBlockSize;
private final int maxTermBlockSize;
+ // nocommit do other block sizes perform better?
public final static int BLOCK_SIZE = 128;
public BlockPostingsFormat() {
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/block/BlockPostingsWriter.java b/lucene/core/src/java/org/apache/lucene/codecs/block/BlockPostingsWriter.java
index 8a47c9d607b..4a75391ca88 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/block/BlockPostingsWriter.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/block/BlockPostingsWriter.java
@@ -168,6 +168,7 @@ public final class BlockPostingsWriter extends PostingsWriterBase {
docDeltaBuffer = new int[BLOCK_SIZE];
freqBuffer = new int[BLOCK_SIZE];
+ // nocommit should we try skipping every 2/4 blocks...?
skipWriter = new BlockSkipWriter(maxSkipLevels,
BLOCK_SIZE,
state.segmentInfo.getDocCount(),
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/block/ForUtil.java b/lucene/core/src/java/org/apache/lucene/codecs/block/ForUtil.java
index 6687716a690..ac55322edf8 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/block/ForUtil.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/block/ForUtil.java
@@ -46,6 +46,7 @@ public final class ForUtil {
}
for (int i=0; i<blockSize; ++i) {
+ assert data[i] >= 0;
encodeNormalValue(intBuffer, i, data[i], numBits);
}
@@ -66,12 +67,13 @@ public final class ForUtil {
* @param data int array to hold uncompressed data
* @param header header of current block, which contains numFrameBits
*/
- static void decompress(IntBuffer intBuffer, int[] data, int numBits) {
+ static void decompress(IntBuffer intBuffer, int[] data, int header) {
// since this buffer is reused at upper level, rewind first
intBuffer.rewind();
- // nocommit assert header isn't "malformed", ie besides
- // numBytes / bit-width there is nothing else!
+ // NOTE: header == numBits now, but we may change that
+ final int numBits = header;
+ assert numBits >=0 && numBits < 32;
decompressCore(intBuffer, data, numBits);
}
@@ -109,7 +111,7 @@ public final class ForUtil {
case 29: PackedIntsDecompress.decode29(intBuffer, data); break;
case 30: PackedIntsDecompress.decode30(intBuffer, data); break;
case 31: PackedIntsDecompress.decode31(intBuffer, data); break;
- case 32: PackedIntsDecompress.decode32(intBuffer, data); break;
+ // nocommit have default throw exc? or add assert up above
}
}
@@ -134,7 +136,7 @@ public final class ForUtil {
}
/**
- * Estimate best num of frame bits according to the largest value.
+ * Returns number of bits necessary to represent max value.
*/
static int getNumBits(final int[] data) {
if (isAllEqual(data)) {
@@ -147,6 +149,7 @@ public final class ForUtil {
optBits++;
}
}
+ assert optBits < 32;
return optBits;
}
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/block/PackedIntsDecompress.java b/lucene/core/src/java/org/apache/lucene/codecs/block/PackedIntsDecompress.java
index 79600403206..e0b82a415bd 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/block/PackedIntsDecompress.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/block/PackedIntsDecompress.java
@@ -1766,76 +1766,4 @@ final class PackedIntsDecompress {
outputOffset += 32;
}
}
- public static void decode32(final IntBuffer compressedBuffer, final int[] output) {
- final int numFrameBits = 32;
- final int mask = (int) ((1L<<numFrameBits) - 1);
- int outputOffset = 0;
- for(int step=0;step<4;step++) {
- int intValue0 = compressedBuffer.get();
- int intValue1 = compressedBuffer.get();
- int intValue2 = compressedBuffer.get();
- int intValue3 = compressedBuffer.get();
- int intValue4 = compressedBuffer.get();
- int intValue5 = compressedBuffer.get();
- int intValue6 = compressedBuffer.get();
- int intValue7 = compressedBuffer.get();
- int intValue8 = compressedBuffer.get();
- int intValue9 = compressedBuffer.get();
- int intValue10 = compressedBuffer.get();
- int intValue11 = compressedBuffer.get();
- int intValue12 = compressedBuffer.get();
- int intValue13 = compressedBuffer.get();
- int intValue14 = compressedBuffer.get();
- int intValue15 = compressedBuffer.get();
- int intValue16 = compressedBuffer.get();
- int intValue17 = compressedBuffer.get();
- int intValue18 = compressedBuffer.get();
- int intValue19 = compressedBuffer.get();
- int intValue20 = compressedBuffer.get();
- int intValue21 = compressedBuffer.get();
- int intValue22 = compressedBuffer.get();
- int intValue23 = compressedBuffer.get();
- int intValue24 = compressedBuffer.get();
- int intValue25 = compressedBuffer.get();
- int intValue26 = compressedBuffer.get();
- int intValue27 = compressedBuffer.get();
- int intValue28 = compressedBuffer.get();
- int intValue29 = compressedBuffer.get();
- int intValue30 = compressedBuffer.get();
- int intValue31 = compressedBuffer.get();
- output[0 + outputOffset] = intValue0;
- output[1 + outputOffset] = intValue1;
- output[2 + outputOffset] = intValue2;
- output[3 + outputOffset] = intValue3;
- output[4 + outputOffset] = intValue4;
- output[5 + outputOffset] = intValue5;
- output[6 + outputOffset] = intValue6;
- output[7 + outputOffset] = intValue7;
- output[8 + outputOffset] = intValue8;
- output[9 + outputOffset] = intValue9;
- output[10 + outputOffset] = intValue10;
- output[11 + outputOffset] = intValue11;
- output[12 + outputOffset] = intValue12;
- output[13 + outputOffset] = intValue13;
- output[14 + outputOffset] = intValue14;
- output[15 + outputOffset] = intValue15;
- output[16 + outputOffset] = intValue16;
- output[17 + outputOffset] = intValue17;
- output[18 + outputOffset] = intValue18;
- output[19 + outputOffset] = intValue19;
- output[20 + outputOffset] = intValue20;
- output[21 + outputOffset] = intValue21;
- output[22 + outputOffset] = intValue22;
- output[23 + outputOffset] = intValue23;
- output[24 + outputOffset] = intValue24;
- output[25 + outputOffset] = intValue25;
- output[26 + outputOffset] = intValue26;
- output[27 + outputOffset] = intValue27;
- output[28 + outputOffset] = intValue28;
- output[29 + outputOffset] = intValue29;
- output[30 + outputOffset] = intValue30;
- output[31 + outputOffset] = intValue31;
- outputOffset += 32;
- }
- }
}