-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* SinkTask and SourceTask implement the validate method apache/rocketmq-connect#85 * Adjust the init and start methods of the component interface * Set pause and resume to deprecated methods. It feels like they can be removed * Add struct object and optimize schema and schema builder API #41 * add offset storage writer #41 * add getter and setter method #41 * add SchemaAndValue #41 * add logical type #41 * Schemabuilder add required method * schema add hashCode and equals method * fixed doc method * Field add equals and hashcode method * optimize api #85 * Optimize transform api #45 * Optimize transform api and add RecordConverter
- Loading branch information
1 parent
c1b5606
commit 949e27b
Showing
7 changed files
with
118 additions
and
13 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
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
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
81 changes: 81 additions & 0 deletions
81
connector/src/main/java/io/openmessaging/connector/api/data/RecordConverter.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,81 @@ | ||
/* | ||
* 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 io.openmessaging.connector.api.data; | ||
|
||
import io.openmessaging.KeyValue; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* The topic parameter is mainly a compatible schema registry | ||
* abstract converter | ||
*/ | ||
public interface RecordConverter { | ||
|
||
|
||
/** | ||
* Config is used for parameter passing in the conversion process | ||
* @param configs | ||
*/ | ||
default void configure(Map<String, ?> configs) { | ||
|
||
} | ||
|
||
/** | ||
* Convert ConnectRecord to byte[] | ||
* @param topic the topic associated with the data | ||
* @param schema record schema | ||
* @param value record value | ||
* @return | ||
*/ | ||
byte[] fromConnectData(String topic, Schema schema, Object value); | ||
|
||
|
||
/** | ||
* The provided subject and extension may be used in the record as needed. | ||
* @param topic the topic associated with the data | ||
* @param extensions | ||
* @param schema rocketmq connect record schema | ||
* @param value rocketmq connect record value | ||
* @return | ||
*/ | ||
default byte[] fromConnectData(String topic, KeyValue extensions, Schema schema, Object value) { | ||
return fromConnectData(topic, schema, value); | ||
} | ||
|
||
/** | ||
* Convert a byte[] object to a Rocketmq Connect data object. | ||
* | ||
* @param topic the topic associated with the data | ||
* @param value the value to convert | ||
* @return an object containing the {@link Schema} and the converted value | ||
*/ | ||
SchemaAndValue toConnectData(String topic, byte[] value); | ||
|
||
|
||
/** | ||
* The provided subject and extension may be used in the record as needed. | ||
* @param topic the topic associated with the data | ||
* @param extensions transform property | ||
* @param value | ||
* @return | ||
*/ | ||
default SchemaAndValue toConnectData(String topic, KeyValue extensions, byte[] value) { | ||
return toConnectData(topic, value); | ||
} | ||
|
||
} |