@Override
 public void writeDictionaryPage(DictionaryPage dictionaryPage) throws IOException {
   if (this.dictionaryPage != null) {
     throw new ParquetEncodingException("Only one dictionary page is allowed");
   }
   BytesInput dictionaryBytes = dictionaryPage.getBytes();
   int uncompressedSize = (int) dictionaryBytes.size();
   BytesInput compressedBytes = compressor.compress(dictionaryBytes);
   this.dictionaryPage =
       new DictionaryPage(
           BytesInput.copy(compressedBytes),
           uncompressedSize,
           dictionaryPage.getDictionarySize(),
           dictionaryPage.getEncoding());
 }
 public void writeToFileWriter(ParquetFileWriter writer) throws IOException {
   writer.startColumn(path, totalValueCount, compressor.getCodecName());
   if (dictionaryPage != null) {
     writer.writeDictionaryPage(dictionaryPage);
     // tracking the dictionary encoding is handled in writeDictionaryPage
   }
   writer.writeDataPages(
       buf,
       uncompressedLength,
       compressedLength,
       totalStatistics,
       rlEncodings,
       dlEncodings,
       dataEncodings);
   writer.endColumn();
   if (LOG.isDebugEnabled()) {
     LOG.debug(
         String.format(
                 "written %,dB for %s: %,d values, %,dB raw, %,dB comp, %d pages, encodings: %s",
                 buf.size(),
                 path,
                 totalValueCount,
                 uncompressedLength,
                 compressedLength,
                 pageCount,
                 new HashSet<Encoding>(dataEncodings))
             + (dictionaryPage != null
                 ? String.format(
                     ", dic { %,d entries, %,dB raw, %,dB comp}",
                     dictionaryPage.getDictionarySize(),
                     dictionaryPage.getUncompressedSize(),
                     dictionaryPage.getDictionarySize())
                 : ""));
   }
   rlEncodings.clear();
   dlEncodings.clear();
   dataEncodings.clear();
   pageCount = 0;
 }
  public VectorizedColumnReader(ColumnDescriptor descriptor, PageReader pageReader)
      throws IOException {
    this.descriptor = descriptor;
    this.pageReader = pageReader;
    this.maxDefLevel = descriptor.getMaxDefinitionLevel();

    DictionaryPage dictionaryPage = pageReader.readDictionaryPage();
    if (dictionaryPage != null) {
      try {
        this.dictionary = dictionaryPage.getEncoding().initDictionary(descriptor, dictionaryPage);
        this.isCurrentPageDictionaryEncoded = true;
      } catch (IOException e) {
        throw new IOException("could not decode the dictionary for " + descriptor, e);
      }
    } else {
      this.dictionary = null;
      this.isCurrentPageDictionaryEncoded = false;
    }
    this.totalValueCount = pageReader.getTotalValueCount();
    if (totalValueCount == 0) {
      throw new IOException("totalValueCount == 0");
    }
  }