use of com.facebook.presto.orc.stream.ByteArrayStream in project presto by prestodb.
the class SliceDictionaryStreamReader method openRowGroup.
private void openRowGroup(Type type) throws IOException {
// read the dictionary
if (!stripeDictionaryOpen) {
// We must always create a new dictionary array because the previous dictionary may still be referenced
// add one extra entry for null
stripeDictionary = new Slice[stripeDictionarySize + 1];
if (stripeDictionarySize > 0) {
int[] dictionaryLength = new int[stripeDictionarySize];
// read the lengths
LongStream lengthStream = stripeDictionaryLengthStreamSource.openStream();
if (lengthStream == null) {
throw new OrcCorruptionException("Dictionary is not empty but dictionary length stream is not present");
}
lengthStream.nextIntVector(stripeDictionarySize, dictionaryLength);
// read dictionary values
ByteArrayStream dictionaryDataStream = stripeDictionaryDataStreamSource.openStream();
readDictionary(dictionaryDataStream, stripeDictionarySize, dictionaryLength, 0, stripeDictionary, type);
}
}
stripeDictionaryOpen = true;
// read row group dictionary
RowGroupDictionaryLengthStream dictionaryLengthStream = rowGroupDictionaryLengthStreamSource.openStream();
if (dictionaryLengthStream != null) {
int rowGroupDictionarySize = dictionaryLengthStream.getEntryCount();
// We must always create a new dictionary array because the previous dictionary may still be referenced
// The first elements of the dictionary are from the stripe dictionary, then the row group dictionary elements, and then a null
rowGroupDictionary = Arrays.copyOf(stripeDictionary, stripeDictionarySize + rowGroupDictionarySize + 1);
setDictionaryBlockData(rowGroupDictionary);
// resize the dictionary lengths array if necessary
if (rowGroupDictionaryLength.length < rowGroupDictionarySize) {
rowGroupDictionaryLength = new int[rowGroupDictionarySize];
}
// read the lengths
dictionaryLengthStream.nextIntVector(rowGroupDictionarySize, rowGroupDictionaryLength);
// read dictionary values
ByteArrayStream dictionaryDataStream = rowGroupDictionaryDataStreamSource.openStream();
readDictionary(dictionaryDataStream, rowGroupDictionarySize, rowGroupDictionaryLength, stripeDictionarySize, rowGroupDictionary, type);
} else {
// there is no row group dictionary so use the stripe dictionary
setDictionaryBlockData(stripeDictionary);
}
presentStream = presentStreamSource.openStream();
inDictionaryStream = inDictionaryStreamSource.openStream();
dataStream = dataStreamSource.openStream();
rowGroupOpen = true;
}
Aggregations