use of org.apache.inlong.sort.util.TestingUtils.EmptySourceInfo in project incubator-inlong by apache.
the class MultiTenancyInLongMsgMixedDeserializerTest method testIsInLongMsgDataFlow.
@Test
public void testIsInLongMsgDataFlow() {
final TubeSourceInfo tubeSourceInfo = new TubeSourceInfo("topic", "address", null, new InLongMsgCsvDeserializationInfo("tid", ',', false), new FieldInfo[0]);
final EmptySinkInfo sinkInfo = new EmptySinkInfo();
final DataFlowInfo dataFlowInfo = new DataFlowInfo(1L, tubeSourceInfo, sinkInfo);
assertTrue(MultiTenancyInLongMsgMixedDeserializer.isInLongMsgDataFlow(dataFlowInfo));
final DataFlowInfo nonInLongMsgDataFlow = new DataFlowInfo(2L, new EmptySourceInfo(), sinkInfo);
assertFalse(MultiTenancyInLongMsgMixedDeserializer.isInLongMsgDataFlow(nonInLongMsgDataFlow));
}
use of org.apache.inlong.sort.util.TestingUtils.EmptySourceInfo in project incubator-inlong by apache.
the class RecordTransformerTest method testRecordMatchSerializer.
@Test
public void testRecordMatchSerializer() throws Exception {
final int bufferSize = 1024;
final RecordTransformer transformer = new RecordTransformer(bufferSize);
final FieldInfo field1 = new FieldInfo("field1", new LongFormatInfo());
final FieldInfo field2 = new FieldInfo("field2", new StringFormatInfo());
final TestingSinkInfo sinkInfo = new TestingSinkInfo(new FieldInfo[] { field1, field2 });
final DataFlowInfo dataFlowInfo = new DataFlowInfo(1L, new EmptySourceInfo(), sinkInfo);
transformer.addDataFlow(dataFlowInfo);
Map<Long, RowSerializer> rowSerializers = transformer.getRowSerializers();
final Row row = new Row(2);
row.setField(0, 1024L);
row.setField(1, "9527");
final Record record = new Record(1L, System.currentTimeMillis(), row);
assertSame(record, transformer.matchRecordAndSerializerField(record, rowSerializers.get(1L)));
}
use of org.apache.inlong.sort.util.TestingUtils.EmptySourceInfo in project incubator-inlong by apache.
the class RecordTransformerTest method testRecordNotMatchSerializer.
@Test
public void testRecordNotMatchSerializer() throws Exception {
final int bufferSize = 1024;
final RecordTransformer transformer = new RecordTransformer(bufferSize);
final FieldInfo field1 = new FieldInfo("field1", new LongFormatInfo());
final FieldInfo field2 = new FieldInfo("field2", new StringFormatInfo());
final TestingSinkInfo sinkInfo = new TestingSinkInfo(new FieldInfo[] { field1, field2 });
final DataFlowInfo dataFlowInfo = new DataFlowInfo(1L, new EmptySourceInfo(), sinkInfo);
transformer.addDataFlow(dataFlowInfo);
Map<Long, RowSerializer> rowSerializers = transformer.getRowSerializers();
final Row oneFieldRow = new Row(1);
oneFieldRow.setField(0, 1024L);
final Record oneFieldRecord = new Record(1L, System.currentTimeMillis(), oneFieldRow);
assertEquals(2, transformer.matchRecordAndSerializerField(oneFieldRecord, rowSerializers.get(1L)).getRow().getArity());
final Row threeFieldRow = new Row(3);
threeFieldRow.setField(0, 1024L);
threeFieldRow.setField(1, "9527");
threeFieldRow.setField(2, 2048);
final Record threeFieldRecord = new Record(1L, System.currentTimeMillis(), threeFieldRow);
assertEquals(2, transformer.matchRecordAndSerializerField(threeFieldRecord, rowSerializers.get(1L)).getRow().getArity());
}
use of org.apache.inlong.sort.util.TestingUtils.EmptySourceInfo in project incubator-inlong by apache.
the class RecordTransformerTest method testSerializerNotMatchRecord.
@Test
public void testSerializerNotMatchRecord() throws Exception {
final Row row = new Row(2);
row.setField(0, 1024L);
row.setField(1, "9527");
final Record record = new Record(1L, System.currentTimeMillis(), row);
final int bufferSize = 1024;
final RecordTransformer transformer = new RecordTransformer(bufferSize);
final FieldInfo field1 = new FieldInfo("field1", new LongFormatInfo());
final TestingSinkInfo sinkInfo = new TestingSinkInfo(new FieldInfo[] { field1 });
final DataFlowInfo dataFlowInfo = new DataFlowInfo(1L, new EmptySourceInfo(), sinkInfo);
transformer.addDataFlow(dataFlowInfo);
Map<Long, RowSerializer> rowSerializers = transformer.getRowSerializers();
assertEquals(1, transformer.matchRecordAndSerializerField(record, rowSerializers.get(1L)).getRow().getArity());
final FieldInfo newField1 = new FieldInfo("field1", new LongFormatInfo());
final FieldInfo newField2 = new FieldInfo("field2", new LongFormatInfo());
final FieldInfo newField3 = new FieldInfo("field3", new LongFormatInfo());
final TestingSinkInfo newSinkInfo = new TestingSinkInfo(new FieldInfo[] { newField1, newField2, newField3 });
final DataFlowInfo newDataFlowInfo = new DataFlowInfo(1L, new EmptySourceInfo(), newSinkInfo);
transformer.addDataFlow(newDataFlowInfo);
Map<Long, RowSerializer> newRowSerializers = transformer.getRowSerializers();
assertEquals(3, transformer.matchRecordAndSerializerField(record, newRowSerializers.get(1L)).getRow().getArity());
}
use of org.apache.inlong.sort.util.TestingUtils.EmptySourceInfo in project incubator-inlong by apache.
the class RecordTransformerTest method testTransformation.
@Test
public void testTransformation() throws Exception {
final int bufferSize = 1024;
final RecordTransformer transformer = new RecordTransformer(bufferSize);
final FieldInfo field1 = new FieldInfo("field1", new LongFormatInfo());
final FieldInfo field2 = new FieldInfo("field2", new StringFormatInfo());
final TestingSinkInfo sinkInfo = new TestingSinkInfo(new FieldInfo[] { field1, field2 });
final DataFlowInfo dataFlowInfo = new DataFlowInfo(1L, new EmptySourceInfo(), sinkInfo);
transformer.addDataFlow(dataFlowInfo);
final Row row = new Row(2);
row.setField(0, 1024L);
row.setField(1, "9527");
final Record record = new Record(1L, System.currentTimeMillis(), row);
final Record transformed = transformer.toRecord(transformer.toSerializedRecord(record));
assertEquals(record, transformed);
// check the buffers
assertEquals(0, transformer.getDataInputDeserializer().available());
assertEquals(0, transformer.getDataOutputSerializer().length());
assertEquals(bufferSize, transformer.getDataOutputSerializer().getSharedBuffer().length);
transformer.removeDataFlow(dataFlowInfo);
assertEquals(0, transformer.getRowSerializers().size());
}
Aggregations