Search in sources :

Example 6 with BinaryRowData

use of org.apache.flink.table.data.binary.BinaryRowData in project flink by apache.

the class RowDataSerializerTest method getTestData.

@Override
protected RowData[] getTestData() {
    RowData row1 = StreamRecordUtils.row(null, 1L);
    BinaryRowData row2 = StreamRecordUtils.binaryrow(1L, null);
    return new RowData[] { row1, row2 };
}
Also used : RowData(org.apache.flink.table.data.RowData) BinaryRowData(org.apache.flink.table.data.binary.BinaryRowData) BinaryRowData(org.apache.flink.table.data.binary.BinaryRowData)

Example 7 with BinaryRowData

use of org.apache.flink.table.data.binary.BinaryRowData in project flink by apache.

the class RowDataSerializerTest method deepEqualsRowData.

private static boolean deepEqualsRowData(RowData should, RowData is, RowDataSerializer serializer1, RowDataSerializer serializer2) {
    if (should.getArity() != is.getArity()) {
        return false;
    }
    BinaryRowData row1 = serializer1.toBinaryRow(should);
    BinaryRowData row2 = serializer2.toBinaryRow(is);
    return Objects.equals(row1, row2);
}
Also used : BinaryRowData(org.apache.flink.table.data.binary.BinaryRowData)

Example 8 with BinaryRowData

use of org.apache.flink.table.data.binary.BinaryRowData in project flink by apache.

the class BaseMaterializedResultTest method createInternalBinaryRowDataConverter.

static Function<Row, BinaryRowData> createInternalBinaryRowDataConverter(DataType dataType) {
    DataStructureConverter<Object, Object> converter = DataStructureConverters.getConverter(dataType);
    RowDataSerializer serializer = new RowDataSerializer((RowType) dataType.getLogicalType());
    return row -> serializer.toBinaryRow((RowData) converter.toInternalOrNull(row)).copy();
}
Also used : DataType(org.apache.flink.table.types.DataType) List(java.util.List) RowData(org.apache.flink.table.data.RowData) DataStructureConverter(org.apache.flink.table.data.conversion.DataStructureConverter) DataStructureConverters(org.apache.flink.table.data.conversion.DataStructureConverters) RowDataSerializer(org.apache.flink.table.runtime.typeutils.RowDataSerializer) Row(org.apache.flink.types.Row) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) BinaryRowData(org.apache.flink.table.data.binary.BinaryRowData) RowType(org.apache.flink.table.types.logical.RowType) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) RowData(org.apache.flink.table.data.RowData) BinaryRowData(org.apache.flink.table.data.binary.BinaryRowData) RowDataSerializer(org.apache.flink.table.runtime.typeutils.RowDataSerializer)

Example 9 with BinaryRowData

use of org.apache.flink.table.data.binary.BinaryRowData in project flink by apache.

the class RangeUnboundedFollowingOverFrame method process.

@Override
public RowData process(int index, RowData current) throws Exception {
    boolean bufferUpdated = index == 0;
    // Ignore all the rows from the buffer for which the input row value is smaller than
    // the output row lower bound.
    ResettableExternalBuffer.BufferIterator iterator = input.newIterator(inputIndex);
    BinaryRowData nextRow = OverWindowFrame.getNextOrNull(iterator);
    while (nextRow != null && lbound.compare(nextRow, current) < 0) {
        inputIndex += 1;
        bufferUpdated = true;
        nextRow = OverWindowFrame.getNextOrNull(iterator);
    }
    return accumulateIterator(bufferUpdated, nextRow, iterator);
}
Also used : ResettableExternalBuffer(org.apache.flink.table.runtime.util.ResettableExternalBuffer) BinaryRowData(org.apache.flink.table.data.binary.BinaryRowData)

Example 10 with BinaryRowData

use of org.apache.flink.table.data.binary.BinaryRowData in project flink by apache.

the class BufferDataOverWindowOperator method processCurrentData.

private void processCurrentData() throws Exception {
    currentData.complete();
    for (OverWindowFrame frame : overWindowFrames) {
        frame.prepare(currentData);
    }
    int rowIndex = 0;
    ResettableExternalBuffer.BufferIterator bufferIterator = currentData.newIterator();
    while (bufferIterator.advanceNext()) {
        BinaryRowData currentRow = bufferIterator.getRow();
        RowData output = currentRow;
        // JoinedRowData is slow.
        for (int i = 0; i < overWindowFrames.length; i++) {
            OverWindowFrame frame = overWindowFrames[i];
            RowData value = frame.process(rowIndex, currentRow);
            output = joinedRows[i].replace(output, value);
        }
        collector.collect(output);
        rowIndex += 1;
    }
    bufferIterator.close();
    currentData.reset();
}
Also used : RowData(org.apache.flink.table.data.RowData) BinaryRowData(org.apache.flink.table.data.binary.BinaryRowData) JoinedRowData(org.apache.flink.table.data.utils.JoinedRowData) ResettableExternalBuffer(org.apache.flink.table.runtime.util.ResettableExternalBuffer) BinaryRowData(org.apache.flink.table.data.binary.BinaryRowData) OverWindowFrame(org.apache.flink.table.runtime.operators.over.frame.OverWindowFrame)

Aggregations

BinaryRowData (org.apache.flink.table.data.binary.BinaryRowData)173 Test (org.junit.Test)81 BinaryRowWriter (org.apache.flink.table.data.writer.BinaryRowWriter)54 RowData (org.apache.flink.table.data.RowData)31 ArrayList (java.util.ArrayList)30 MemoryManager (org.apache.flink.runtime.memory.MemoryManager)22 UniformBinaryRowGenerator (org.apache.flink.table.runtime.util.UniformBinaryRowGenerator)21 JoinedRowData (org.apache.flink.table.data.utils.JoinedRowData)16 MemorySegment (org.apache.flink.core.memory.MemorySegment)15 MutableObjectIterator (org.apache.flink.util.MutableObjectIterator)14 GenericRowData (org.apache.flink.table.data.GenericRowData)13 Random (java.util.Random)12 BinaryRowDataSerializer (org.apache.flink.table.runtime.typeutils.BinaryRowDataSerializer)12 HashMap (java.util.HashMap)9 RowDataSerializer (org.apache.flink.table.runtime.typeutils.RowDataSerializer)9 Map (java.util.Map)7 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)7 StreamOperator (org.apache.flink.streaming.api.operators.StreamOperator)7 RandomAccessInputView (org.apache.flink.runtime.io.disk.RandomAccessInputView)6 StreamRecord (org.apache.flink.streaming.runtime.streamrecord.StreamRecord)6