Search in sources :

Example 1 with RowTupleSupplier

use of com.facebook.presto.spark.execution.PrestoSparkRowBatch.RowTupleSupplier in project presto by prestodb.

the class TestPrestoSparkRowBatch method getEntries.

private static List<List<Row>> getEntries(PrestoSparkRowBatch rowBatch) {
    ImmutableList.Builder<List<Row>> entries = ImmutableList.builder();
    RowTupleSupplier rowTupleSupplier = rowBatch.createRowTupleSupplier();
    while (true) {
        Tuple2<MutablePartitionId, PrestoSparkMutableRow> next = rowTupleSupplier.getNext();
        if (next == null) {
            break;
        }
        ImmutableList.Builder<Row> entry = ImmutableList.builder();
        int partition = next._1.getPartition();
        PrestoSparkMutableRow mutableRow = next._2;
        ByteBuffer buffer = mutableRow.getBuffer();
        buffer.order(LITTLE_ENDIAN);
        short rowCount = buffer.getShort();
        assertEquals(mutableRow.getPositionCount(), rowCount);
        for (int i = 0; i < rowCount; i++) {
            entry.add(new Row(partition, readRowData(buffer)));
        }
        entries.add(entry.build());
    }
    return entries.build();
}
Also used : MutablePartitionId(com.facebook.presto.spark.classloader_interface.MutablePartitionId) ImmutableList(com.google.common.collect.ImmutableList) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) RowTupleSupplier(com.facebook.presto.spark.execution.PrestoSparkRowBatch.RowTupleSupplier) ImmutableList(com.google.common.collect.ImmutableList) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) List(java.util.List) IntArrayList(it.unimi.dsi.fastutil.ints.IntArrayList) PrestoSparkMutableRow(com.facebook.presto.spark.classloader_interface.PrestoSparkMutableRow) ByteBuffer(java.nio.ByteBuffer) PrestoSparkMutableRow(com.facebook.presto.spark.classloader_interface.PrestoSparkMutableRow)

Aggregations

MutablePartitionId (com.facebook.presto.spark.classloader_interface.MutablePartitionId)1 PrestoSparkMutableRow (com.facebook.presto.spark.classloader_interface.PrestoSparkMutableRow)1 RowTupleSupplier (com.facebook.presto.spark.execution.PrestoSparkRowBatch.RowTupleSupplier)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)1 IntArrayList (it.unimi.dsi.fastutil.ints.IntArrayList)1 ByteBuffer (java.nio.ByteBuffer)1 List (java.util.List)1