forked from apache/inlong
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Sort] Sort format supports InLongMsg-kv format apache#9521
- Loading branch information
Showing
14 changed files
with
1,963 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Licensed to the Apache Software Foundation (ASF) under one | ||
or more contributor license agreements. See the NOTICE file | ||
distributed with this work for additional information | ||
regarding copyright ownership. The ASF licenses this file | ||
to you under the Apache License, Version 2.0 (the | ||
"License"); you may not use this file except in compliance | ||
with the License. You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, | ||
software distributed under the License is distributed on an | ||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations | ||
under the License. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.apache.inlong</groupId> | ||
<artifactId>sort-formats</artifactId> | ||
<version>1.11.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>sort-format-inlongmsg-kv</artifactId> | ||
<name>Apache InLong - Sort Format-inlongmsg-kv</name> | ||
|
||
<properties> | ||
<inlong.root.dir>${project.parent.parent.parent.basedir}</inlong.root.dir> | ||
</properties> | ||
|
||
<dependencies> | ||
<!-- core dependencies --> | ||
<dependency> | ||
<groupId>org.apache.inlong</groupId> | ||
<artifactId>sort-format-common</artifactId> | ||
<version>${project.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.inlong</groupId> | ||
<artifactId>sort-format-base</artifactId> | ||
<version>${project.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.inlong</groupId> | ||
<artifactId>sort-format-inlongmsg-base</artifactId> | ||
<version>${project.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.xerial.snappy</groupId> | ||
<artifactId>snappy-java</artifactId> | ||
<version>${snappy.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.flink</groupId> | ||
<artifactId>flink-shaded-jackson</artifactId> | ||
<version>${flink.jackson.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.flink</groupId> | ||
<artifactId>flink-core</artifactId> | ||
<version>${flink.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.flink</groupId> | ||
<artifactId>flink-table-common</artifactId> | ||
<version>${flink.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<!-- test dependencies --> | ||
|
||
<dependency> | ||
<groupId>org.apache.flink</groupId> | ||
<artifactId>flink-table-common</artifactId> | ||
<version>${flink.version}</version> | ||
<type>test-jar</type> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
<profiles> | ||
<!-- Create SQL Client uber jars by default --> | ||
<profile> | ||
<id>sql-jars</id> | ||
<activation> | ||
<property> | ||
<name>!skipSqlJars</name> | ||
</property> | ||
</activation> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>jar</goal> | ||
</goals> | ||
<phase>package</phase> | ||
<configuration> | ||
<classifier>sql-jar</classifier> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
</profiles> | ||
</project> |
105 changes: 105 additions & 0 deletions
105
...at-inlongmsg-kv/src/main/java/org/apache/inlong/sort/formats/inlongmsgkv/InLongMsgKv.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.inlong.sort.formats.inlongmsgkv; | ||
|
||
import org.apache.inlong.sort.formats.base.TextFormatDescriptor; | ||
|
||
import static org.apache.flink.util.Preconditions.checkNotNull; | ||
import static org.apache.inlong.sort.formats.base.TableFormatConstants.FORMAT_ENTRY_DELIMITER; | ||
import static org.apache.inlong.sort.formats.base.TableFormatConstants.FORMAT_KV_DELIMITER; | ||
import static org.apache.inlong.sort.formats.base.TableFormatConstants.FORMAT_LINE_DELIMITER; | ||
import static org.apache.inlong.sort.formats.inlongmsg.InLongMsgUtils.FORMAT_ATTRIBUTES_FIELD_NAME; | ||
import static org.apache.inlong.sort.formats.inlongmsg.InLongMsgUtils.FORMAT_RETAIN_PREDEFINED_FIELD; | ||
import static org.apache.inlong.sort.formats.inlongmsg.InLongMsgUtils.FORMAT_TIME_FIELD_NAME; | ||
|
||
/** | ||
* Format descriptor for KVs. | ||
*/ | ||
public class InLongMsgKv extends TextFormatDescriptor<InLongMsgKv> { | ||
|
||
public static final String FORMAT_TYPE_VALUE = "InLongMsg-KV"; | ||
|
||
public InLongMsgKv() { | ||
super(FORMAT_TYPE_VALUE, 1); | ||
} | ||
|
||
/** | ||
* Sets the entry delimiter character ('&' by default). | ||
* | ||
* @param delimiter the entry delimiter character | ||
* @return The instance which has delimiter set. | ||
*/ | ||
public InLongMsgKv entryDelimiter(char delimiter) { | ||
internalProperties.putCharacter(FORMAT_ENTRY_DELIMITER, delimiter); | ||
return this; | ||
} | ||
|
||
/** | ||
* Sets the kv delimiter character ('=' by default). | ||
* | ||
* @param delimiter the kv delimiter character. | ||
* @return The instance which has delimiter set. | ||
*/ | ||
public InLongMsgKv kvDelimiter(char delimiter) { | ||
internalProperties.putCharacter(FORMAT_KV_DELIMITER, delimiter); | ||
return this; | ||
} | ||
|
||
/** | ||
* Sets the delimiter between lines. | ||
* | ||
* @param lineDelimiter The delimiter between lines (e.g. '\n'). | ||
* @return The instance which has lineDelimiter set. | ||
*/ | ||
public InLongMsgKv lineDelimiter(char lineDelimiter) { | ||
internalProperties.putCharacter(FORMAT_LINE_DELIMITER, lineDelimiter); | ||
return this; | ||
} | ||
|
||
/** | ||
* Sets the name of the time field. | ||
* | ||
* @param timeFieldName The name of the time field. | ||
* @return The instance which has timeFieldName set. | ||
*/ | ||
public InLongMsgKv timeFieldName(String timeFieldName) { | ||
checkNotNull(timeFieldName); | ||
internalProperties.putString(FORMAT_TIME_FIELD_NAME, timeFieldName); | ||
return this; | ||
} | ||
|
||
/** | ||
* Sets the name of the attributes field. | ||
* | ||
* @param attributesFieldName The name of the attributes field. | ||
* @return The instance which has attributes field set. | ||
*/ | ||
public InLongMsgKv attributesFieldName(String attributesFieldName) { | ||
checkNotNull(attributesFieldName); | ||
internalProperties.putString(FORMAT_ATTRIBUTES_FIELD_NAME, attributesFieldName); | ||
return this; | ||
} | ||
|
||
/** | ||
* Skips the predefined Field. | ||
*/ | ||
public InLongMsgKv skipPredefinedField() { | ||
internalProperties.putBoolean(FORMAT_RETAIN_PREDEFINED_FIELD, false); | ||
return this; | ||
} | ||
} |
Oops, something went wrong.