use of org.apache.inlong.sort.formats.common.DoubleFormatInfo in project incubator-inlong by apache.
the class RowToJsonKafkaSinkTest method prepareData.
@Override
protected void prepareData() throws IOException, ClassNotFoundException {
topic = "test_kafka_row_to_json";
serializationSchema = SerializationSchemaFactory.build(new FieldInfo[] { new FieldInfo("f1", new StringFormatInfo()), new FieldInfo("f2", new MapFormatInfo(new StringFormatInfo(), new DoubleFormatInfo())), new FieldInfo("f3", new ArrayFormatInfo(new IntFormatInfo())) }, new JsonSerializationInfo());
prepareTestRows();
}
use of org.apache.inlong.sort.formats.common.DoubleFormatInfo in project incubator-inlong by apache.
the class RowToStringKafkaSinkTest method prepareData.
@Override
protected void prepareData() throws IOException, ClassNotFoundException {
topic = "test_kafka_row_to_string";
serializationSchema = SerializationSchemaFactory.build(new FieldInfo[] { new FieldInfo("f1", new StringFormatInfo()), new FieldInfo("f2", new DoubleFormatInfo()) }, null);
testRows = new ArrayList<>();
testRows.add(Row.of("f1", 12.0));
testRows.add(Row.of("f2", 12.1));
testRows.add(Row.of("f3", 12.3));
}
use of org.apache.inlong.sort.formats.common.DoubleFormatInfo in project incubator-inlong by apache.
the class RowToAvroKafkaSinkTest method prepareData.
@Override
protected void prepareData() throws IOException, ClassNotFoundException {
fieldInfos = new FieldInfo[] { new FieldInfo("f1", new StringFormatInfo()), new FieldInfo("f2", new IntFormatInfo()), new FieldInfo("f3", new NullFormatInfo()), new FieldInfo("f4", new BinaryFormatInfo()), new FieldInfo("f5", new MapFormatInfo(new StringFormatInfo(), new RowFormatInfo(new String[] { "f51", "f52" }, new FormatInfo[] { new IntFormatInfo(), new ArrayFormatInfo(new DoubleFormatInfo()) }))) };
topic = "test_kafka_row_to_avro";
serializationSchema = SerializationSchemaFactory.build(fieldInfos, new AvroSerializationInfo());
prepareTestRows();
}
use of org.apache.inlong.sort.formats.common.DoubleFormatInfo in project incubator-inlong by apache.
the class TableFormatUtils method deriveLogicalType.
/**
* Derive the LogicalType for the given FormatInfo.
*/
public static LogicalType deriveLogicalType(FormatInfo formatInfo) {
if (formatInfo instanceof StringFormatInfo) {
return new VarCharType();
} else if (formatInfo instanceof BooleanFormatInfo) {
return new BooleanType();
} else if (formatInfo instanceof ByteFormatInfo) {
return new TinyIntType();
} else if (formatInfo instanceof ShortFormatInfo) {
return new SmallIntType();
} else if (formatInfo instanceof IntFormatInfo) {
return new IntType();
} else if (formatInfo instanceof LongFormatInfo) {
return new BigIntType();
} else if (formatInfo instanceof FloatFormatInfo) {
return new FloatType();
} else if (formatInfo instanceof DoubleFormatInfo) {
return new DoubleType();
} else if (formatInfo instanceof DecimalFormatInfo) {
return new DecimalType();
} else if (formatInfo instanceof TimeFormatInfo) {
return new TimeType();
} else if (formatInfo instanceof DateFormatInfo) {
return new DateType();
} else if (formatInfo instanceof TimestampFormatInfo) {
return new TimestampType(DEFAULT_PRECISION_FOR_TIMESTAMP);
} else if (formatInfo instanceof LocalZonedTimestampFormatInfo) {
return new LocalZonedTimestampType();
} else if (formatInfo instanceof ArrayFormatInfo) {
FormatInfo elementFormatInfo = ((ArrayFormatInfo) formatInfo).getElementFormatInfo();
return new ArrayType(deriveLogicalType(elementFormatInfo));
} else if (formatInfo instanceof MapFormatInfo) {
MapFormatInfo mapFormatInfo = (MapFormatInfo) formatInfo;
FormatInfo keyFormatInfo = mapFormatInfo.getKeyFormatInfo();
FormatInfo valueFormatInfo = mapFormatInfo.getValueFormatInfo();
return new MapType(deriveLogicalType(keyFormatInfo), deriveLogicalType(valueFormatInfo));
} else if (formatInfo instanceof RowFormatInfo) {
RowFormatInfo rowFormatInfo = (RowFormatInfo) formatInfo;
FormatInfo[] formatInfos = rowFormatInfo.getFieldFormatInfos();
int formatInfosSize = formatInfos.length;
LogicalType[] logicalTypes = new LogicalType[formatInfosSize];
for (int i = 0; i < formatInfosSize; ++i) {
logicalTypes[i] = deriveLogicalType(formatInfos[i]);
}
return RowType.of(logicalTypes, rowFormatInfo.getFieldNames());
} else if (formatInfo instanceof BinaryFormatInfo) {
return new BinaryType();
} else if (formatInfo instanceof NullFormatInfo) {
return new NullType();
} else {
throw new UnsupportedOperationException();
}
}
Aggregations