Search in sources :

Example 21 with BinaryArrayData

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

the class ArrayObjectArrayConverter method open.

@Override
public void open(ClassLoader classLoader) {
    reuseArray = new BinaryArrayData();
    reuseWriter = new BinaryArrayWriter(reuseArray, 0, elementSize);
    elementConverter.open(classLoader);
}
Also used : BinaryArrayWriter(org.apache.flink.table.data.writer.BinaryArrayWriter) BinaryArrayData(org.apache.flink.table.data.binary.BinaryArrayData)

Example 22 with BinaryArrayData

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

the class ArrayDataSerializer method serialize.

@Override
public void serialize(ArrayData record, DataOutputView target) throws IOException {
    BinaryArrayData binaryArray = toBinaryArray(record);
    target.writeInt(binaryArray.getSizeInBytes());
    BinarySegmentUtils.copyToView(binaryArray.getSegments(), binaryArray.getOffset(), binaryArray.getSizeInBytes(), target);
}
Also used : BinaryArrayData(org.apache.flink.table.data.binary.BinaryArrayData)

Example 23 with BinaryArrayData

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

the class ArrayDataSerializer method toBinaryArray.

public BinaryArrayData toBinaryArray(ArrayData from) {
    if (from instanceof BinaryArrayData) {
        return (BinaryArrayData) from;
    }
    int numElements = from.size();
    if (reuseArray == null) {
        reuseArray = new BinaryArrayData();
    }
    if (reuseWriter == null || reuseWriter.getNumElements() != numElements) {
        reuseWriter = new BinaryArrayWriter(reuseArray, numElements, BinaryArrayData.calculateFixLengthPartSize(eleType));
    } else {
        reuseWriter.reset();
    }
    for (int i = 0; i < numElements; i++) {
        if (from.isNullAt(i)) {
            reuseWriter.setNullAt(i, eleType);
        } else {
            BinaryWriter.write(reuseWriter, i, elementGetter.getElementOrNull(from, i), eleType, eleSer);
        }
    }
    reuseWriter.complete();
    return reuseArray;
}
Also used : BinaryArrayWriter(org.apache.flink.table.data.writer.BinaryArrayWriter) BinaryArrayData(org.apache.flink.table.data.binary.BinaryArrayData)

Example 24 with BinaryArrayData

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

the class MapDataSerializerTest method createArray.

private static BinaryArrayData createArray(int... vs) {
    BinaryArrayData array = new BinaryArrayData();
    BinaryArrayWriter writer = new BinaryArrayWriter(array, vs.length, 4);
    for (int i = 0; i < vs.length; i++) {
        writer.writeInt(i, vs[i]);
    }
    writer.complete();
    return array;
}
Also used : BinaryArrayWriter(org.apache.flink.table.data.writer.BinaryArrayWriter) BinaryArrayData(org.apache.flink.table.data.binary.BinaryArrayData)

Example 25 with BinaryArrayData

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

the class RowDataSerializerTest method createArray.

// ----------------------------------------------------------------------------------------------
private static BinaryArrayData createArray(int... ints) {
    BinaryArrayData array = new BinaryArrayData();
    BinaryArrayWriter writer = new BinaryArrayWriter(array, ints.length, 4);
    for (int i = 0; i < ints.length; i++) {
        writer.writeInt(i, ints[i]);
    }
    writer.complete();
    return array;
}
Also used : BinaryArrayWriter(org.apache.flink.table.data.writer.BinaryArrayWriter) BinaryArrayData(org.apache.flink.table.data.binary.BinaryArrayData)

Aggregations

BinaryArrayData (org.apache.flink.table.data.binary.BinaryArrayData)27 BinaryArrayWriter (org.apache.flink.table.data.writer.BinaryArrayWriter)19 Test (org.junit.Test)11 BinaryRowData (org.apache.flink.table.data.binary.BinaryRowData)7 BinaryMapData (org.apache.flink.table.data.binary.BinaryMapData)5 BinaryRowWriter (org.apache.flink.table.data.writer.BinaryRowWriter)5 MemorySegment (org.apache.flink.core.memory.MemorySegment)3 ArrayDataSerializer (org.apache.flink.table.runtime.typeutils.ArrayDataSerializer)3 MapDataSerializer (org.apache.flink.table.runtime.typeutils.MapDataSerializer)3 BigDecimal (java.math.BigDecimal)2 IntType (org.apache.flink.table.types.logical.IntType)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 QuickSort (org.apache.flink.runtime.operators.sort.QuickSort)1 ArrayData (org.apache.flink.table.data.ArrayData)1 GenericMapData (org.apache.flink.table.data.GenericMapData)1 GenericRowData (org.apache.flink.table.data.GenericRowData)1 MapData (org.apache.flink.table.data.MapData)1 RawValueData (org.apache.flink.table.data.RawValueData)1 RowData (org.apache.flink.table.data.RowData)1