Search in sources :

Example 1 with InLongMsgCsvDeserializationInfo

use of org.apache.inlong.sort.protocol.deserialization.InLongMsgCsvDeserializationInfo in project incubator-inlong by apache.

the class PushSortConfigListener method getSourceInfo.

/**
 * Get source info for DataFlowInfo
 */
@Deprecated
private SourceInfo getSourceInfo(InlongGroupInfo groupInfo, String streamId, List<StreamSinkFieldEntity> fieldList) {
    DeserializationInfo deserializationInfo = null;
    String groupId = groupInfo.getInlongGroupId();
    InlongStreamInfo streamInfo = streamService.get(groupId, streamId);
    boolean isDbType = Constant.DATA_SOURCE_DB.equals(streamInfo.getDataType());
    if (!isDbType) {
        // FILE and auto push source, the data format is TEXT or KEY-VALUE, temporarily use InLongMsgCsv
        String dataType = streamInfo.getDataType();
        if (Constant.DATA_TYPE_TEXT.equalsIgnoreCase(dataType) || Constant.DATA_TYPE_KEY_VALUE.equalsIgnoreCase(dataType)) {
            // Use the field separator from the inlong stream
            char separator = (char) Integer.parseInt(streamInfo.getDataSeparator());
            // TODO support escape
            /*Character escape = null;
                if (info.getDataEscapeChar() != null) {
                    escape = info.getDataEscapeChar().charAt(0);
                }*/
            // Whether to delete the first separator, the default is false for the time being
            deserializationInfo = new InLongMsgCsvDeserializationInfo(streamId, separator);
        }
    }
    // The number and order of the source fields must be the same as the target fields
    return null;
}
Also used : DeserializationInfo(org.apache.inlong.sort.protocol.deserialization.DeserializationInfo) InLongMsgCsvDeserializationInfo(org.apache.inlong.sort.protocol.deserialization.InLongMsgCsvDeserializationInfo) InLongMsgCsvDeserializationInfo(org.apache.inlong.sort.protocol.deserialization.InLongMsgCsvDeserializationInfo) InlongStreamInfo(org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo)

Example 2 with InLongMsgCsvDeserializationInfo

use of org.apache.inlong.sort.protocol.deserialization.InLongMsgCsvDeserializationInfo 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));
}
Also used : EmptySinkInfo(org.apache.inlong.sort.util.TestingUtils.EmptySinkInfo) InLongMsgCsvDeserializationInfo(org.apache.inlong.sort.protocol.deserialization.InLongMsgCsvDeserializationInfo) TubeSourceInfo(org.apache.inlong.sort.protocol.source.TubeSourceInfo) EmptySourceInfo(org.apache.inlong.sort.util.TestingUtils.EmptySourceInfo) DataFlowInfo(org.apache.inlong.sort.protocol.DataFlowInfo) Test(org.junit.Test)

Example 3 with InLongMsgCsvDeserializationInfo

use of org.apache.inlong.sort.protocol.deserialization.InLongMsgCsvDeserializationInfo in project incubator-inlong by apache.

the class TubeSubscriptionDescriptionTest method testCopyConstructor.

@Test
public void testCopyConstructor() {
    final TubeSubscriptionDescription description = new TubeSubscriptionDescription(topic, masterAddress, null);
    final TubeSourceInfo tubeSourceInfo = new TubeSourceInfo(topic, masterAddress, null, new InLongMsgCsvDeserializationInfo(tid, ',', true), new FieldInfo[0]);
    description.addDataFlow(dataFlowId, tubeSourceInfo);
    final TubeSubscriptionDescription copied = new TubeSubscriptionDescription(description);
    assertEquals(description, copied);
    copied.removeDataFlow(dataFlowId);
    assertNotEquals(description, copied);
}
Also used : InLongMsgCsvDeserializationInfo(org.apache.inlong.sort.protocol.deserialization.InLongMsgCsvDeserializationInfo) TubeSourceInfo(org.apache.inlong.sort.protocol.source.TubeSourceInfo) Test(org.junit.Test)

Example 4 with InLongMsgCsvDeserializationInfo

use of org.apache.inlong.sort.protocol.deserialization.InLongMsgCsvDeserializationInfo in project incubator-inlong by apache.

the class MultiTenancyInLongMsgMixedDeserializer method generateDeserializer.

@VisibleForTesting
Pair<AbstractInLongMsgMixedFormatDeserializer, InLongMsgMixedFormatConverter> generateDeserializer(FieldInfo[] fields, InLongMsgDeserializationInfo inLongMsgDeserializationInfo) {
    final RowFormatInfo rowFormatInfo = CommonUtils.generateDeserializationRowFormatInfo(fields);
    final AbstractInLongMsgMixedFormatDeserializer preDeserializer;
    final InLongMsgMixedFormatConverter deserializer;
    if (inLongMsgDeserializationInfo instanceof InLongMsgCsvDeserializationInfo) {
        final InLongMsgCsvDeserializationInfo csvDeserializationInfo = (InLongMsgCsvDeserializationInfo) inLongMsgDeserializationInfo;
        preDeserializer = new InLongMsgCsvMixedFormatDeserializer(StandardCharsets.UTF_8.name(), csvDeserializationInfo.getDelimiter(), null, null, csvDeserializationInfo.isDeleteHeadDelimiter(), false);
        deserializer = new InLongMsgCsvMixedFormatConverter(rowFormatInfo, DEFAULT_TIME_FIELD_NAME, DEFAULT_ATTRIBUTES_FIELD_NAME, null, false);
    } else {
        throw new UnsupportedOperationException("Not supported yet " + inLongMsgDeserializationInfo.getClass().getSimpleName());
    }
    return Pair.of(preDeserializer, deserializer);
}
Also used : InLongMsgMixedFormatConverter(org.apache.inlong.sort.formats.inlongmsg.InLongMsgMixedFormatConverter) InLongMsgCsvMixedFormatDeserializer(org.apache.inlong.sort.formats.inlongmsgcsv.InLongMsgCsvMixedFormatDeserializer) RowFormatInfo(org.apache.inlong.sort.formats.common.RowFormatInfo) InLongMsgCsvMixedFormatConverter(org.apache.inlong.sort.formats.inlongmsgcsv.InLongMsgCsvMixedFormatConverter) InLongMsgCsvDeserializationInfo(org.apache.inlong.sort.protocol.deserialization.InLongMsgCsvDeserializationInfo) AbstractInLongMsgMixedFormatDeserializer(org.apache.inlong.sort.formats.inlongmsg.AbstractInLongMsgMixedFormatDeserializer) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 5 with InLongMsgCsvDeserializationInfo

use of org.apache.inlong.sort.protocol.deserialization.InLongMsgCsvDeserializationInfo in project incubator-inlong by apache.

the class MultiTenancyDeserializer method generateDeserializer.

@VisibleForTesting
Deserializer<SerializedRecord, Record> generateDeserializer(FieldInfo[] fields, DeserializationInfo deserializationInfo) {
    final RowFormatInfo rowFormatInfo = CommonUtils.generateDeserializationRowFormatInfo(fields);
    final Deserializer<SerializedRecord, Record> deserializer;
    if (deserializationInfo instanceof InLongMsgCsvDeserializationInfo) {
        InLongMsgCsvDeserializationInfo inLongMsgCsvDeserializationInfo = (InLongMsgCsvDeserializationInfo) deserializationInfo;
        InLongMsgCsvFormatDeserializer inLongMsgCsvFormatDeserializer = new InLongMsgCsvFormatDeserializer(rowFormatInfo, DEFAULT_TIME_FIELD_NAME, DEFAULT_ATTRIBUTES_FIELD_NAME, TableFormatConstants.DEFAULT_CHARSET, inLongMsgCsvDeserializationInfo.getDelimiter(), null, null, null, inLongMsgCsvDeserializationInfo.isDeleteHeadDelimiter(), TableFormatConstants.DEFAULT_IGNORE_ERRORS);
        deserializer = new InLongMsgDeserializer(inLongMsgCsvFormatDeserializer);
    } else {
        // TODO, support more formats here
        throw new UnsupportedOperationException("Not supported yet " + deserializationInfo.getClass().getSimpleName());
    }
    return deserializer;
}
Also used : SerializedRecord(org.apache.inlong.sort.flink.SerializedRecord) InLongMsgCsvFormatDeserializer(org.apache.inlong.sort.formats.inlongmsgcsv.InLongMsgCsvFormatDeserializer) RowFormatInfo(org.apache.inlong.sort.formats.common.RowFormatInfo) SerializedRecord(org.apache.inlong.sort.flink.SerializedRecord) Record(org.apache.inlong.sort.flink.Record) InLongMsgCsvDeserializationInfo(org.apache.inlong.sort.protocol.deserialization.InLongMsgCsvDeserializationInfo) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

InLongMsgCsvDeserializationInfo (org.apache.inlong.sort.protocol.deserialization.InLongMsgCsvDeserializationInfo)9 Test (org.junit.Test)6 TubeSourceInfo (org.apache.inlong.sort.protocol.source.TubeSourceInfo)5 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 ObjectMapper (org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper)2 Record (org.apache.inlong.sort.flink.Record)2 RowFormatInfo (org.apache.inlong.sort.formats.common.RowFormatInfo)2 DataFlowInfo (org.apache.inlong.sort.protocol.DataFlowInfo)2 FieldInfo (org.apache.inlong.sort.protocol.FieldInfo)2 DeserializationInfo (org.apache.inlong.sort.protocol.deserialization.DeserializationInfo)2 EmptySinkInfo (org.apache.inlong.sort.util.TestingUtils.EmptySinkInfo)2 IOException (java.io.IOException)1 Timestamp (java.sql.Timestamp)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 JsonProcessingException (org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException)1 InLongMsg (org.apache.inlong.common.msg.InLongMsg)1 InlongStreamInfo (org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo)1 InLongMsgMixedSerializedRecord (org.apache.inlong.sort.flink.InLongMsgMixedSerializedRecord)1