gf2121 commented on a change in pull request #562:
URL: https://github.com/apache/lucene/pull/562#discussion_r774526889



##########
File path: lucene/core/src/java/org/apache/lucene/util/packed/ForUtil.java
##########
@@ -0,0 +1,3311 @@
+// This file has been automatically generated, DO NOT EDIT
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.util.packed;
+
+import java.io.IOException;
+import org.apache.lucene.store.DataInput;
+import org.apache.lucene.store.DataOutput;
+import org.apache.lucene.util.MathUtil;
+
+// Inspired from https://fulmicoton.com/posts/bitpacking/
+// Encodes multiple integers in a long to get SIMD-like speedups.
+// If bitsPerValue <= 8 then we pack 8 ints per long
+// else if bitsPerValue <= 16 we pack 4 ints per long
+// else we pack 2 ints per long
+final class ForUtil {
+
+  static final int BLOCK_SIZE = 128;
+  static final int BLOCK_SIZE_LOG2 = MathUtil.log(BLOCK_SIZE, 2);
+  private static final int BLOCK_SIZE_DIV_2 = BLOCK_SIZE >> 1;
+  private static final int BLOCK_SIZE_DIV_4 = BLOCK_SIZE >> 2;
+  static final int BLOCK_SIZE_DIV_8 = BLOCK_SIZE >> 3;
+  private static final int BLOCK_SIZE_DIV_64 = BLOCK_SIZE >> 6;
+  private static final int BLOCK_SIZE_DIV_8_MUL_1 = BLOCK_SIZE_DIV_8;
+  private static final int BLOCK_SIZE_DIV_8_MUL_2 = BLOCK_SIZE_DIV_8 * 2;
+  private static final int BLOCK_SIZE_DIV_8_MUL_3 = BLOCK_SIZE_DIV_8 * 3;
+  private static final int BLOCK_SIZE_DIV_8_MUL_4 = BLOCK_SIZE_DIV_8 * 4;
+  private static final int BLOCK_SIZE_DIV_8_MUL_5 = BLOCK_SIZE_DIV_8 * 5;
+  private static final int BLOCK_SIZE_DIV_8_MUL_6 = BLOCK_SIZE_DIV_8 * 6;
+  private static final int BLOCK_SIZE_DIV_8_MUL_7 = BLOCK_SIZE_DIV_8 * 7;
+  private static final int BLOCK_SIZE_LOG2_MIN_3 = BLOCK_SIZE_LOG2 - 3;
+
+  private static long expandMask32(long mask32) {
+    return mask32 | (mask32 << 32);
+  }
+
+  private static long expandMask16(long mask16) {
+    return expandMask32(mask16 | (mask16 << 16));
+  }
+
+  private static long expandMask8(long mask8) {
+    return expandMask16(mask8 | (mask8 << 8));
+  }
+
+  private static long mask32(int bitsPerValue) {
+    return expandMask32((1L << bitsPerValue) - 1);
+  }
+
+  private static long mask64(int bitsPerValue) {
+    return (1L << bitsPerValue) - 1;
+  }
+
+  private static long mask16(int bitsPerValue) {
+    return expandMask16((1L << bitsPerValue) - 1);
+  }
+
+  private static long mask8(int bitsPerValue) {
+    return expandMask8((1L << bitsPerValue) - 1);
+  }
+
+  private static void expand8(long[] arr) {
+    for (int i = 0; i < BLOCK_SIZE_DIV_8; ++i) {
+      long l = arr[i];
+      arr[i] = (l >>> 56) & 0xFFL;
+      arr[BLOCK_SIZE_DIV_8_MUL_1 + i] = (l >>> 48) & 0xFFL;
+      arr[BLOCK_SIZE_DIV_8_MUL_2 + i] = (l >>> 40) & 0xFFL;
+      arr[BLOCK_SIZE_DIV_8_MUL_3 + i] = (l >>> 32) & 0xFFL;
+      arr[BLOCK_SIZE_DIV_8_MUL_4 + i] = (l >>> 24) & 0xFFL;
+      arr[BLOCK_SIZE_DIV_8_MUL_5 + i] = (l >>> 16) & 0xFFL;
+      arr[BLOCK_SIZE_DIV_8_MUL_6 + i] = (l >>> 8) & 0xFFL;
+      arr[BLOCK_SIZE_DIV_8_MUL_7 + i] = l & 0xFFL;
+    }
+  }
+
+  private static void collapse8(long[] arr) {
+    for (int i = 0; i < BLOCK_SIZE_DIV_8; ++i) {
+      arr[i] =
+          (arr[i] << 56)
+              | (arr[BLOCK_SIZE_DIV_8_MUL_1 + i] << 48)
+              | (arr[BLOCK_SIZE_DIV_8_MUL_2 + i] << 40)
+              | (arr[BLOCK_SIZE_DIV_8_MUL_3 + i] << 32)
+              | (arr[BLOCK_SIZE_DIV_8_MUL_4 + i] << 24)
+              | (arr[BLOCK_SIZE_DIV_8_MUL_5 + i] << 16)
+              | (arr[BLOCK_SIZE_DIV_8_MUL_6 + i] << 8)
+              | arr[BLOCK_SIZE_DIV_8_MUL_7 + i];
+    }
+  }
+
+  private static void expand16(long[] arr) {
+    for (int i = 0; i < BLOCK_SIZE_DIV_4; ++i) {
+      long l = arr[i];
+      arr[i] = (l >>> 48) & 0xFFFFL;
+      arr[BLOCK_SIZE_DIV_8_MUL_2 + i] = (l >>> 32) & 0xFFFFL;
+      arr[BLOCK_SIZE_DIV_8_MUL_4 + i] = (l >>> 16) & 0xFFFFL;
+      arr[BLOCK_SIZE_DIV_8_MUL_6 + i] = l & 0xFFFFL;
+    }
+  }
+
+  private static void collapse16(long[] arr) {
+    for (int i = 0; i < BLOCK_SIZE_DIV_4; ++i) {
+      arr[i] =
+          (arr[i] << 48)
+              | (arr[BLOCK_SIZE_DIV_8_MUL_2 + i] << 32)
+              | (arr[BLOCK_SIZE_DIV_8_MUL_4 + i] << 16)
+              | arr[BLOCK_SIZE_DIV_8_MUL_6 + i];
+    }
+  }
+
+  private static void expand32(long[] arr) {
+    for (int i = 0; i < BLOCK_SIZE_DIV_2; ++i) {
+      long l = arr[i];
+      arr[i] = l >>> 32;
+      arr[BLOCK_SIZE_DIV_8_MUL_4 + i] = l & 0xFFFFFFFFL;
+    }
+  }
+
+  private static void collapse32(long[] arr) {
+    for (int i = 0; i < BLOCK_SIZE_DIV_2; ++i) {
+      arr[i] = (arr[i] << 32) | arr[BLOCK_SIZE_DIV_8_MUL_4 + i];
+    }
+  }
+
+  private final long[] tmp;
+
+  ForUtil() {
+    this.tmp = new long[BLOCK_SIZE];
+  }
+
+  ForUtil(long[] tmp) {
+    assert tmp.length >= BLOCK_SIZE;
+    this.tmp = tmp;
+  }
+
+  /** Encode 128 integers from {@code longs} into {@code out}. */
+  void encode(long[] longs, int bitsPerValue, DataOutput out) throws 
IOException {
+    final int nextPrimitive;
+    final int numLongs;
+    if (bitsPerValue <= 8) {
+      nextPrimitive = 8;
+      numLongs = BLOCK_SIZE_DIV_8;
+      collapse8(longs);
+    } else if (bitsPerValue <= 16) {
+      nextPrimitive = 16;
+      numLongs = BLOCK_SIZE_DIV_4;
+      collapse16(longs);
+    } else if (bitsPerValue <= 32){
+      nextPrimitive = 32;
+      numLongs = BLOCK_SIZE_DIV_2;
+      collapse32(longs);
+    } else {
+      nextPrimitive = 64;
+      numLongs = BLOCK_SIZE;
+    }
+
+    final int numLongsPerShift = bitsPerValue * BLOCK_SIZE_DIV_64;
+    int idx = 0;
+    int shift = nextPrimitive - bitsPerValue;
+    for (int i = 0; i < numLongsPerShift; ++i) {
+      tmp[i] = longs[idx++] << shift;
+    }
+    for (shift = shift - bitsPerValue; shift >= 0; shift -= bitsPerValue) {
+      for (int i = 0; i < numLongsPerShift; ++i) {
+        tmp[i] |= longs[idx++] << shift;
+      }
+    }
+
+    final int remainingBitsPerLong = shift + bitsPerValue;
+    final long maskRemainingBitsPerLong;
+    if (nextPrimitive == 8) {
+      maskRemainingBitsPerLong = MASKS8[remainingBitsPerLong];
+    } else if (nextPrimitive == 16) {
+      maskRemainingBitsPerLong = MASKS16[remainingBitsPerLong];
+    } else if (nextPrimitive == 32) {
+      maskRemainingBitsPerLong = MASKS32[remainingBitsPerLong];
+    } else {
+      maskRemainingBitsPerLong = MASKS64[remainingBitsPerLong];
+    }
+
+    int tmpIdx = 0;
+    int remainingBitsPerValue = bitsPerValue;
+    while (idx < numLongs) {
+      if (remainingBitsPerValue >= remainingBitsPerLong) {
+        remainingBitsPerValue -= remainingBitsPerLong;
+        tmp[tmpIdx++] |= (longs[idx] >>> remainingBitsPerValue) & 
maskRemainingBitsPerLong;
+        if (remainingBitsPerValue == 0) {
+          idx++;
+          remainingBitsPerValue = bitsPerValue;
+        }
+      } else {
+        final long mask1, mask2;
+        if (nextPrimitive == 8) {
+          mask1 = MASKS8[remainingBitsPerValue];
+          mask2 = MASKS8[remainingBitsPerLong - remainingBitsPerValue];
+        } else if (nextPrimitive == 16) {
+          mask1 = MASKS16[remainingBitsPerValue];
+          mask2 = MASKS16[remainingBitsPerLong - remainingBitsPerValue];
+        } else if (nextPrimitive == 32) {
+          mask1 = MASKS32[remainingBitsPerValue];
+          mask2 = MASKS32[remainingBitsPerLong - remainingBitsPerValue];
+        } else {
+          mask1 = MASKS64[remainingBitsPerValue];
+          mask2 = MASKS64[remainingBitsPerLong - remainingBitsPerValue];
+        }
+        tmp[tmpIdx] |= (longs[idx++] & mask1) << (remainingBitsPerLong - 
remainingBitsPerValue);
+        remainingBitsPerValue = bitsPerValue - remainingBitsPerLong + 
remainingBitsPerValue;
+        tmp[tmpIdx++] |= (longs[idx] >>> remainingBitsPerValue) & mask2;
+      }
+    }
+
+    for (int i = 0; i < numLongsPerShift; ++i) {
+      out.writeLong(tmp[i]);
+    }
+  }
+
+  /** Number of bytes required to encode 128 integers of {@code bitsPerValue} 
bits per value. */
+  int numBytes(int bitsPerValue) {
+    return bitsPerValue << BLOCK_SIZE_LOG2_MIN_3;
+  }
+
+  private static void decodeSlow(int bitsPerValue, DataInput in, long[] tmp, 
long[] longs)
+      throws IOException {
+    final int numLongs = bitsPerValue * BLOCK_SIZE_DIV_64;
+    in.readLongs(tmp, 0, numLongs);
+    final long mask = MASKS32[bitsPerValue];
+    int longsIdx = 0;
+    int shift = 32 - bitsPerValue;
+    for (; shift >= 0; shift -= bitsPerValue) {
+      shiftLongs(tmp, numLongs, longs, longsIdx, shift, mask);
+      longsIdx += numLongs;
+    }
+    final int remainingBitsPerLong = shift + bitsPerValue;
+    final long mask32RemainingBitsPerLong = MASKS32[remainingBitsPerLong];
+    int tmpIdx = 0;
+    int remainingBits = remainingBitsPerLong;
+    for (; longsIdx < BLOCK_SIZE_DIV_2; ++longsIdx) {
+      int b = bitsPerValue - remainingBits;
+      long l = (tmp[tmpIdx++] & MASKS32[remainingBits]) << b;
+      while (b >= remainingBitsPerLong) {
+        b -= remainingBitsPerLong;
+        l |= (tmp[tmpIdx++] & mask32RemainingBitsPerLong) << b;
+      }
+      if (b > 0) {
+        l |= (tmp[tmpIdx] >>> (remainingBitsPerLong - b)) & MASKS32[b];
+        remainingBits = remainingBitsPerLong - b;
+      } else {
+        remainingBits = remainingBitsPerLong;
+      }
+      longs[longsIdx] = l;
+    }
+  }
+
+  /**
+   * The pattern that this shiftLongs method applies is recognized by the C2 
compiler, which
+   * generates SIMD instructions for it in order to shift multiple longs at 
once.
+   */
+  private static void shiftLongs(long[] a, int count, long[] b, int bi, int 
shift, long mask) {
+    for (int i = 0; i < count; ++i) {
+      b[bi + i] = (a[i] >>> shift) & mask;
+    }
+  }
+
+  private static final long[] MASKS8 = new long[8];
+  private static final long[] MASKS16 = new long[16];
+  private static final long[] MASKS32 = new long[32];
+  private static final long[] MASKS64 = new long[64];
+
+  static {
+    for (int i = 0; i < 8; ++i) {
+      MASKS8[i] = mask8(i);
+    }
+    for (int i = 0; i < 16; ++i) {
+      MASKS16[i] = mask16(i);
+    }
+    for (int i = 0; i < 32; ++i) {
+      MASKS32[i] = mask32(i);
+    }
+    for (int i = 0; i < 64; ++i) {
+      MASKS64[i] = mask64(i);
+    }
+  }
+  // mark values in array as final longs to avoid the cost of reading array, 
arrays should only be
+  // used when the idx is a variable
+  private static final long MASK8_1 = MASKS8[1];
+  private static final long MASK8_2 = MASKS8[2];
+  private static final long MASK8_3 = MASKS8[3];
+  private static final long MASK8_4 = MASKS8[4];
+  private static final long MASK8_5 = MASKS8[5];
+  private static final long MASK8_6 = MASKS8[6];
+  private static final long MASK8_7 = MASKS8[7];
+  private static final long MASK16_1 = MASKS16[1];
+  private static final long MASK16_2 = MASKS16[2];
+  private static final long MASK16_3 = MASKS16[3];
+  private static final long MASK16_4 = MASKS16[4];
+  private static final long MASK16_5 = MASKS16[5];
+  private static final long MASK16_6 = MASKS16[6];
+  private static final long MASK16_7 = MASKS16[7];
+  private static final long MASK16_9 = MASKS16[9];
+  private static final long MASK16_10 = MASKS16[10];
+  private static final long MASK16_11 = MASKS16[11];
+  private static final long MASK16_12 = MASKS16[12];
+  private static final long MASK16_13 = MASKS16[13];
+  private static final long MASK16_14 = MASKS16[14];
+  private static final long MASK16_15 = MASKS16[15];
+  private static final long MASK32_1 = MASKS32[1];
+  private static final long MASK32_2 = MASKS32[2];
+  private static final long MASK32_3 = MASKS32[3];
+  private static final long MASK32_4 = MASKS32[4];
+  private static final long MASK32_5 = MASKS32[5];
+  private static final long MASK32_6 = MASKS32[6];
+  private static final long MASK32_7 = MASKS32[7];
+  private static final long MASK32_8 = MASKS32[8];
+  private static final long MASK32_9 = MASKS32[9];
+  private static final long MASK32_10 = MASKS32[10];
+  private static final long MASK32_11 = MASKS32[11];
+  private static final long MASK32_12 = MASKS32[12];
+  private static final long MASK32_13 = MASKS32[13];
+  private static final long MASK32_14 = MASKS32[14];
+  private static final long MASK32_15 = MASKS32[15];
+  private static final long MASK32_17 = MASKS32[17];
+  private static final long MASK32_18 = MASKS32[18];
+  private static final long MASK32_19 = MASKS32[19];
+  private static final long MASK32_20 = MASKS32[20];
+  private static final long MASK32_21 = MASKS32[21];
+  private static final long MASK32_22 = MASKS32[22];
+  private static final long MASK32_23 = MASKS32[23];
+  private static final long MASK32_24 = MASKS32[24];
+  private static final long MASK32_25 = MASKS32[25];
+  private static final long MASK32_26 = MASKS32[26];
+  private static final long MASK32_27 = MASKS32[27];
+  private static final long MASK32_28 = MASKS32[28];
+  private static final long MASK32_29 = MASKS32[29];
+  private static final long MASK32_30 = MASKS32[30];
+  private static final long MASK32_31 = MASKS32[31];
+  private static final long MASK64_1 = MASKS64[1];
+  private static final long MASK64_2 = MASKS64[2];
+  private static final long MASK64_3 = MASKS64[3];
+  private static final long MASK64_4 = MASKS64[4];
+  private static final long MASK64_5 = MASKS64[5];
+  private static final long MASK64_6 = MASKS64[6];
+  private static final long MASK64_7 = MASKS64[7];
+  private static final long MASK64_8 = MASKS64[8];
+  private static final long MASK64_9 = MASKS64[9];
+  private static final long MASK64_10 = MASKS64[10];
+  private static final long MASK64_11 = MASKS64[11];
+  private static final long MASK64_12 = MASKS64[12];
+  private static final long MASK64_13 = MASKS64[13];
+  private static final long MASK64_14 = MASKS64[14];
+  private static final long MASK64_15 = MASKS64[15];
+  private static final long MASK64_16 = MASKS64[16];
+  private static final long MASK64_17 = MASKS64[17];
+  private static final long MASK64_18 = MASKS64[18];
+  private static final long MASK64_19 = MASKS64[19];
+  private static final long MASK64_20 = MASKS64[20];
+  private static final long MASK64_21 = MASKS64[21];
+  private static final long MASK64_22 = MASKS64[22];
+  private static final long MASK64_23 = MASKS64[23];
+  private static final long MASK64_24 = MASKS64[24];
+  private static final long MASK64_25 = MASKS64[25];
+  private static final long MASK64_26 = MASKS64[26];
+  private static final long MASK64_27 = MASKS64[27];
+  private static final long MASK64_28 = MASKS64[28];
+  private static final long MASK64_29 = MASKS64[29];
+  private static final long MASK64_30 = MASKS64[30];
+  private static final long MASK64_31 = MASKS64[31];
+  private static final long MASK64_33 = MASKS64[33];
+  private static final long MASK64_34 = MASKS64[34];
+  private static final long MASK64_35 = MASKS64[35];
+  private static final long MASK64_36 = MASKS64[36];
+  private static final long MASK64_37 = MASKS64[37];
+  private static final long MASK64_38 = MASKS64[38];
+  private static final long MASK64_39 = MASKS64[39];
+  private static final long MASK64_40 = MASKS64[40];
+  private static final long MASK64_41 = MASKS64[41];
+  private static final long MASK64_42 = MASKS64[42];
+  private static final long MASK64_43 = MASKS64[43];
+  private static final long MASK64_44 = MASKS64[44];
+  private static final long MASK64_45 = MASKS64[45];
+  private static final long MASK64_46 = MASKS64[46];
+  private static final long MASK64_47 = MASKS64[47];
+  private static final long MASK64_48 = MASKS64[48];
+  private static final long MASK64_49 = MASKS64[49];
+  private static final long MASK64_50 = MASKS64[50];
+  private static final long MASK64_51 = MASKS64[51];
+  private static final long MASK64_52 = MASKS64[52];
+  private static final long MASK64_53 = MASKS64[53];
+  private static final long MASK64_54 = MASKS64[54];
+  private static final long MASK64_55 = MASKS64[55];
+  private static final long MASK64_56 = MASKS64[56];
+  private static final long MASK64_57 = MASKS64[57];
+  private static final long MASK64_58 = MASKS64[58];
+  private static final long MASK64_59 = MASKS64[59];
+  private static final long MASK64_60 = MASKS64[60];
+  private static final long MASK64_61 = MASKS64[61];
+  private static final long MASK64_62 = MASKS64[62];
+  private static final long MASK64_63 = MASKS64[63];
+
+  /** Decode 128 integers into {@code longs}. */
+  void decode(int bitsPerValue, DataInput in, long[] longs) throws IOException 
{
+    switch (bitsPerValue) {
+      case 1:
+        decode1(in, tmp, longs);
+        expand8(longs);
+        break;
+      case 2:
+        decode2(in, tmp, longs);
+        expand8(longs);
+        break;
+      case 3:
+        decode3(in, tmp, longs);
+        expand8(longs);
+        break;
+      case 4:
+        decode4(in, tmp, longs);
+        expand8(longs);
+        break;
+      case 5:
+        decode5(in, tmp, longs);
+        expand8(longs);
+        break;
+      case 6:
+        decode6(in, tmp, longs);
+        expand8(longs);
+        break;
+      case 7:
+        decode7(in, tmp, longs);
+        expand8(longs);
+        break;
+      case 8:
+        decode8(in, tmp, longs);
+        expand8(longs);
+        break;
+      case 9:
+        decode9(in, tmp, longs);
+        expand16(longs);
+        break;
+      case 10:
+        decode10(in, tmp, longs);
+        expand16(longs);
+        break;
+      case 11:
+        decode11(in, tmp, longs);
+        expand16(longs);
+        break;
+      case 12:
+        decode12(in, tmp, longs);
+        expand16(longs);
+        break;
+      case 13:
+        decode13(in, tmp, longs);
+        expand16(longs);
+        break;
+      case 14:
+        decode14(in, tmp, longs);
+        expand16(longs);
+        break;
+      case 15:
+        decode15(in, tmp, longs);
+        expand16(longs);
+        break;
+      case 16:
+        decode16(in, tmp, longs);
+        expand16(longs);
+        break;
+      case 17:
+        decode17(in, tmp, longs);
+        expand32(longs);
+        break;
+      case 18:
+        decode18(in, tmp, longs);
+        expand32(longs);
+        break;
+      case 19:
+        decode19(in, tmp, longs);
+        expand32(longs);
+        break;
+      case 20:
+        decode20(in, tmp, longs);
+        expand32(longs);
+        break;
+      case 21:
+        decode21(in, tmp, longs);
+        expand32(longs);
+        break;
+      case 22:
+        decode22(in, tmp, longs);
+        expand32(longs);
+        break;
+      case 23:
+        decode23(in, tmp, longs);
+        expand32(longs);
+        break;
+      case 24:
+        decode24(in, tmp, longs);
+        expand32(longs);
+        break;
+      case 25:
+        decode25(in, tmp, longs);
+        expand32(longs);
+        break;
+      case 26:
+        decode26(in, tmp, longs);
+        expand32(longs);
+        break;
+      case 27:
+        decode27(in, tmp, longs);
+        expand32(longs);
+        break;
+      case 28:
+        decode28(in, tmp, longs);
+        expand32(longs);
+        break;
+      case 29:
+        decode29(in, tmp, longs);
+        expand32(longs);
+        break;
+      case 30:
+        decode30(in, tmp, longs);
+        expand32(longs);
+        break;
+      case 31:
+        decode31(in, tmp, longs);
+        expand32(longs);
+        break;
+      case 32:
+        decode32(in, tmp, longs);
+        expand32(longs);
+        break;
+      case 33:
+        decode33(in, tmp, longs);
+        break;
+      case 34:
+        decode34(in, tmp, longs);
+        break;
+      case 35:
+        decode35(in, tmp, longs);
+        break;
+      case 36:
+        decode36(in, tmp, longs);
+        break;
+      case 37:
+        decode37(in, tmp, longs);
+        break;
+      case 38:
+        decode38(in, tmp, longs);
+        break;
+      case 39:
+        decode39(in, tmp, longs);
+        break;
+      case 40:
+        decode40(in, tmp, longs);
+        break;
+      case 41:
+        decode41(in, tmp, longs);
+        break;
+      case 42:
+        decode42(in, tmp, longs);
+        break;
+      case 43:
+        decode43(in, tmp, longs);
+        break;
+      case 44:
+        decode44(in, tmp, longs);
+        break;
+      case 45:
+        decode45(in, tmp, longs);
+        break;
+      case 46:
+        decode46(in, tmp, longs);
+        break;
+      case 47:
+        decode47(in, tmp, longs);
+        break;
+      case 48:
+        decode48(in, tmp, longs);
+        break;
+      case 49:
+        decode49(in, tmp, longs);
+        break;
+      case 50:
+        decode50(in, tmp, longs);
+        break;
+      case 51:
+        decode51(in, tmp, longs);
+        break;
+      case 52:
+        decode52(in, tmp, longs);
+        break;
+      case 53:
+        decode53(in, tmp, longs);
+        break;
+      case 54:
+        decode54(in, tmp, longs);
+        break;
+      case 55:
+        decode55(in, tmp, longs);
+        break;
+      case 56:
+        decode56(in, tmp, longs);
+        break;
+      case 57:
+        decode57(in, tmp, longs);
+        break;
+      case 58:
+        decode58(in, tmp, longs);
+        break;
+      case 59:
+        decode59(in, tmp, longs);
+        break;
+      case 60:
+        decode60(in, tmp, longs);
+        break;
+      case 61:
+        decode61(in, tmp, longs);
+        break;
+      case 62:
+        decode62(in, tmp, longs);
+        break;
+      case 63:
+        decode63(in, tmp, longs);
+        break;
+      case 64:
+        decode64(in, tmp, longs);
+        break;
+      default:
+        decodeSlow(bitsPerValue, in, tmp, longs);
+        expand32(longs);
+        break;
+    }
+  }
+
+  private static void decode1(DataInput in, long[] tmp, long[] longs) throws 
IOException {
+    in.readLongs(tmp, 0, 2);
+    shiftLongs(tmp, 2, longs, 0, 7, MASK8_1);
+    shiftLongs(tmp, 2, longs, 2, 6, MASK8_1);
+    shiftLongs(tmp, 2, longs, 4, 5, MASK8_1);
+    shiftLongs(tmp, 2, longs, 6, 4, MASK8_1);
+    shiftLongs(tmp, 2, longs, 8, 3, MASK8_1);
+    shiftLongs(tmp, 2, longs, 10, 2, MASK8_1);
+    shiftLongs(tmp, 2, longs, 12, 1, MASK8_1);
+    shiftLongs(tmp, 2, longs, 14, 0, MASK8_1);
+  }
+
+  private static void decode2(DataInput in, long[] tmp, long[] longs) throws 
IOException {
+    in.readLongs(tmp, 0, 4);
+    shiftLongs(tmp, 4, longs, 0, 6, MASK8_2);
+    shiftLongs(tmp, 4, longs, 4, 4, MASK8_2);
+    shiftLongs(tmp, 4, longs, 8, 2, MASK8_2);
+    shiftLongs(tmp, 4, longs, 12, 0, MASK8_2);
+  }
+
+  private static void decode3(DataInput in, long[] tmp, long[] longs) throws 
IOException {
+    in.readLongs(tmp, 0, 6);
+    shiftLongs(tmp, 6, longs, 0, 5, MASK8_3);
+    shiftLongs(tmp, 6, longs, 6, 2, MASK8_3);
+    for (int iter = 0, tmpIdx = 0, longsIdx = 12; iter < 2; ++iter, tmpIdx += 
3, longsIdx += 2) {
+      long l0 = (tmp[tmpIdx + 0] & MASK8_2) << 1;
+      l0 |= (tmp[tmpIdx + 1] >>> 1) & MASK8_1;
+      longs[longsIdx + 0] = l0;
+      long l1 = (tmp[tmpIdx + 1] & MASK8_1) << 2;
+      l1 |= (tmp[tmpIdx + 2] & MASK8_2) << 0;
+      longs[longsIdx + 1] = l1;
+    }
+  }
+
+  private static void decode4(DataInput in, long[] tmp, long[] longs) throws 
IOException {
+    in.readLongs(tmp, 0, 8);
+    shiftLongs(tmp, 8, longs, 0, 4, MASK8_4);
+    shiftLongs(tmp, 8, longs, 8, 0, MASK8_4);
+  }
+
+  private static void decode5(DataInput in, long[] tmp, long[] longs) throws 
IOException {
+    in.readLongs(tmp, 0, 10);
+    shiftLongs(tmp, 10, longs, 0, 3, MASK8_5);
+    for (int iter = 0, tmpIdx = 0, longsIdx = 10; iter < 2; ++iter, tmpIdx += 
5, longsIdx += 3) {
+      long l0 = (tmp[tmpIdx + 0] & MASK8_3) << 2;
+      l0 |= (tmp[tmpIdx + 1] >>> 1) & MASK8_2;
+      longs[longsIdx + 0] = l0;
+      long l1 = (tmp[tmpIdx + 1] & MASK8_1) << 4;
+      l1 |= (tmp[tmpIdx + 2] & MASK8_3) << 1;
+      l1 |= (tmp[tmpIdx + 3] >>> 2) & MASK8_1;
+      longs[longsIdx + 1] = l1;
+      long l2 = (tmp[tmpIdx + 3] & MASK8_2) << 3;
+      l2 |= (tmp[tmpIdx + 4] & MASK8_3) << 0;
+      longs[longsIdx + 2] = l2;
+    }
+  }
+
+  private static void decode6(DataInput in, long[] tmp, long[] longs) throws 
IOException {
+    in.readLongs(tmp, 0, 12);
+    shiftLongs(tmp, 12, longs, 0, 2, MASK8_6);
+    shiftLongs(tmp, 12, tmp, 0, 0, MASK8_2);
+    for (int iter = 0, tmpIdx = 0, longsIdx = 12; iter < 4; ++iter, tmpIdx += 
3, longsIdx += 1) {
+      long l0 = tmp[tmpIdx + 0] << 4;
+      l0 |= tmp[tmpIdx + 1] << 2;
+      l0 |= tmp[tmpIdx + 2] << 0;
+      longs[longsIdx + 0] = l0;
+    }
+  }
+
+  private static void decode7(DataInput in, long[] tmp, long[] longs) throws 
IOException {
+    in.readLongs(tmp, 0, 14);
+    shiftLongs(tmp, 14, longs, 0, 1, MASK8_7);
+    shiftLongs(tmp, 14, tmp, 0, 0, MASK8_1);
+    for (int iter = 0, tmpIdx = 0, longsIdx = 14; iter < 2; ++iter, tmpIdx += 
7, longsIdx += 1) {
+      long l0 = tmp[tmpIdx + 0] << 6;
+      l0 |= tmp[tmpIdx + 1] << 5;
+      l0 |= tmp[tmpIdx + 2] << 4;
+      l0 |= tmp[tmpIdx + 3] << 3;
+      l0 |= tmp[tmpIdx + 4] << 2;
+      l0 |= tmp[tmpIdx + 5] << 1;
+      l0 |= tmp[tmpIdx + 6] << 0;
+      longs[longsIdx + 0] = l0;
+    }
+  }
+
+  private static void decode8(DataInput in, long[] tmp, long[] longs) throws 
IOException {

Review comment:
       fixed




-- 
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]

Reply via email to