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);
}
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);
}
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;
}
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;
}
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;
}
Aggregations