private static void generatePack(FileWriter fw, int bitWidth, boolean isLong) throws IOException {
        long mask = genMask(bitWidth, isLong);
        String maskSuffix = isLong ? "L" : "";
        String variableType = isLong ? VARIABLE_TYPE_FOR_LONG : VARIABLE_TYPE_FOR_INT;
        fw.append("    public final void pack8Values(Object inBase, long inAddr, Object outBase, long outAddr){\n");
        for (int byteIndex = 0; byteIndex < bitWidth; ++byteIndex) {
            //fw.append("      out[" + align(byteIndex, 2) + " + outPos] = (byte)((\n");
            //       putByte(outBase, 0 + outAddr, (byte)((
            fw.append("       setByte(outBase, " + align(byteIndex, 2) + " + outAddr, (byte)((\n");
            int startIndex = (byteIndex * 8) / bitWidth;
            int endIndex = ((byteIndex + 1) * 8 + bitWidth - 1) / bitWidth;
            for (int valueIndex = startIndex; valueIndex < endIndex; valueIndex++) {
                if (valueIndex == startIndex) {
                    fw.append("          ");
                } else {
                    fw.append("\n        | ");
                }
                ShiftMask shiftMask = getShift(fw, bitWidth, isLong, false, byteIndex, valueIndex);

                String shiftString = ""; // used when shift == 0
                if (shiftMask.shift > 0) {
                    shiftString = " >>> " + shiftMask.shift;
                } else if (shiftMask.shift < 0) {
                    shiftString = " <<  " + (-shiftMask.shift);
                }
                //fw.append("((in[" + align(valueIndex, 2) + " + inPos] & " + mask + maskSuffix + ")" + shiftString + ")");
                //           ((in[ 0 + inPos] & 1023))) & 255);
                //           ((getInt(inBase, (0 << 2) + inAddr) & 1023))) & 255));
                if (isLong) {
                    fw.append("((getLong(inBase, (" + align(valueIndex, 2) + " << 3) + inAddr) & " + mask + maskSuffix + ")" + shiftString + ")");
                } else {
                    fw.append("((getInt(inBase, (" + align(valueIndex, 2) + " << 2) + inAddr) & " + mask + maskSuffix + ")" + shiftString + ")");
                }
            }
            fw.append(") & 255));\n");
        }
        fw.append("    }\n");
    }
\n");
        if (msbFirst) {
            fw.append(" * Packs from the Most Significant Bit first\n");
        } else {
            fw.append(" * Packs from the Least Significant Bit first\n");
        }
        fw.append(" * \n");
        fw.append(" * @author automatically generated\n");
        fw.append(" * @see ByteBasedBitPackingGenerator\n");
        fw.append(" *\n");
        fw.append("
indexr-codegen/src/main/java/io/indexr/vlt/codec/pack/PackingClassGen.java