public void writeInts()

in java/core/src/java/org/apache/orc/impl/SerializationUtils.java [493:568]


  public void writeInts(long[] input, int offset, int len, int bitSize,
                        OutputStream output) throws IOException {
    if (input == null || input.length < 1 || offset < 0 || len < 1 || bitSize < 1) {
      return;
    }

    switch (bitSize) {
      case 1:
        unrolledBitPack1(input, offset, len, output);
        return;
      case 2:
        unrolledBitPack2(input, offset, len, output);
        return;
      case 4:
        unrolledBitPack4(input, offset, len, output);
        return;
      case 8:
        unrolledBitPack8(input, offset, len, output);
        return;
      case 16:
        unrolledBitPack16(input, offset, len, output);
        return;
      case 24:
        unrolledBitPack24(input, offset, len, output);
        return;
      case 32:
        unrolledBitPack32(input, offset, len, output);
        return;
      case 40:
        unrolledBitPack40(input, offset, len, output);
        return;
      case 48:
        unrolledBitPack48(input, offset, len, output);
        return;
      case 56:
        unrolledBitPack56(input, offset, len, output);
        return;
      case 64:
        unrolledBitPack64(input, offset, len, output);
        return;
      default:
        break;
    }

    int bitsLeft = 8;
    byte current = 0;
    for(int i = offset; i < (offset + len); i++) {
      long value = input[i];
      int bitsToWrite = bitSize;
      while (bitsToWrite > bitsLeft) {
        // add the bits to the bottom of the current word
        current |= value >>> (bitsToWrite - bitsLeft);
        // subtract out the bits we just added
        bitsToWrite -= bitsLeft;
        // zero out the bits above bitsToWrite
        value &= (1L << bitsToWrite) - 1;
        output.write(current);
        current = 0;
        bitsLeft = 8;
      }
      bitsLeft -= bitsToWrite;
      current |= value << bitsLeft;
      if (bitsLeft == 0) {
        output.write(current);
        current = 0;
        bitsLeft = 8;
      }
    }

    // flush
    if (bitsLeft != 8) {
      output.write(current);
      current = 0;
      bitsLeft = 8;
    }
  }