Search in sources :

Example 6 with StreamDataOutput

use of com.facebook.presto.orc.stream.StreamDataOutput in project presto by prestodb.

the class TestLongDictionaryProvider method createSliceOutput.

private DynamicSliceOutput createSliceOutput(StreamId streamId, long[] data) {
    LongOutputStreamDwrf outputStream = new LongOutputStreamDwrf(getColumnWriterOptions(), Optional.empty(), true, DICTIONARY_DATA);
    for (long val : data) {
        outputStream.writeLong(val);
    }
    outputStream.close();
    DynamicSliceOutput sliceOutput = new DynamicSliceOutput(1000);
    StreamDataOutput streamDataOutput = outputStream.getStreamDataOutput(streamId.getColumn());
    streamDataOutput.writeData(sliceOutput);
    return sliceOutput;
}
Also used : LongOutputStreamDwrf(com.facebook.presto.orc.stream.LongOutputStreamDwrf) DynamicSliceOutput(io.airlift.slice.DynamicSliceOutput) StreamDataOutput(com.facebook.presto.orc.stream.StreamDataOutput)

Example 7 with StreamDataOutput

use of com.facebook.presto.orc.stream.StreamDataOutput in project presto by prestodb.

the class TestStreamLayout method testByStreamSize.

@Test
public void testByStreamSize() {
    List<StreamDataOutput> streams = new ArrayList<>();
    int length = 10_000;
    for (int i = 0; i < 10; i++) {
        streams.add(createStream(i, StreamKind.PRESENT, length - i));
        streams.add(createStream(i, StreamKind.DATA, length - 100 - i));
    }
    Collections.shuffle(streams);
    new ByStreamSize().reorder(streams);
    assertEquals(streams.size(), 20);
    Iterator<StreamDataOutput> iterator = streams.iterator();
    for (int i = 9; i >= 0; i--) {
        verifyStream(iterator.next().getStream(), i, StreamKind.DATA, length - 100 - i);
    }
    for (int i = 9; i >= 0; i--) {
        verifyStream(iterator.next().getStream(), i, StreamKind.PRESENT, length - i);
    }
    assertFalse(iterator.hasNext());
}
Also used : ByStreamSize(com.facebook.presto.orc.writer.StreamLayout.ByStreamSize) ArrayList(java.util.ArrayList) StreamDataOutput(com.facebook.presto.orc.stream.StreamDataOutput) Test(org.testng.annotations.Test)

Example 8 with StreamDataOutput

use of com.facebook.presto.orc.stream.StreamDataOutput in project presto by prestodb.

the class FloatColumnWriter method getIndexStreams.

@Override
public List<StreamDataOutput> getIndexStreams() throws IOException {
    checkState(closed);
    ImmutableList.Builder<RowGroupIndex> rowGroupIndexes = ImmutableList.builder();
    List<FloatStreamCheckpoint> dataCheckpoints = dataStream.getCheckpoints();
    Optional<List<BooleanStreamCheckpoint>> presentCheckpoints = presentStream.getCheckpoints();
    for (int i = 0; i < rowGroupColumnStatistics.size(); i++) {
        int groupId = i;
        ColumnStatistics columnStatistics = rowGroupColumnStatistics.get(groupId);
        FloatStreamCheckpoint dataCheckpoint = dataCheckpoints.get(groupId);
        Optional<BooleanStreamCheckpoint> presentCheckpoint = presentCheckpoints.map(checkpoints -> checkpoints.get(groupId));
        List<Integer> positions = createFloatColumnPositionList(compressed, dataCheckpoint, presentCheckpoint);
        rowGroupIndexes.add(new RowGroupIndex(positions, columnStatistics));
    }
    Slice slice = metadataWriter.writeRowIndexes(rowGroupIndexes.build());
    Stream stream = new Stream(column, StreamKind.ROW_INDEX, slice.length(), false);
    return ImmutableList.of(new StreamDataOutput(slice, stream));
}
Also used : ColumnStatistics(com.facebook.presto.orc.metadata.statistics.ColumnStatistics) BooleanStreamCheckpoint(com.facebook.presto.orc.checkpoint.BooleanStreamCheckpoint) ImmutableList(com.google.common.collect.ImmutableList) FloatStreamCheckpoint(com.facebook.presto.orc.checkpoint.FloatStreamCheckpoint) StreamDataOutput(com.facebook.presto.orc.stream.StreamDataOutput) FloatStreamCheckpoint(com.facebook.presto.orc.checkpoint.FloatStreamCheckpoint) BooleanStreamCheckpoint(com.facebook.presto.orc.checkpoint.BooleanStreamCheckpoint) RowGroupIndex(com.facebook.presto.orc.metadata.RowGroupIndex) Slice(io.airlift.slice.Slice) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) PresentOutputStream(com.facebook.presto.orc.stream.PresentOutputStream) FloatOutputStream(com.facebook.presto.orc.stream.FloatOutputStream) Stream(com.facebook.presto.orc.metadata.Stream)

Example 9 with StreamDataOutput

use of com.facebook.presto.orc.stream.StreamDataOutput in project presto by prestodb.

the class StructColumnWriter method getIndexStreams.

@Override
public List<StreamDataOutput> getIndexStreams() throws IOException {
    checkState(closed);
    ImmutableList.Builder<RowGroupIndex> rowGroupIndexes = ImmutableList.builder();
    Optional<List<BooleanStreamCheckpoint>> presentCheckpoints = presentStream.getCheckpoints();
    for (int i = 0; i < rowGroupColumnStatistics.size(); i++) {
        int groupId = i;
        ColumnStatistics columnStatistics = rowGroupColumnStatistics.get(groupId);
        Optional<BooleanStreamCheckpoint> presentCheckpoint = presentCheckpoints.map(checkpoints -> checkpoints.get(groupId));
        List<Integer> positions = createStructColumnPositionList(compressed, presentCheckpoint);
        rowGroupIndexes.add(new RowGroupIndex(positions, columnStatistics));
    }
    Slice slice = metadataWriter.writeRowIndexes(rowGroupIndexes.build());
    Stream stream = new Stream(column, StreamKind.ROW_INDEX, slice.length(), false);
    ImmutableList.Builder<StreamDataOutput> indexStreams = ImmutableList.builder();
    indexStreams.add(new StreamDataOutput(slice, stream));
    for (ColumnWriter structField : structFields) {
        indexStreams.addAll(structField.getIndexStreams());
    }
    return indexStreams.build();
}
Also used : ColumnStatistics(com.facebook.presto.orc.metadata.statistics.ColumnStatistics) BooleanStreamCheckpoint(com.facebook.presto.orc.checkpoint.BooleanStreamCheckpoint) ImmutableList(com.google.common.collect.ImmutableList) StreamDataOutput(com.facebook.presto.orc.stream.StreamDataOutput) BooleanStreamCheckpoint(com.facebook.presto.orc.checkpoint.BooleanStreamCheckpoint) RowGroupIndex(com.facebook.presto.orc.metadata.RowGroupIndex) Slice(io.airlift.slice.Slice) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) PresentOutputStream(com.facebook.presto.orc.stream.PresentOutputStream) Stream(com.facebook.presto.orc.metadata.Stream)

Example 10 with StreamDataOutput

use of com.facebook.presto.orc.stream.StreamDataOutput in project presto by prestodb.

the class LongColumnWriter method getIndexStreams.

@Override
public List<StreamDataOutput> getIndexStreams() throws IOException {
    checkState(closed);
    ImmutableList.Builder<RowGroupIndex> rowGroupIndexes = ImmutableList.builder();
    List<LongStreamCheckpoint> dataCheckpoints = dataStream.getCheckpoints();
    Optional<List<BooleanStreamCheckpoint>> presentCheckpoints = presentStream.getCheckpoints();
    for (int i = 0; i < rowGroupColumnStatistics.size(); i++) {
        int groupId = i;
        ColumnStatistics columnStatistics = rowGroupColumnStatistics.get(groupId);
        LongStreamCheckpoint dataCheckpoint = dataCheckpoints.get(groupId);
        Optional<BooleanStreamCheckpoint> presentCheckpoint = presentCheckpoints.map(checkpoints -> checkpoints.get(groupId));
        List<Integer> positions = createLongColumnPositionList(compressed, dataCheckpoint, presentCheckpoint);
        rowGroupIndexes.add(new RowGroupIndex(positions, columnStatistics));
    }
    Slice slice = metadataWriter.writeRowIndexes(rowGroupIndexes.build());
    Stream stream = new Stream(column, StreamKind.ROW_INDEX, slice.length(), false);
    return ImmutableList.of(new StreamDataOutput(slice, stream));
}
Also used : ColumnStatistics(com.facebook.presto.orc.metadata.statistics.ColumnStatistics) BooleanStreamCheckpoint(com.facebook.presto.orc.checkpoint.BooleanStreamCheckpoint) ImmutableList(com.google.common.collect.ImmutableList) StreamDataOutput(com.facebook.presto.orc.stream.StreamDataOutput) LongStreamCheckpoint(com.facebook.presto.orc.checkpoint.LongStreamCheckpoint) LongStreamCheckpoint(com.facebook.presto.orc.checkpoint.LongStreamCheckpoint) BooleanStreamCheckpoint(com.facebook.presto.orc.checkpoint.BooleanStreamCheckpoint) RowGroupIndex(com.facebook.presto.orc.metadata.RowGroupIndex) Slice(io.airlift.slice.Slice) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) PresentOutputStream(com.facebook.presto.orc.stream.PresentOutputStream) LongOutputStream(com.facebook.presto.orc.stream.LongOutputStream) Stream(com.facebook.presto.orc.metadata.Stream)

Aggregations

StreamDataOutput (com.facebook.presto.orc.stream.StreamDataOutput)18 ArrayList (java.util.ArrayList)16 Slice (io.airlift.slice.Slice)14 Stream (com.facebook.presto.orc.metadata.Stream)13 ColumnStatistics (com.facebook.presto.orc.metadata.statistics.ColumnStatistics)13 ImmutableList (com.google.common.collect.ImmutableList)13 List (java.util.List)13 BooleanStreamCheckpoint (com.facebook.presto.orc.checkpoint.BooleanStreamCheckpoint)12 RowGroupIndex (com.facebook.presto.orc.metadata.RowGroupIndex)12 PresentOutputStream (com.facebook.presto.orc.stream.PresentOutputStream)12 LongStreamCheckpoint (com.facebook.presto.orc.checkpoint.LongStreamCheckpoint)7 LongOutputStream (com.facebook.presto.orc.stream.LongOutputStream)7 LongOutputStream.createLengthOutputStream (com.facebook.presto.orc.stream.LongOutputStream.createLengthOutputStream)3 Slices.utf8Slice (io.airlift.slice.Slices.utf8Slice)2 Collectors.toList (java.util.stream.Collectors.toList)2 Page (com.facebook.presto.common.Page)1 BlockBuilder (com.facebook.presto.common.block.BlockBuilder)1 DataOutput (com.facebook.presto.common.io.DataOutput)1 DataOutput.createDataOutput (com.facebook.presto.common.io.DataOutput.createDataOutput)1 DataSink (com.facebook.presto.common.io.DataSink)1