@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());
 }
예제 #2
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");
    }
  }