From ae8787358a965f1ee32640518ae36ae2299e8992 Mon Sep 17 00:00:00 2001 From: Michael McCandless Date: Tue, 7 Aug 2012 16:01:27 +0000 Subject: [PATCH] remove 32 bit case (all our int values are >= 0) git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/pforcodec_3892@1370330 13f79535-47bb-0310-9956-ffa450edef68 --- .../codecs/block/BlockPostingsFormat.java | 1 + .../codecs/block/BlockPostingsWriter.java | 1 + .../apache/lucene/codecs/block/ForUtil.java | 13 ++-- .../codecs/block/PackedIntsDecompress.java | 72 ------------------- 4 files changed, 10 insertions(+), 77 deletions(-) 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= 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<