/** * {@inheritDoc} * @see org.apache.parquet.column.ColumnReader#consume() */ @Override public void consume() { checkRead(); valueRead = false; }
/** * {@inheritDoc} * @see org.apache.parquet.column.ColumnReader#getBoolean() */ @Override public boolean getBoolean() { readValue(); return this.binding.getBoolean(); }
private void checkRead() { int rl, dl; int skipValues = 0; for (;;) { if (isPageFullyConsumed()) { if (isFullyConsumed()) { LOG.debug("end reached"); repetitionLevel = 0; // the next repetition level return; } readPage(); skipValues = 0; } rl = repetitionLevelColumn.nextInt(); dl = definitionLevelColumn.nextInt(); ++readValues; if (!skipRL(rl)) { break; } if (dl == maxDefinitionLevel) { ++skipValues; } } binding.skip(skipValues); repetitionLevel = rl; definitionLevel = dl; }
private void readPageV2(DataPageV2 page) { this.repetitionLevelColumn = newRLEIterator(path.getMaxRepetitionLevel(), page.getRepetitionLevels()); this.definitionLevelColumn = newRLEIterator(path.getMaxDefinitionLevel(), page.getDefinitionLevels()); int valueCount = page.getValueCount(); LOG.debug("page data size {} bytes and {} values", page.getData().size(), valueCount); try { initDataReader(page.getDataEncoding(), page.getData().toInputStream(), valueCount); } catch (IOException e) { throw new ParquetDecodingException("could not read page " + page + " in col " + path, e); } newPageInitialized(page); }
private void readPageV1(DataPageV1 page) { ValuesReader rlReader = page.getRlEncoding().getValuesReader(path, REPETITION_LEVEL); ValuesReader dlReader = page.getDlEncoding().getValuesReader(path, DEFINITION_LEVEL); this.repetitionLevelColumn = new ValuesReaderIntIterator(rlReader); this.definitionLevelColumn = new ValuesReaderIntIterator(dlReader); int valueCount = page.getValueCount(); try { BytesInput bytes = page.getBytes(); LOG.debug("page size {} bytes and {} values", bytes.size(), valueCount); LOG.debug("reading repetition levels at 0"); ByteBufferInputStream in = bytes.toInputStream(); rlReader.initFromPage(valueCount, in); LOG.debug("reading definition levels at {}", in.position()); dlReader.initFromPage(valueCount, in); LOG.debug("reading data at {}", in.position()); initDataReader(page.getValueEncoding(), in, valueCount); } catch (IOException e) { throw new ParquetDecodingException("could not read page " + page + " in col " + path, e); } newPageInitialized(page); }
private void initDataReader(Encoding dataEncoding, ByteBufferInputStream in, int valueCount) { ValuesReader previousReader = this.dataColumn; this.currentEncoding = dataEncoding; this.pageValueCount = valueCount; this.endOfPageValueCount = readValues + pageValueCount; if (dataEncoding.usesDictionary()) { if (dictionary == null) { throw new ParquetDecodingException( "could not read page in col " + path + " as the dictionary was missing for encoding " + dataEncoding); } this.dataColumn = dataEncoding.getDictionaryBasedValuesReader(path, VALUES, dictionary); } else { this.dataColumn = dataEncoding.getValuesReader(path, VALUES); } if (dataEncoding.usesDictionary() && converter.hasDictionarySupport()) { bindToDictionary(dictionary); } else { bind(path.getType()); } try { dataColumn.initFromPage(pageValueCount, in); } catch (IOException e) { throw new ParquetDecodingException("could not read page in col " + path, e); } if (CorruptDeltaByteArrays.requiresSequentialReads(writerVersion, dataEncoding) && previousReader != null && previousReader instanceof RequiresPreviousReader) { // previous reader can only be set if reading sequentially ((RequiresPreviousReader) dataColumn).setPreviousReader(previousReader); } }
/** * {@inheritDoc} * @see org.apache.parquet.column.ColumnReader#getInteger() */ @Override public int getInteger() { readValue(); return this.binding.getInteger(); }
/** * {@inheritDoc} * @see org.apache.parquet.column.ColumnReader#getLong() */ @Override public long getLong() { readValue(); return this.binding.getLong(); }
/** * {@inheritDoc} * @see org.apache.parquet.column.ColumnReader#writeCurrentValueToConverter() */ @Override public void writeCurrentValueToConverter() { readValue(); this.binding.writeValue(); }
@Override public int getCurrentValueDictionaryID() { readValue(); return binding.getDictionaryId(); }
/** * {@inheritDoc} * @see org.apache.parquet.column.ColumnReader#getDouble() */ @Override public double getDouble() { readValue(); return this.binding.getDouble(); }
/** * {@inheritDoc} * @see org.apache.parquet.column.ColumnReader#getBinary() */ @Override public Binary getBinary() { readValue(); return this.binding.getBinary(); }
/** * {@inheritDoc} * @see org.apache.parquet.column.ColumnReader#getFloat() */ @Override public float getFloat() { readValue(); return this.binding.getFloat(); }