@Override public BytesInput getBytes() { if (!dictionaryTooBig && dict.size() > 0) { // remember size of dictionary when we last wrote a page lastUsedDictionarySize = dict.size(); lastUsedDictionaryByteSize = dictionaryByteSize; int maxDicId = dict.size() - 1; if (DEBUG) LOG.debug("max dic id " + maxDicId); int bitWidth = BytesUtils.getWidthFromMaxInt(maxDicId); // TODO: what is a good initialCapacity? final RunLengthBitPackingHybridEncoder encoder = new RunLengthBitPackingHybridEncoder(BytesUtils.getWidthFromMaxInt(maxDicId), 64 * 1024); IntIterator iterator = out.iterator(); try { while (iterator.hasNext()) { encoder.writeInt(iterator.next()); } // encodes the bit width byte[] bytesHeader = new byte[] {(byte) bitWidth}; BytesInput rleEncodedBytes = encoder.toBytes(); if (DEBUG) LOG.debug("rle encoded bytes " + rleEncodedBytes.size()); return concat(BytesInput.from(bytesHeader), rleEncodedBytes); } catch (IOException e) { throw new ParquetEncodingException("could not encode the values", e); } } return plainValuesWriter.getBytes(); }