Search in sources :

Example 1 with LongInputStream

use of io.prestosql.orc.stream.LongInputStream in project hetu-core by openlookeng.

the class SliceDictionaryColumnReader method openRowGroup.

private void openRowGroup() throws IOException {
    // read the dictionary
    if (!dictionaryOpen) {
        if (dictionarySize > 0) {
            // resize the dictionary lengths array if necessary
            if (dictionaryLength.length < dictionarySize) {
                dictionaryLength = new int[dictionarySize];
            }
            // read the lengths
            LongInputStream lengthStream = dictionaryLengthStreamSource.openStream();
            if (lengthStream == null) {
                throw new OrcCorruptionException(column.getOrcDataSourceId(), "Dictionary is not empty but dictionary length stream is missing");
            }
            lengthStream.next(dictionaryLength, dictionarySize);
            long dataLength = 0;
            for (int i = 0; i < dictionarySize; i++) {
                dataLength += dictionaryLength[i];
            }
            // we must always create a new dictionary array because the previous dictionary may still be referenced
            dictionaryData = new byte[toIntExact(dataLength)];
            // add one extra entry for null
            dictionaryOffsetVector = new int[dictionarySize + 2];
            // read dictionary values
            ByteArrayInputStream dictionaryDataStream = dictionaryDataStreamSource.openStream();
            readDictionary(dictionaryDataStream, dictionarySize, dictionaryLength, 0, dictionaryData, dictionaryOffsetVector, maxCodePointCount, isCharType);
        } else {
            dictionaryData = EMPTY_DICTIONARY_DATA;
            dictionaryOffsetVector = EMPTY_DICTIONARY_OFFSETS;
        }
    }
    dictionaryOpen = true;
    setDictionaryBlockData(dictionaryData, dictionaryOffsetVector, dictionarySize + 1);
    presentStream = presentStreamSource.openStream();
    dataStream = dataStreamSource.openStream();
    rowGroupOpen = true;
}
Also used : ByteArrayInputStream(io.prestosql.orc.stream.ByteArrayInputStream) OrcCorruptionException(io.prestosql.orc.OrcCorruptionException) LongInputStream(io.prestosql.orc.stream.LongInputStream)

Example 2 with LongInputStream

use of io.prestosql.orc.stream.LongInputStream in project hetu-core by openlookeng.

the class SliceDictionarySelectiveColumnReader method openRowGroup.

private void openRowGroup() throws IOException {
    // read the dictionary
    if (!stripeDictionaryOpen) {
        if (stripeDictionarySize > 0) {
            // resize the dictionary lengths array if necessary
            if (stripeDictionaryLength.length < stripeDictionarySize) {
                stripeDictionaryLength = new int[stripeDictionarySize];
            }
            // read the lengths
            LongInputStream lengthStream = stripeDictionaryLengthStreamSource.openStream();
            if (lengthStream == null) {
                throw new OrcCorruptionException(streamDescriptor.getOrcDataSourceId(), "Dictionary is not empty but dictionary length stream is not present");
            }
            lengthStream.nextIntVector(stripeDictionarySize, stripeDictionaryLength, 0);
            long dataLength = 0;
            for (int i = 0; i < stripeDictionarySize; i++) {
                dataLength += stripeDictionaryLength[i];
            }
            // we must always create a new dictionary array because the previous dictionary may still be referenced
            stripeDictionaryData = new byte[toIntExact(dataLength)];
            // add one extra entry for null
            stripeDictionaryOffsetVector = new int[stripeDictionarySize + 2];
            // read dictionary values
            ByteArrayInputStream dictionaryDataStream = stripeDictionaryDataStreamSource.openStream();
            readDictionary(dictionaryDataStream, stripeDictionarySize, stripeDictionaryLength, 0, stripeDictionaryData, stripeDictionaryOffsetVector, maxCodePointCount, isCharType);
        } else {
            stripeDictionaryData = EMPTY_DICTIONARY_DATA;
            stripeDictionaryOffsetVector = EMPTY_DICTIONARY_OFFSETS;
        }
    }
    stripeDictionaryOpen = true;
    // there is no row group dictionary so use the stripe dictionary
    setDictionaryBlockData(stripeDictionaryData, stripeDictionaryOffsetVector, stripeDictionarySize + 1);
    presentStream = presentStreamSource.openStream();
    dataStream = dataStreamSource.openStream();
    rowGroupOpen = true;
}
Also used : ByteArrayInputStream(io.prestosql.orc.stream.ByteArrayInputStream) OrcCorruptionException(io.prestosql.orc.OrcCorruptionException) LongInputStream(io.prestosql.orc.stream.LongInputStream)

Aggregations

OrcCorruptionException (io.prestosql.orc.OrcCorruptionException)2 ByteArrayInputStream (io.prestosql.orc.stream.ByteArrayInputStream)2 LongInputStream (io.prestosql.orc.stream.LongInputStream)2