Commit 7c89bace authored by 田磊's avatar 田磊

push

parent 9a69aaf0
import com.alibaba.dts.boot.MysqlRecordPrinter;
import com.alibaba.dts.formats.avro.Operation;
import com.alibaba.dts.common.RecordListener;
import com.alibaba.dts.common.UserRecord;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Collections;
import java.util.Map;
import java.util.Objects;
import java.util.Properties;
import static com.alibaba.dts.boot.Boot.boot;
import static com.alibaba.dts.common.Util.uncompressionObjectName;
import static com.alibaba.dts.recordgenerator.Names.*;
public class NotifyDemo {
private static final Logger log = LoggerFactory.getLogger(NotifyDemo.class);
public static Map<String, RecordListener> buildRecordListener() {
// user can impl their own listener
RecordListener mysqlRecordPrintListener = new RecordListener() {
@Override
public void consume(UserRecord record) {
Operation operation = record.getRecord().getOperation();
if (!(operation == Operation.DELETE ||
operation == Operation.INSERT ||
operation == Operation.UPDATE)) {
record.commit(String.valueOf(record.getRecord().getSourceTimestamp()));
return;
}
// consume record
// MysqlRecordPrinter show how to go through record fields and get general attributes
String ret = MysqlRecordPrinter.recordToString(record.getRecord());
String dbName = null;
String tableName = null;
// here we get db and table name
String[] dbPair = uncompressionObjectName(record.getRecord().getObjectName());
if (null != dbPair) {
if (dbPair.length == 2) {
dbName = dbPair[0];
tableName = dbPair[1];
} else if (dbPair.length == 3) {
dbName = dbPair[0];
tableName = dbPair[2];
} else if (dbPair.length == 1) {
dbName = dbPair[0];
tableName = "";
} else {
throw new RuntimeException("invalid db and table name pair for record [" + record + "]");
}
}
if (!Objects.equals(tableName, "store")) {
record.commit(String.valueOf(record.getRecord().getSourceTimestamp()));
return;
}
log.error("dbName {} tableName: {}", dbName, tableName);
log.info(ret);
record.commit(String.valueOf(record.getRecord().getSourceTimestamp()));
}
};
return Collections.singletonMap("mysqlRecordPrinter", mysqlRecordPrintListener);
}
/**
* This demo use hard coded config. User can modify variable value for test
* The detailed describe for var in resources/demoConfig
*/
public static Properties getConfigs() {
Properties properties = new Properties();
// user password and sid for auth
properties.setProperty(USER_NAME, "dtsscm");
properties.setProperty(PASSWORD_NAME, "A5tJKZur8fUCdluC");
properties.setProperty(SID_NAME, "dtsuxfc9cw6150cbg9");
// kafka consumer group general same with sid
properties.setProperty(GROUP_NAME, "dtsuxfc9cw6150cbg9");
// topic to consume, partition is 0
properties.setProperty(KAFKA_TOPIC, "cn_hangzhou_pc_bp16ydc05ds3uivel_rootdev_version2");
// kafka broker url
properties.setProperty(KAFKA_BROKER_URL_NAME, "dts-cn-hangzhou.aliyuncs.com:18001");
// initial checkpoint for first seek(a timestamp to set, eg 1566180200 if you want (Mon Aug 19 10:03:21 CST 2019))
properties.setProperty(INITIAL_CHECKPOINT_NAME, "1631700109");
// if force use config checkpoint when start. for checkpoint reset
properties.setProperty(USE_CONFIG_CHECKPOINT_NAME, "false");
// use consumer assign or subscribe interface
// when use subscribe mode, group config is required. kafka consumer group is enabled
properties.setProperty(SUBSCRIBE_MODE_NAME, "assign");
return properties;
}
public static void main(String[] args) throws InterruptedException {
try{
boot(getConfigs(), buildRecordListener());
}catch(Throwable e){
log.error("NotifyDemo: failed cause " + e.getMessage(), e);
throw e;
} finally {
System.exit(0);
}
}
}
package com.alibaba.dts.boot;
import com.alibaba.dts.common.RecordListener;
import org.apache.kafka.common.TopicPartition;
import org.apache.log4j.PropertyConfigurator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.dts.recordgenerator.OffsetCommitCallBack;
import com.alibaba.dts.recordprocessor.EtlRecordProcessor;
import com.alibaba.dts.recordgenerator.RecordGenerator;
import com.alibaba.dts.recordgenerator.ConsumerWrapFactory;
import sun.misc.Signal;
import sun.misc.SignalHandler;
import com.alibaba.dts.common.Checkpoint;
import com.alibaba.dts.common.Context;
import com.alibaba.dts.common.WorkThread;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicBoolean;
import static com.alibaba.dts.recordgenerator.Names.*;
import static com.alibaba.dts.common.Util.*;
public class Boot {
private static final Logger log = LoggerFactory.getLogger(Boot.class);
private static final AtomicBoolean existed = new AtomicBoolean(false);
public static void boot(String configFile, Map<String, RecordListener> recordListeners) {
boot(loadConfig(configFile), recordListeners);
}
public static void boot(Properties properties, Map<String, RecordListener> recordListeners) {
// first init log4j
initLog4j();
require(null != recordListeners && !recordListeners.isEmpty(), "record listener required");
Context context = getStreamContext(properties);
// check config
checkConfig(properties);
RecordGenerator recordGenerator = getRecordGenerator(context, properties);
EtlRecordProcessor etlRecordProcessor = getEtlRecordProcessor(context, properties, recordGenerator);
recordListeners.forEach((k, v) -> {
log.info("Boot: register record listener " + k);
etlRecordProcessor.registerRecordListener(k, v);
});
registerSignalHandler(context);
List<WorkThread> startStream = startWorker(etlRecordProcessor, recordGenerator);
while (!existed.get() ) {
sleepMS(1000);
}
log.info("StreamBoot: shutting down...");
for (WorkThread workThread : startStream) {
workThread.stop();
}
}
private static List<WorkThread> startWorker(EtlRecordProcessor etlRecordProcessor, RecordGenerator recordGenerator) {
List<WorkThread> ret = new LinkedList<>();
ret.add(new WorkThread(etlRecordProcessor));
ret.add(new WorkThread(recordGenerator));
for (WorkThread workThread : ret) {
workThread.start();
}
return ret;
}
private static void registerSignalHandler(Context context) {
SignalHandler signalHandler = new SignalHandler() {
@Override
public void handle(Signal signal) {
// SIG_INT
if (signal.getNumber() == 2) {
existed.compareAndSet(false, true);
}
}
};
Signal.handle(new Signal("INT"), signalHandler);
}
private static Context getStreamContext(Properties properties) {
Context ret = new Context();
return ret;
}
// offset@timestamp or timestamp
private static Checkpoint parseCheckpoint(String checkpoint) {
require(null != checkpoint, "checkpoint should not be null");
String[] offsetAndTS = checkpoint.split("@");
Checkpoint streamCheckpoint = null;
if (offsetAndTS.length == 1) {
streamCheckpoint = new Checkpoint(null, Long.valueOf(offsetAndTS[0]), -1, "");
} else if (offsetAndTS.length >= 2) {
streamCheckpoint = new Checkpoint(null, Long.valueOf(offsetAndTS[0]), Long.valueOf(offsetAndTS[1]), "");
}
return streamCheckpoint;
}
private static RecordGenerator getRecordGenerator(Context context, Properties properties) {
RecordGenerator recordGenerator = new RecordGenerator(properties, context,
parseCheckpoint(properties.getProperty(INITIAL_CHECKPOINT_NAME)),
new ConsumerWrapFactory.KafkaConsumerWrapFactory());
context.setStreamSource(recordGenerator);
return recordGenerator;
}
private static EtlRecordProcessor getEtlRecordProcessor(Context context, Properties properties, RecordGenerator recordGenerator) {
EtlRecordProcessor etlRecordProcessor = new EtlRecordProcessor(new OffsetCommitCallBack() {
@Override
public void commit(TopicPartition tp, long timestamp, long offset, String metadata) {
recordGenerator.setToCommitCheckpoint(new Checkpoint(tp, timestamp, offset, metadata));
}
}, context);
context.setRecordProcessor(etlRecordProcessor);
return etlRecordProcessor;
}
// may check some fo config value
private static void checkConfig(Properties properties) {
require(null != properties.getProperty(USER_NAME), "use should supplied");
require(null != properties.getProperty(PASSWORD_NAME), "password should supplied");
require(null != properties.getProperty(SID_NAME), "sid should supplied");
require(null != properties.getProperty(KAFKA_TOPIC), "kafka topic should supplied");
require(null != properties.getProperty(KAFKA_BROKER_URL_NAME), "broker url should supplied");
}
private static Properties initLog4j() {
Properties properties = new Properties();
InputStream log4jInput = null;
try {
log4jInput = Thread.currentThread().getContextClassLoader().getResourceAsStream("log4j.properties");
PropertyConfigurator.configure(log4jInput);
} catch (Exception e) {
} finally {
swallowErrorClose(log4jInput);
}
return properties;
}
private static Properties loadConfig(String filePath) {
Properties ret = new Properties();
InputStream toLoad = null;
try {
toLoad = new BufferedInputStream(new FileInputStream(filePath));
ret.load(toLoad);
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
swallowErrorClose(toLoad);
}
return ret;
}
}
package com.alibaba.dts.boot;
import com.alibaba.dts.formats.avro.Field;
import com.alibaba.dts.formats.avro.Record;
import com.alibaba.dts.common.FieldEntryHolder;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.dts.recordprocessor.FieldConverter;
import java.util.Iterator;
import java.util.List;
import static com.alibaba.dts.common.Util.uncompressionObjectName;
/**
* this class show how to process record attribute and column
*/
public class MysqlRecordPrinter {
private static final Logger log = LoggerFactory.getLogger(MysqlRecordPrinter.class);
private static final FieldConverter FIELD_CONVERTER = FieldConverter.getConverter("mysql", null);
public static String recordToString(Record record) {
StringBuilder stringBuilder = new StringBuilder(256);
switch (record.getOperation()) {
case DDL: {
appendRecordGeneralInfo(record, stringBuilder);
String ddl = (String)record.getAfterImages();
stringBuilder.append("DDL [").append(ddl).append("]");
break;
}
default: {
List<Field> fields = (List<Field>) record.getFields();
FieldEntryHolder[] fieldArray = getFieldEntryHolder(record);
appendRecordGeneralInfo(record, stringBuilder);
appendFields(fields, fieldArray[0], fieldArray[1], stringBuilder);
break;
}
}
return stringBuilder.toString();
}
private static FieldEntryHolder[] getFieldEntryHolder(Record record) {
// this is a simple impl, may exist unhandled situation
FieldEntryHolder[] fieldArray = new FieldEntryHolder[2];
fieldArray[0] = new FieldEntryHolder((List<Object>) record.getBeforeImages());
fieldArray[1] = new FieldEntryHolder((List<Object>) record.getAfterImages());
return fieldArray;
}
private static void appendFields(List<Field> fields, FieldEntryHolder before, FieldEntryHolder after, StringBuilder stringBuilder) {
if (null != fields) {
Iterator<Field> fieldIterator = fields.iterator();
while (fieldIterator.hasNext() && before.hasNext() && after.hasNext()) {
Field field = fieldIterator.next();
Object toPrintBefore = before.take();
Object toPrintAfter = after.take();
appendField(field, toPrintBefore, toPrintAfter, stringBuilder);
}
}
}
private static void appendField(Field field, Object beforeImage, Object afterImage, StringBuilder stringBuilder) {
stringBuilder.append("Field [").append(field.getName()).append("]");
if (null != beforeImage) {
stringBuilder.append("Before [").append(FIELD_CONVERTER.convert(field, beforeImage).toString()).append("]");
}
if (null != afterImage) {
stringBuilder.append("After [").append(FIELD_CONVERTER.convert(field, afterImage).toString()).append("]");
}
stringBuilder.append("\n");
}
private static void appendRecordGeneralInfo(Record record, StringBuilder stringBuilder) {
String dbName = null;
String tableName = null;
// here we get db and table name
String[] dbPair = uncompressionObjectName(record.getObjectName());
if (null != dbPair) {
if (dbPair.length == 2) {
dbName = dbPair[0];
tableName = dbPair[1];
} else if (dbPair.length == 3) {
dbName = dbPair[0];
tableName = dbPair[2];
} else if (dbPair.length == 1) {
dbName = dbPair[0];
tableName = "";
} else {
throw new RuntimeException("invalid db and table name pair for record [" + record + "]");
}
}
stringBuilder.
// record id can not be used as unique identifier
append("recordID [").append(record.getId()).append("]")
// source info contains which source this record came from
.append("source [").append(record.getSource()).append("]")
// db and table name
.append("dbTable [").append(dbName).append(".").append(tableName).append("]")
// record type
.append("recordType [").append(record.getOperation()).append("]")
// record generate timestamp in source log
.append("recordTimestamp [").append(record.getSourceTimestamp()).append("]")
// record extra tag
.append("extra tags [").append(StringUtils.join(record.getTags(), ",")).append("]");
stringBuilder.append("\n");
}
}
package com.alibaba.dts.common;
import java.io.*;
import java.util.LinkedList;
import java.util.List;
import static com.alibaba.dts.common.Util.*;
public class AtomicFileStore {
private final String fileName;
public AtomicFileStore(String fileName) {
this.fileName = fileName;
}
public List<String> getContent() {
List<String> ret = new LinkedList<>();
if (!checkFileExists(fileName)) {
return ret;
}
FileReader readFile = null;
BufferedReader bufferedReader = null;
try {
readFile = new FileReader(fileName);
bufferedReader = new BufferedReader(readFile);
String s = null;
while ((s = bufferedReader.readLine()) != null) {
ret.add(s);
}
} catch (Exception e) {
} finally {
swallowErrorClose(readFile);
swallowErrorClose(bufferedReader);
}
return ret;
}
public boolean updateContent(List<String> newContent) {
synchronized (this) {
String tmpFileName = fileName + ".tmp";
if (checkFileExists(tmpFileName)) {
deleteFile(tmpFileName);
}
boolean writeSuccess = true;
FileWriter fileWriter = null;
BufferedWriter bufferedWriter = null;
try {
fileWriter = new FileWriter(tmpFileName);
bufferedWriter = new BufferedWriter(fileWriter);
for (String content : newContent) {
bufferedWriter.write(content);
bufferedWriter.newLine();
}
bufferedWriter.flush();
} catch (Exception e) {
writeSuccess = false;
} finally {
swallowErrorClose(fileWriter);
swallowErrorClose(bufferedWriter);
}
// BugFix: windows can't rename file to existing file, remove old file first
remove();
return writeSuccess ? (new File(tmpFileName).renameTo(new File(fileName))) : false;
}
}
public void remove() {
deleteFile(fileName);
}
}
package com.alibaba.dts.common;
import org.apache.kafka.common.TopicPartition;
public class Checkpoint {
public static final Checkpoint INVALID_STREAM_CHECKPOINT = new Checkpoint(null, -1, -1, "-1");
private final TopicPartition topicPartition;
private final long timeStamp;
private final long offset;
private final String info;
public Checkpoint(TopicPartition topicPartition, long timeStamp, long offset, String info) {
this.topicPartition = topicPartition;
this.timeStamp = timeStamp;
this.offset = offset;
this.info = info;
}
public long getOffset() {
return offset;
}
public long getTimeStamp() {
return timeStamp;
}
public String getInfo() {
return info;
}
public TopicPartition getTopicPartition() {
return topicPartition;
}
public String toString() {
return "Checkpoint[ topicPartition: " + topicPartition + "timestamp: " + timeStamp + ", offset: " + offset + ", info: " + info + "]";
}
}
package com.alibaba.dts.common;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.dts.recordgenerator.RecordGenerator;
import com.alibaba.dts.recordprocessor.EtlRecordProcessor;
public class Context {
private static final Logger log = LoggerFactory.getLogger(Context.class);
private RecordGenerator streamSource;
private EtlRecordProcessor recordProcessor;
public void setStreamSource(RecordGenerator streamSource) {
this.streamSource = streamSource;
}
public EtlRecordProcessor getRecordProcessor() {
return recordProcessor;
}
public void setRecordProcessor(EtlRecordProcessor recordProcessor) {
this.recordProcessor = recordProcessor;
}
}
package com.alibaba.dts.common;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
public class FieldEntryHolder {
private final List<Object> originFields;
private final Iterator<Object> iterator;
private final List<Object> filteredFields;
public FieldEntryHolder(List<Object> originFields) {
this.originFields = originFields;
if (null == originFields) {
this.filteredFields = null;
this.iterator = null;
} else {
this.filteredFields = new LinkedList<>();
this.iterator = originFields.iterator();
}
}
public boolean hasNext() {
if (iterator == null) {
return true;
}
return iterator.hasNext();
}
public void skip() {
if (null != iterator) {
iterator.next();
}
}
public Object take() {
if (null != iterator) {
Object current = iterator.next();
filteredFields.add(current);
return current;
} else {
return null;
}
}
}
\ No newline at end of file
package com.alibaba.dts.common;
public interface RecordListener {
public void consume(UserRecord record);
}
package com.alibaba.dts.common;
import java.util.concurrent.atomic.AtomicLong;
/**
* for compaction enabled topic, empty key field in producer record is not allowed, so we gene random key to avoid compaction
*/
public class UniqueKeyGenerator {
private AtomicLong counter;
private final String startMSStr;
public UniqueKeyGenerator() {
counter = new AtomicLong(0);
startMSStr = String.valueOf(System.currentTimeMillis()) + "-";
}
public String nextKey() {
return startMSStr + counter.getAndIncrement();
}
}
\ No newline at end of file
package com.alibaba.dts.common;
import com.alibaba.dts.formats.avro.Record;
import org.apache.kafka.common.TopicPartition;
public interface UserCommitCallBack {
public void commit(TopicPartition tp, Record record, long offset, String metadata);
}
package com.alibaba.dts.common;
import com.alibaba.dts.formats.avro.Record;
import org.apache.kafka.common.TopicPartition;
public class UserRecord {
private final TopicPartition topicPartition;
private final long offset;
private final Record record;
private final UserCommitCallBack userCommitCallBack;
public UserRecord(TopicPartition tp, long offset, Record record, UserCommitCallBack userCommitCallBack) {
this.topicPartition = tp;
this.offset = offset;
this.record = record;
this.userCommitCallBack = userCommitCallBack;
}
public long getOffset() {
return offset;
}
public Record getRecord() {
return record;
}
public TopicPartition getTopicPartition() {
return topicPartition;
}
public void commit(String metadata) {
userCommitCallBack.commit(topicPartition, record, offset, metadata);
}
}
package com.alibaba.dts.common;
import org.apache.commons.lang3.StringUtils;
import org.apache.kafka.clients.CommonClientConfigs;
import org.apache.kafka.clients.consumer.ConsumerConfig;
import org.apache.kafka.common.config.SaslConfigs;
import com.alibaba.dts.recordgenerator.ClusterSwitchListener;
import java.io.Closeable;
import java.io.File;
import java.util.Properties;
import static com.alibaba.dts.recordgenerator.Names.*;
public class Util {
public static void swallowErrorClose(Closeable target) {
try {
if (null != target) {
target.close();
}
} catch (Exception e) {
}
}
public static void sleepMS(long value) {
try {
Thread.sleep(value);
} catch (Exception e) {
}
}
public static void mergeSourceKafkaProperties(Properties originProperties, Properties mergeToProperties) {
originProperties.forEach((k, v) ->{
String key = (String)k;
if (key.startsWith("kafka.")) {
String toPutKey = key.substring(6);
mergeToProperties.setProperty(toPutKey, (String)v);
}
});
mergeToProperties.setProperty(SaslConfigs.SASL_JAAS_CONFIG,
buildJaasConfig(originProperties.getProperty(SID_NAME), originProperties.getProperty(USER_NAME), originProperties.getProperty(PASSWORD_NAME)));
mergeToProperties.setProperty(SaslConfigs.SASL_MECHANISM, "PLAIN");
mergeToProperties.setProperty(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG, "SASL_PLAINTEXT");
mergeToProperties.setProperty(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, originProperties.getProperty(KAFKA_BROKER_URL_NAME));
mergeToProperties.setProperty(ConsumerConfig.GROUP_ID_CONFIG, originProperties.getProperty(GROUP_NAME));
// disable auto commit
mergeToProperties.setProperty(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, "false");
mergeToProperties.setProperty(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.ByteArrayDeserializer");
mergeToProperties.setProperty(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.ByteArrayDeserializer");
// to let the consumer feel the switch of cluster and reseek the offset by timestamp
mergeToProperties.setProperty(ConsumerConfig.INTERCEPTOR_CLASSES_CONFIG, ClusterSwitchListener.class.getName());
}
public static void require(boolean predict, String errMessage) {
if (!predict) {
throw new RuntimeException(errMessage);
}
}
public static String buildJaasConfig(String sid, String user, String password) {
String jaasTemplate = "org.apache.kafka.common.security.plain.PlainLoginModule required username=\"%s-%s\" password=\"%s\";";
return String.format(jaasTemplate, user, sid, password);
}
public static boolean checkFileExists(String fileName) {
File metaFile = new File(fileName);
return metaFile.exists();
}
public static void deleteFile(String fileName) {
File maybeAbsolutePath = new File(fileName);
if (!maybeAbsolutePath.exists()) {
return;
}
File metaFile = null;
if (maybeAbsolutePath.isAbsolute()) {
metaFile = maybeAbsolutePath;
} else {
File currentPath = new File(".");
metaFile = new File(currentPath.getAbsolutePath() + File.separator + fileName);
}
boolean deleted = metaFile.delete();
if (!deleted) {
throw new RuntimeException(metaFile.getAbsolutePath() + " should be cleaned anyway");
}
}
private static void setIfAbsent(Properties properties, String key, String valueSetIfAbsent) {
if (StringUtils.isEmpty(properties.getProperty(key))) {
properties.setProperty(key, valueSetIfAbsent);
}
}
public static String[] uncompressionObjectName(String compressionName){
if(null == compressionName || compressionName.isEmpty() ){
return null;
}
String [] names = compressionName.split("\\.");
int length = names.length;
for(int i=0;i<length;++i){
names[i] = unescapeName(names[i]);
}
return names;
}
private static String unescapeName(String name){
if (null == name || (name.indexOf("\\u002E") < 0)) {
return name;
}
StringBuilder builder = new StringBuilder();
int length = name.length();
for(int i=0;i<length;++i){
char c = name.charAt(i);
if('\\' == c && ( i<length-6 && 'u' == name.charAt(i + 1)
&& '0' == name.charAt(i + 2) && '0' == name.charAt(i+3)
&& '2' == name.charAt(i + 4) && 'E' == name.charAt(i+5))){
builder.append(".");
i += 5;
continue;
}else{
builder.append(c);
}
}
return builder.toString();
}
public static void sleepMs(long ms) {
try {
Thread.sleep(ms);
} catch (Exception e) {
}
}
}
package com.alibaba.dts.common;
import java.io.Closeable;
import static com.alibaba.dts.common.Util.swallowErrorClose;
public class WorkThread<T extends Runnable & Closeable> {
private final T r;
private final Thread worker;
public WorkThread(T r) {
this.r = r;
worker = new Thread(r);
}
public void start() {
worker.start();
}
public void stop() {
swallowErrorClose(r);
try {
worker.join(10000, 0);
} catch (Exception e) {
e.printStackTrace();
}
}
}
\ No newline at end of file
/**
* Autogenerated by Avro
*
* DO NOT EDIT DIRECTLY
*/
package com.alibaba.dts.formats.avro;
import org.apache.avro.specific.SpecificData;
import org.apache.avro.message.BinaryMessageEncoder;
import org.apache.avro.message.BinaryMessageDecoder;
import org.apache.avro.message.SchemaStore;
@SuppressWarnings("all")
@org.apache.avro.specific.AvroGenerated
public class BinaryGeometry extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
private static final long serialVersionUID = -9183362578343147886L;
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"BinaryGeometry\",\"namespace\":\"com.alibaba.dts.formats.avro\",\"fields\":[{\"name\":\"type\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"}},{\"name\":\"value\",\"type\":\"bytes\"}]}");
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
private static SpecificData MODEL$ = new SpecificData();
private static final BinaryMessageEncoder<BinaryGeometry> ENCODER =
new BinaryMessageEncoder<BinaryGeometry>(MODEL$, SCHEMA$);
private static final BinaryMessageDecoder<BinaryGeometry> DECODER =
new BinaryMessageDecoder<BinaryGeometry>(MODEL$, SCHEMA$);
/**
* Return the BinaryMessageDecoder instance used by this class.
*/
public static BinaryMessageDecoder<BinaryGeometry> getDecoder() {
return DECODER;
}
/**
* Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
* @param resolver a {@link SchemaStore} used to find schemas by fingerprint
*/
public static BinaryMessageDecoder<BinaryGeometry> createDecoder(SchemaStore resolver) {
return new BinaryMessageDecoder<BinaryGeometry>(MODEL$, SCHEMA$, resolver);
}
/** Serializes this BinaryGeometry to a ByteBuffer. */
public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException {
return ENCODER.encode(this);
}
/** Deserializes a BinaryGeometry from a ByteBuffer. */
public static BinaryGeometry fromByteBuffer(
java.nio.ByteBuffer b) throws java.io.IOException {
return DECODER.decode(b);
}
@Deprecated public java.lang.String type;
@Deprecated public java.nio.ByteBuffer value;
/**
* Default constructor. Note that this does not initialize fields
* to their default values from the schema. If that is desired then
* one should use <code>newBuilder()</code>.
*/
public BinaryGeometry() {}
/**
* All-args constructor.
* @param type The new value for type
* @param value The new value for value
*/
public BinaryGeometry(java.lang.String type, java.nio.ByteBuffer value) {
this.type = type;
this.value = value;
}
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
// Used by DatumWriter. Applications should not call.
public java.lang.Object get(int field$) {
switch (field$) {
case 0: return type;
case 1: return value;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
// Used by DatumReader. Applications should not call.
@SuppressWarnings(value="unchecked")
public void put(int field$, java.lang.Object value$) {
switch (field$) {
case 0: type = (java.lang.String)value$; break;
case 1: value = (java.nio.ByteBuffer)value$; break;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
/**
* Gets the value of the 'type' field.
* @return The value of the 'type' field.
*/
public java.lang.String getType() {
return type;
}
/**
* Sets the value of the 'type' field.
* @param value the value to set.
*/
public void setType(java.lang.String value) {
this.type = value;
}
/**
* Gets the value of the 'value' field.
* @return The value of the 'value' field.
*/
public java.nio.ByteBuffer getValue() {
return value;
}
/**
* Sets the value of the 'value' field.
* @param value the value to set.
*/
public void setValue(java.nio.ByteBuffer value) {
this.value = value;
}
/**
* Creates a new BinaryGeometry RecordBuilder.
* @return A new BinaryGeometry RecordBuilder
*/
public static com.alibaba.dts.formats.avro.BinaryGeometry.Builder newBuilder() {
return new com.alibaba.dts.formats.avro.BinaryGeometry.Builder();
}
/**
* Creates a new BinaryGeometry RecordBuilder by copying an existing Builder.
* @param other The existing builder to copy.
* @return A new BinaryGeometry RecordBuilder
*/
public static com.alibaba.dts.formats.avro.BinaryGeometry.Builder newBuilder(com.alibaba.dts.formats.avro.BinaryGeometry.Builder other) {
return new com.alibaba.dts.formats.avro.BinaryGeometry.Builder(other);
}
/**
* Creates a new BinaryGeometry RecordBuilder by copying an existing BinaryGeometry instance.
* @param other The existing instance to copy.
* @return A new BinaryGeometry RecordBuilder
*/
public static com.alibaba.dts.formats.avro.BinaryGeometry.Builder newBuilder(com.alibaba.dts.formats.avro.BinaryGeometry other) {
return new com.alibaba.dts.formats.avro.BinaryGeometry.Builder(other);
}
/**
* RecordBuilder for BinaryGeometry instances.
*/
public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<BinaryGeometry>
implements org.apache.avro.data.RecordBuilder<BinaryGeometry> {
private java.lang.String type;
private java.nio.ByteBuffer value;
/** Creates a new Builder */
private Builder() {
super(SCHEMA$);
}
/**
* Creates a Builder by copying an existing Builder.
* @param other The existing Builder to copy.
*/
private Builder(com.alibaba.dts.formats.avro.BinaryGeometry.Builder other) {
super(other);
if (isValidValue(fields()[0], other.type)) {
this.type = data().deepCopy(fields()[0].schema(), other.type);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.value)) {
this.value = data().deepCopy(fields()[1].schema(), other.value);
fieldSetFlags()[1] = true;
}
}
/**
* Creates a Builder by copying an existing BinaryGeometry instance
* @param other The existing instance to copy.
*/
private Builder(com.alibaba.dts.formats.avro.BinaryGeometry other) {
super(SCHEMA$);
if (isValidValue(fields()[0], other.type)) {
this.type = data().deepCopy(fields()[0].schema(), other.type);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.value)) {
this.value = data().deepCopy(fields()[1].schema(), other.value);
fieldSetFlags()[1] = true;
}
}
/**
* Gets the value of the 'type' field.
* @return The value.
*/
public java.lang.String getType() {
return type;
}
/**
* Sets the value of the 'type' field.
* @param value The value of 'type'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.BinaryGeometry.Builder setType(java.lang.String value) {
validate(fields()[0], value);
this.type = value;
fieldSetFlags()[0] = true;
return this;
}
/**
* Checks whether the 'type' field has been set.
* @return True if the 'type' field has been set, false otherwise.
*/
public boolean hasType() {
return fieldSetFlags()[0];
}
/**
* Clears the value of the 'type' field.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.BinaryGeometry.Builder clearType() {
type = null;
fieldSetFlags()[0] = false;
return this;
}
/**
* Gets the value of the 'value' field.
* @return The value.
*/
public java.nio.ByteBuffer getValue() {
return value;
}
/**
* Sets the value of the 'value' field.
* @param value The value of 'value'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.BinaryGeometry.Builder setValue(java.nio.ByteBuffer value) {
validate(fields()[1], value);
this.value = value;
fieldSetFlags()[1] = true;
return this;
}
/**
* Checks whether the 'value' field has been set.
* @return True if the 'value' field has been set, false otherwise.
*/
public boolean hasValue() {
return fieldSetFlags()[1];
}
/**
* Clears the value of the 'value' field.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.BinaryGeometry.Builder clearValue() {
value = null;
fieldSetFlags()[1] = false;
return this;
}
@Override
@SuppressWarnings("unchecked")
public BinaryGeometry build() {
try {
BinaryGeometry record = new BinaryGeometry();
record.type = fieldSetFlags()[0] ? this.type : (java.lang.String) defaultValue(fields()[0]);
record.value = fieldSetFlags()[1] ? this.value : (java.nio.ByteBuffer) defaultValue(fields()[1]);
return record;
} catch (java.lang.Exception e) {
throw new org.apache.avro.AvroRuntimeException(e);
}
}
}
@SuppressWarnings("unchecked")
private static final org.apache.avro.io.DatumWriter<BinaryGeometry>
WRITER$ = (org.apache.avro.io.DatumWriter<BinaryGeometry>)MODEL$.createDatumWriter(SCHEMA$);
@Override public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException {
WRITER$.write(this, SpecificData.getEncoder(out));
}
@SuppressWarnings("unchecked")
private static final org.apache.avro.io.DatumReader<BinaryGeometry>
READER$ = (org.apache.avro.io.DatumReader<BinaryGeometry>)MODEL$.createDatumReader(SCHEMA$);
@Override public void readExternal(java.io.ObjectInput in)
throws java.io.IOException {
READER$.read(this, SpecificData.getDecoder(in));
}
}
/**
* Autogenerated by Avro
*
* DO NOT EDIT DIRECTLY
*/
package com.alibaba.dts.formats.avro;
import org.apache.avro.specific.SpecificData;
import org.apache.avro.message.BinaryMessageEncoder;
import org.apache.avro.message.BinaryMessageDecoder;
import org.apache.avro.message.SchemaStore;
@SuppressWarnings("all")
@org.apache.avro.specific.AvroGenerated
public class BinaryObject extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
private static final long serialVersionUID = 9094139956249411247L;
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"BinaryObject\",\"namespace\":\"com.alibaba.dts.formats.avro\",\"fields\":[{\"name\":\"type\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"}},{\"name\":\"value\",\"type\":\"bytes\"}]}");
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
private static SpecificData MODEL$ = new SpecificData();
private static final BinaryMessageEncoder<BinaryObject> ENCODER =
new BinaryMessageEncoder<BinaryObject>(MODEL$, SCHEMA$);
private static final BinaryMessageDecoder<BinaryObject> DECODER =
new BinaryMessageDecoder<BinaryObject>(MODEL$, SCHEMA$);
/**
* Return the BinaryMessageDecoder instance used by this class.
*/
public static BinaryMessageDecoder<BinaryObject> getDecoder() {
return DECODER;
}
/**
* Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
* @param resolver a {@link SchemaStore} used to find schemas by fingerprint
*/
public static BinaryMessageDecoder<BinaryObject> createDecoder(SchemaStore resolver) {
return new BinaryMessageDecoder<BinaryObject>(MODEL$, SCHEMA$, resolver);
}
/** Serializes this BinaryObject to a ByteBuffer. */
public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException {
return ENCODER.encode(this);
}
/** Deserializes a BinaryObject from a ByteBuffer. */
public static BinaryObject fromByteBuffer(
java.nio.ByteBuffer b) throws java.io.IOException {
return DECODER.decode(b);
}
@Deprecated public java.lang.String type;
@Deprecated public java.nio.ByteBuffer value;
/**
* Default constructor. Note that this does not initialize fields
* to their default values from the schema. If that is desired then
* one should use <code>newBuilder()</code>.
*/
public BinaryObject() {}
/**
* All-args constructor.
* @param type The new value for type
* @param value The new value for value
*/
public BinaryObject(java.lang.String type, java.nio.ByteBuffer value) {
this.type = type;
this.value = value;
}
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
// Used by DatumWriter. Applications should not call.
public java.lang.Object get(int field$) {
switch (field$) {
case 0: return type;
case 1: return value;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
// Used by DatumReader. Applications should not call.
@SuppressWarnings(value="unchecked")
public void put(int field$, java.lang.Object value$) {
switch (field$) {
case 0: type = (java.lang.String)value$; break;
case 1: value = (java.nio.ByteBuffer)value$; break;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
/**
* Gets the value of the 'type' field.
* @return The value of the 'type' field.
*/
public java.lang.String getType() {
return type;
}
/**
* Sets the value of the 'type' field.
* @param value the value to set.
*/
public void setType(java.lang.String value) {
this.type = value;
}
/**
* Gets the value of the 'value' field.
* @return The value of the 'value' field.
*/
public java.nio.ByteBuffer getValue() {
return value;
}
/**
* Sets the value of the 'value' field.
* @param value the value to set.
*/
public void setValue(java.nio.ByteBuffer value) {
this.value = value;
}
/**
* Creates a new BinaryObject RecordBuilder.
* @return A new BinaryObject RecordBuilder
*/
public static com.alibaba.dts.formats.avro.BinaryObject.Builder newBuilder() {
return new com.alibaba.dts.formats.avro.BinaryObject.Builder();
}
/**
* Creates a new BinaryObject RecordBuilder by copying an existing Builder.
* @param other The existing builder to copy.
* @return A new BinaryObject RecordBuilder
*/
public static com.alibaba.dts.formats.avro.BinaryObject.Builder newBuilder(com.alibaba.dts.formats.avro.BinaryObject.Builder other) {
return new com.alibaba.dts.formats.avro.BinaryObject.Builder(other);
}
/**
* Creates a new BinaryObject RecordBuilder by copying an existing BinaryObject instance.
* @param other The existing instance to copy.
* @return A new BinaryObject RecordBuilder
*/
public static com.alibaba.dts.formats.avro.BinaryObject.Builder newBuilder(com.alibaba.dts.formats.avro.BinaryObject other) {
return new com.alibaba.dts.formats.avro.BinaryObject.Builder(other);
}
/**
* RecordBuilder for BinaryObject instances.
*/
public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<BinaryObject>
implements org.apache.avro.data.RecordBuilder<BinaryObject> {
private java.lang.String type;
private java.nio.ByteBuffer value;
/** Creates a new Builder */
private Builder() {
super(SCHEMA$);
}
/**
* Creates a Builder by copying an existing Builder.
* @param other The existing Builder to copy.
*/
private Builder(com.alibaba.dts.formats.avro.BinaryObject.Builder other) {
super(other);
if (isValidValue(fields()[0], other.type)) {
this.type = data().deepCopy(fields()[0].schema(), other.type);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.value)) {
this.value = data().deepCopy(fields()[1].schema(), other.value);
fieldSetFlags()[1] = true;
}
}
/**
* Creates a Builder by copying an existing BinaryObject instance
* @param other The existing instance to copy.
*/
private Builder(com.alibaba.dts.formats.avro.BinaryObject other) {
super(SCHEMA$);
if (isValidValue(fields()[0], other.type)) {
this.type = data().deepCopy(fields()[0].schema(), other.type);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.value)) {
this.value = data().deepCopy(fields()[1].schema(), other.value);
fieldSetFlags()[1] = true;
}
}
/**
* Gets the value of the 'type' field.
* @return The value.
*/
public java.lang.String getType() {
return type;
}
/**
* Sets the value of the 'type' field.
* @param value The value of 'type'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.BinaryObject.Builder setType(java.lang.String value) {
validate(fields()[0], value);
this.type = value;
fieldSetFlags()[0] = true;
return this;
}
/**
* Checks whether the 'type' field has been set.
* @return True if the 'type' field has been set, false otherwise.
*/
public boolean hasType() {
return fieldSetFlags()[0];
}
/**
* Clears the value of the 'type' field.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.BinaryObject.Builder clearType() {
type = null;
fieldSetFlags()[0] = false;
return this;
}
/**
* Gets the value of the 'value' field.
* @return The value.
*/
public java.nio.ByteBuffer getValue() {
return value;
}
/**
* Sets the value of the 'value' field.
* @param value The value of 'value'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.BinaryObject.Builder setValue(java.nio.ByteBuffer value) {
validate(fields()[1], value);
this.value = value;
fieldSetFlags()[1] = true;
return this;
}
/**
* Checks whether the 'value' field has been set.
* @return True if the 'value' field has been set, false otherwise.
*/
public boolean hasValue() {
return fieldSetFlags()[1];
}
/**
* Clears the value of the 'value' field.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.BinaryObject.Builder clearValue() {
value = null;
fieldSetFlags()[1] = false;
return this;
}
@Override
@SuppressWarnings("unchecked")
public BinaryObject build() {
try {
BinaryObject record = new BinaryObject();
record.type = fieldSetFlags()[0] ? this.type : (java.lang.String) defaultValue(fields()[0]);
record.value = fieldSetFlags()[1] ? this.value : (java.nio.ByteBuffer) defaultValue(fields()[1]);
return record;
} catch (java.lang.Exception e) {
throw new org.apache.avro.AvroRuntimeException(e);
}
}
}
@SuppressWarnings("unchecked")
private static final org.apache.avro.io.DatumWriter<BinaryObject>
WRITER$ = (org.apache.avro.io.DatumWriter<BinaryObject>)MODEL$.createDatumWriter(SCHEMA$);
@Override public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException {
WRITER$.write(this, SpecificData.getEncoder(out));
}
@SuppressWarnings("unchecked")
private static final org.apache.avro.io.DatumReader<BinaryObject>
READER$ = (org.apache.avro.io.DatumReader<BinaryObject>)MODEL$.createDatumReader(SCHEMA$);
@Override public void readExternal(java.io.ObjectInput in)
throws java.io.IOException {
READER$.read(this, SpecificData.getDecoder(in));
}
}
/**
* Autogenerated by Avro
*
* DO NOT EDIT DIRECTLY
*/
package com.alibaba.dts.formats.avro;
import org.apache.avro.specific.SpecificData;
import org.apache.avro.message.BinaryMessageEncoder;
import org.apache.avro.message.BinaryMessageDecoder;
import org.apache.avro.message.SchemaStore;
@SuppressWarnings("all")
@org.apache.avro.specific.AvroGenerated
public class Character extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
private static final long serialVersionUID = -1775377444003683903L;
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Character\",\"namespace\":\"com.alibaba.dts.formats.avro\",\"fields\":[{\"name\":\"charset\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"}},{\"name\":\"value\",\"type\":\"bytes\"}]}");
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
private static SpecificData MODEL$ = new SpecificData();
private static final BinaryMessageEncoder<Character> ENCODER =
new BinaryMessageEncoder<Character>(MODEL$, SCHEMA$);
private static final BinaryMessageDecoder<Character> DECODER =
new BinaryMessageDecoder<Character>(MODEL$, SCHEMA$);
/**
* Return the BinaryMessageDecoder instance used by this class.
*/
public static BinaryMessageDecoder<Character> getDecoder() {
return DECODER;
}
/**
* Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
* @param resolver a {@link SchemaStore} used to find schemas by fingerprint
*/
public static BinaryMessageDecoder<Character> createDecoder(SchemaStore resolver) {
return new BinaryMessageDecoder<Character>(MODEL$, SCHEMA$, resolver);
}
/** Serializes this Character to a ByteBuffer. */
public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException {
return ENCODER.encode(this);
}
/** Deserializes a Character from a ByteBuffer. */
public static Character fromByteBuffer(
java.nio.ByteBuffer b) throws java.io.IOException {
return DECODER.decode(b);
}
@Deprecated public java.lang.String charset;
@Deprecated public java.nio.ByteBuffer value;
/**
* Default constructor. Note that this does not initialize fields
* to their default values from the schema. If that is desired then
* one should use <code>newBuilder()</code>.
*/
public Character() {}
/**
* All-args constructor.
* @param charset The new value for charset
* @param value The new value for value
*/
public Character(java.lang.String charset, java.nio.ByteBuffer value) {
this.charset = charset;
this.value = value;
}
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
// Used by DatumWriter. Applications should not call.
public java.lang.Object get(int field$) {
switch (field$) {
case 0: return charset;
case 1: return value;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
// Used by DatumReader. Applications should not call.
@SuppressWarnings(value="unchecked")
public void put(int field$, java.lang.Object value$) {
switch (field$) {
case 0: charset = (java.lang.String)value$; break;
case 1: value = (java.nio.ByteBuffer)value$; break;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
/**
* Gets the value of the 'charset' field.
* @return The value of the 'charset' field.
*/
public java.lang.String getCharset() {
return charset;
}
/**
* Sets the value of the 'charset' field.
* @param value the value to set.
*/
public void setCharset(java.lang.String value) {
this.charset = value;
}
/**
* Gets the value of the 'value' field.
* @return The value of the 'value' field.
*/
public java.nio.ByteBuffer getValue() {
return value;
}
/**
* Sets the value of the 'value' field.
* @param value the value to set.
*/
public void setValue(java.nio.ByteBuffer value) {
this.value = value;
}
/**
* Creates a new Character RecordBuilder.
* @return A new Character RecordBuilder
*/
public static com.alibaba.dts.formats.avro.Character.Builder newBuilder() {
return new com.alibaba.dts.formats.avro.Character.Builder();
}
/**
* Creates a new Character RecordBuilder by copying an existing Builder.
* @param other The existing builder to copy.
* @return A new Character RecordBuilder
*/
public static com.alibaba.dts.formats.avro.Character.Builder newBuilder(com.alibaba.dts.formats.avro.Character.Builder other) {
return new com.alibaba.dts.formats.avro.Character.Builder(other);
}
/**
* Creates a new Character RecordBuilder by copying an existing Character instance.
* @param other The existing instance to copy.
* @return A new Character RecordBuilder
*/
public static com.alibaba.dts.formats.avro.Character.Builder newBuilder(com.alibaba.dts.formats.avro.Character other) {
return new com.alibaba.dts.formats.avro.Character.Builder(other);
}
/**
* RecordBuilder for Character instances.
*/
public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<Character>
implements org.apache.avro.data.RecordBuilder<Character> {
private java.lang.String charset;
private java.nio.ByteBuffer value;
/** Creates a new Builder */
private Builder() {
super(SCHEMA$);
}
/**
* Creates a Builder by copying an existing Builder.
* @param other The existing Builder to copy.
*/
private Builder(com.alibaba.dts.formats.avro.Character.Builder other) {
super(other);
if (isValidValue(fields()[0], other.charset)) {
this.charset = data().deepCopy(fields()[0].schema(), other.charset);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.value)) {
this.value = data().deepCopy(fields()[1].schema(), other.value);
fieldSetFlags()[1] = true;
}
}
/**
* Creates a Builder by copying an existing Character instance
* @param other The existing instance to copy.
*/
private Builder(com.alibaba.dts.formats.avro.Character other) {
super(SCHEMA$);
if (isValidValue(fields()[0], other.charset)) {
this.charset = data().deepCopy(fields()[0].schema(), other.charset);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.value)) {
this.value = data().deepCopy(fields()[1].schema(), other.value);
fieldSetFlags()[1] = true;
}
}
/**
* Gets the value of the 'charset' field.
* @return The value.
*/
public java.lang.String getCharset() {
return charset;
}
/**
* Sets the value of the 'charset' field.
* @param value The value of 'charset'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Character.Builder setCharset(java.lang.String value) {
validate(fields()[0], value);
this.charset = value;
fieldSetFlags()[0] = true;
return this;
}
/**
* Checks whether the 'charset' field has been set.
* @return True if the 'charset' field has been set, false otherwise.
*/
public boolean hasCharset() {
return fieldSetFlags()[0];
}
/**
* Clears the value of the 'charset' field.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Character.Builder clearCharset() {
charset = null;
fieldSetFlags()[0] = false;
return this;
}
/**
* Gets the value of the 'value' field.
* @return The value.
*/
public java.nio.ByteBuffer getValue() {
return value;
}
/**
* Sets the value of the 'value' field.
* @param value The value of 'value'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Character.Builder setValue(java.nio.ByteBuffer value) {
validate(fields()[1], value);
this.value = value;
fieldSetFlags()[1] = true;
return this;
}
/**
* Checks whether the 'value' field has been set.
* @return True if the 'value' field has been set, false otherwise.
*/
public boolean hasValue() {
return fieldSetFlags()[1];
}
/**
* Clears the value of the 'value' field.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Character.Builder clearValue() {
value = null;
fieldSetFlags()[1] = false;
return this;
}
@Override
@SuppressWarnings("unchecked")
public Character build() {
try {
Character record = new Character();
record.charset = fieldSetFlags()[0] ? this.charset : (java.lang.String) defaultValue(fields()[0]);
record.value = fieldSetFlags()[1] ? this.value : (java.nio.ByteBuffer) defaultValue(fields()[1]);
return record;
} catch (java.lang.Exception e) {
throw new org.apache.avro.AvroRuntimeException(e);
}
}
}
@SuppressWarnings("unchecked")
private static final org.apache.avro.io.DatumWriter<Character>
WRITER$ = (org.apache.avro.io.DatumWriter<Character>)MODEL$.createDatumWriter(SCHEMA$);
@Override public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException {
WRITER$.write(this, SpecificData.getEncoder(out));
}
@SuppressWarnings("unchecked")
private static final org.apache.avro.io.DatumReader<Character>
READER$ = (org.apache.avro.io.DatumReader<Character>)MODEL$.createDatumReader(SCHEMA$);
@Override public void readExternal(java.io.ObjectInput in)
throws java.io.IOException {
READER$.read(this, SpecificData.getDecoder(in));
}
}
/**
* Autogenerated by Avro
*
* DO NOT EDIT DIRECTLY
*/
package com.alibaba.dts.formats.avro;
import org.apache.avro.specific.SpecificData;
import org.apache.avro.message.BinaryMessageEncoder;
import org.apache.avro.message.BinaryMessageDecoder;
import org.apache.avro.message.SchemaStore;
@SuppressWarnings("all")
@org.apache.avro.specific.AvroGenerated
public class DateTime extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
private static final long serialVersionUID = -1040122710886440465L;
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"DateTime\",\"namespace\":\"com.alibaba.dts.formats.avro\",\"fields\":[{\"name\":\"year\",\"type\":[\"null\",\"int\"],\"default\":null},{\"name\":\"month\",\"type\":[\"null\",\"int\"],\"default\":null},{\"name\":\"day\",\"type\":[\"null\",\"int\"],\"default\":null},{\"name\":\"hour\",\"type\":[\"null\",\"int\"],\"default\":null},{\"name\":\"minute\",\"type\":[\"null\",\"int\"],\"default\":null},{\"name\":\"second\",\"type\":[\"null\",\"int\"],\"default\":null},{\"name\":\"millis\",\"type\":[\"null\",\"int\"],\"default\":null}]}");
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
private static SpecificData MODEL$ = new SpecificData();
private static final BinaryMessageEncoder<DateTime> ENCODER =
new BinaryMessageEncoder<DateTime>(MODEL$, SCHEMA$);
private static final BinaryMessageDecoder<DateTime> DECODER =
new BinaryMessageDecoder<DateTime>(MODEL$, SCHEMA$);
/**
* Return the BinaryMessageDecoder instance used by this class.
*/
public static BinaryMessageDecoder<DateTime> getDecoder() {
return DECODER;
}
/**
* Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
* @param resolver a {@link SchemaStore} used to find schemas by fingerprint
*/
public static BinaryMessageDecoder<DateTime> createDecoder(SchemaStore resolver) {
return new BinaryMessageDecoder<DateTime>(MODEL$, SCHEMA$, resolver);
}
/** Serializes this DateTime to a ByteBuffer. */
public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException {
return ENCODER.encode(this);
}
/** Deserializes a DateTime from a ByteBuffer. */
public static DateTime fromByteBuffer(
java.nio.ByteBuffer b) throws java.io.IOException {
return DECODER.decode(b);
}
@Deprecated public java.lang.Integer year;
@Deprecated public java.lang.Integer month;
@Deprecated public java.lang.Integer day;
@Deprecated public java.lang.Integer hour;
@Deprecated public java.lang.Integer minute;
@Deprecated public java.lang.Integer second;
@Deprecated public java.lang.Integer millis;
/**
* Default constructor. Note that this does not initialize fields
* to their default values from the schema. If that is desired then
* one should use <code>newBuilder()</code>.
*/
public DateTime() {}
/**
* All-args constructor.
* @param year The new value for year
* @param month The new value for month
* @param day The new value for day
* @param hour The new value for hour
* @param minute The new value for minute
* @param second The new value for second
* @param millis The new value for millis
*/
public DateTime(java.lang.Integer year, java.lang.Integer month, java.lang.Integer day, java.lang.Integer hour, java.lang.Integer minute, java.lang.Integer second, java.lang.Integer millis) {
this.year = year;
this.month = month;
this.day = day;
this.hour = hour;
this.minute = minute;
this.second = second;
this.millis = millis;
}
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
// Used by DatumWriter. Applications should not call.
public java.lang.Object get(int field$) {
switch (field$) {
case 0: return year;
case 1: return month;
case 2: return day;
case 3: return hour;
case 4: return minute;
case 5: return second;
case 6: return millis;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
// Used by DatumReader. Applications should not call.
@SuppressWarnings(value="unchecked")
public void put(int field$, java.lang.Object value$) {
switch (field$) {
case 0: year = (java.lang.Integer)value$; break;
case 1: month = (java.lang.Integer)value$; break;
case 2: day = (java.lang.Integer)value$; break;
case 3: hour = (java.lang.Integer)value$; break;
case 4: minute = (java.lang.Integer)value$; break;
case 5: second = (java.lang.Integer)value$; break;
case 6: millis = (java.lang.Integer)value$; break;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
/**
* Gets the value of the 'year' field.
* @return The value of the 'year' field.
*/
public java.lang.Integer getYear() {
return year;
}
/**
* Sets the value of the 'year' field.
* @param value the value to set.
*/
public void setYear(java.lang.Integer value) {
this.year = value;
}
/**
* Gets the value of the 'month' field.
* @return The value of the 'month' field.
*/
public java.lang.Integer getMonth() {
return month;
}
/**
* Sets the value of the 'month' field.
* @param value the value to set.
*/
public void setMonth(java.lang.Integer value) {
this.month = value;
}
/**
* Gets the value of the 'day' field.
* @return The value of the 'day' field.
*/
public java.lang.Integer getDay() {
return day;
}
/**
* Sets the value of the 'day' field.
* @param value the value to set.
*/
public void setDay(java.lang.Integer value) {
this.day = value;
}
/**
* Gets the value of the 'hour' field.
* @return The value of the 'hour' field.
*/
public java.lang.Integer getHour() {
return hour;
}
/**
* Sets the value of the 'hour' field.
* @param value the value to set.
*/
public void setHour(java.lang.Integer value) {
this.hour = value;
}
/**
* Gets the value of the 'minute' field.
* @return The value of the 'minute' field.
*/
public java.lang.Integer getMinute() {
return minute;
}
/**
* Sets the value of the 'minute' field.
* @param value the value to set.
*/
public void setMinute(java.lang.Integer value) {
this.minute = value;
}
/**
* Gets the value of the 'second' field.
* @return The value of the 'second' field.
*/
public java.lang.Integer getSecond() {
return second;
}
/**
* Sets the value of the 'second' field.
* @param value the value to set.
*/
public void setSecond(java.lang.Integer value) {
this.second = value;
}
/**
* Gets the value of the 'millis' field.
* @return The value of the 'millis' field.
*/
public java.lang.Integer getMillis() {
return millis;
}
/**
* Sets the value of the 'millis' field.
* @param value the value to set.
*/
public void setMillis(java.lang.Integer value) {
this.millis = value;
}
/**
* Creates a new DateTime RecordBuilder.
* @return A new DateTime RecordBuilder
*/
public static com.alibaba.dts.formats.avro.DateTime.Builder newBuilder() {
return new com.alibaba.dts.formats.avro.DateTime.Builder();
}
/**
* Creates a new DateTime RecordBuilder by copying an existing Builder.
* @param other The existing builder to copy.
* @return A new DateTime RecordBuilder
*/
public static com.alibaba.dts.formats.avro.DateTime.Builder newBuilder(com.alibaba.dts.formats.avro.DateTime.Builder other) {
return new com.alibaba.dts.formats.avro.DateTime.Builder(other);
}
/**
* Creates a new DateTime RecordBuilder by copying an existing DateTime instance.
* @param other The existing instance to copy.
* @return A new DateTime RecordBuilder
*/
public static com.alibaba.dts.formats.avro.DateTime.Builder newBuilder(com.alibaba.dts.formats.avro.DateTime other) {
return new com.alibaba.dts.formats.avro.DateTime.Builder(other);
}
/**
* RecordBuilder for DateTime instances.
*/
public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<DateTime>
implements org.apache.avro.data.RecordBuilder<DateTime> {
private java.lang.Integer year;
private java.lang.Integer month;
private java.lang.Integer day;
private java.lang.Integer hour;
private java.lang.Integer minute;
private java.lang.Integer second;
private java.lang.Integer millis;
/** Creates a new Builder */
private Builder() {
super(SCHEMA$);
}
/**
* Creates a Builder by copying an existing Builder.
* @param other The existing Builder to copy.
*/
private Builder(com.alibaba.dts.formats.avro.DateTime.Builder other) {
super(other);
if (isValidValue(fields()[0], other.year)) {
this.year = data().deepCopy(fields()[0].schema(), other.year);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.month)) {
this.month = data().deepCopy(fields()[1].schema(), other.month);
fieldSetFlags()[1] = true;
}
if (isValidValue(fields()[2], other.day)) {
this.day = data().deepCopy(fields()[2].schema(), other.day);
fieldSetFlags()[2] = true;
}
if (isValidValue(fields()[3], other.hour)) {
this.hour = data().deepCopy(fields()[3].schema(), other.hour);
fieldSetFlags()[3] = true;
}
if (isValidValue(fields()[4], other.minute)) {
this.minute = data().deepCopy(fields()[4].schema(), other.minute);
fieldSetFlags()[4] = true;
}
if (isValidValue(fields()[5], other.second)) {
this.second = data().deepCopy(fields()[5].schema(), other.second);
fieldSetFlags()[5] = true;
}
if (isValidValue(fields()[6], other.millis)) {
this.millis = data().deepCopy(fields()[6].schema(), other.millis);
fieldSetFlags()[6] = true;
}
}
/**
* Creates a Builder by copying an existing DateTime instance
* @param other The existing instance to copy.
*/
private Builder(com.alibaba.dts.formats.avro.DateTime other) {
super(SCHEMA$);
if (isValidValue(fields()[0], other.year)) {
this.year = data().deepCopy(fields()[0].schema(), other.year);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.month)) {
this.month = data().deepCopy(fields()[1].schema(), other.month);
fieldSetFlags()[1] = true;
}
if (isValidValue(fields()[2], other.day)) {
this.day = data().deepCopy(fields()[2].schema(), other.day);
fieldSetFlags()[2] = true;
}
if (isValidValue(fields()[3], other.hour)) {
this.hour = data().deepCopy(fields()[3].schema(), other.hour);
fieldSetFlags()[3] = true;
}
if (isValidValue(fields()[4], other.minute)) {
this.minute = data().deepCopy(fields()[4].schema(), other.minute);
fieldSetFlags()[4] = true;
}
if (isValidValue(fields()[5], other.second)) {
this.second = data().deepCopy(fields()[5].schema(), other.second);
fieldSetFlags()[5] = true;
}
if (isValidValue(fields()[6], other.millis)) {
this.millis = data().deepCopy(fields()[6].schema(), other.millis);
fieldSetFlags()[6] = true;
}
}
/**
* Gets the value of the 'year' field.
* @return The value.
*/
public java.lang.Integer getYear() {
return year;
}
/**
* Sets the value of the 'year' field.
* @param value The value of 'year'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.DateTime.Builder setYear(java.lang.Integer value) {
validate(fields()[0], value);
this.year = value;
fieldSetFlags()[0] = true;
return this;
}
/**
* Checks whether the 'year' field has been set.
* @return True if the 'year' field has been set, false otherwise.
*/
public boolean hasYear() {
return fieldSetFlags()[0];
}
/**
* Clears the value of the 'year' field.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.DateTime.Builder clearYear() {
year = null;
fieldSetFlags()[0] = false;
return this;
}
/**
* Gets the value of the 'month' field.
* @return The value.
*/
public java.lang.Integer getMonth() {
return month;
}
/**
* Sets the value of the 'month' field.
* @param value The value of 'month'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.DateTime.Builder setMonth(java.lang.Integer value) {
validate(fields()[1], value);
this.month = value;
fieldSetFlags()[1] = true;
return this;
}
/**
* Checks whether the 'month' field has been set.
* @return True if the 'month' field has been set, false otherwise.
*/
public boolean hasMonth() {
return fieldSetFlags()[1];
}
/**
* Clears the value of the 'month' field.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.DateTime.Builder clearMonth() {
month = null;
fieldSetFlags()[1] = false;
return this;
}
/**
* Gets the value of the 'day' field.
* @return The value.
*/
public java.lang.Integer getDay() {
return day;
}
/**
* Sets the value of the 'day' field.
* @param value The value of 'day'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.DateTime.Builder setDay(java.lang.Integer value) {
validate(fields()[2], value);
this.day = value;
fieldSetFlags()[2] = true;
return this;
}
/**
* Checks whether the 'day' field has been set.
* @return True if the 'day' field has been set, false otherwise.
*/
public boolean hasDay() {
return fieldSetFlags()[2];
}
/**
* Clears the value of the 'day' field.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.DateTime.Builder clearDay() {
day = null;
fieldSetFlags()[2] = false;
return this;
}
/**
* Gets the value of the 'hour' field.
* @return The value.
*/
public java.lang.Integer getHour() {
return hour;
}
/**
* Sets the value of the 'hour' field.
* @param value The value of 'hour'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.DateTime.Builder setHour(java.lang.Integer value) {
validate(fields()[3], value);
this.hour = value;
fieldSetFlags()[3] = true;
return this;
}
/**
* Checks whether the 'hour' field has been set.
* @return True if the 'hour' field has been set, false otherwise.
*/
public boolean hasHour() {
return fieldSetFlags()[3];
}
/**
* Clears the value of the 'hour' field.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.DateTime.Builder clearHour() {
hour = null;
fieldSetFlags()[3] = false;
return this;
}
/**
* Gets the value of the 'minute' field.
* @return The value.
*/
public java.lang.Integer getMinute() {
return minute;
}
/**
* Sets the value of the 'minute' field.
* @param value The value of 'minute'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.DateTime.Builder setMinute(java.lang.Integer value) {
validate(fields()[4], value);
this.minute = value;
fieldSetFlags()[4] = true;
return this;
}
/**
* Checks whether the 'minute' field has been set.
* @return True if the 'minute' field has been set, false otherwise.
*/
public boolean hasMinute() {
return fieldSetFlags()[4];
}
/**
* Clears the value of the 'minute' field.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.DateTime.Builder clearMinute() {
minute = null;
fieldSetFlags()[4] = false;
return this;
}
/**
* Gets the value of the 'second' field.
* @return The value.
*/
public java.lang.Integer getSecond() {
return second;
}
/**
* Sets the value of the 'second' field.
* @param value The value of 'second'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.DateTime.Builder setSecond(java.lang.Integer value) {
validate(fields()[5], value);
this.second = value;
fieldSetFlags()[5] = true;
return this;
}
/**
* Checks whether the 'second' field has been set.
* @return True if the 'second' field has been set, false otherwise.
*/
public boolean hasSecond() {
return fieldSetFlags()[5];
}
/**
* Clears the value of the 'second' field.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.DateTime.Builder clearSecond() {
second = null;
fieldSetFlags()[5] = false;
return this;
}
/**
* Gets the value of the 'millis' field.
* @return The value.
*/
public java.lang.Integer getMillis() {
return millis;
}
/**
* Sets the value of the 'millis' field.
* @param value The value of 'millis'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.DateTime.Builder setMillis(java.lang.Integer value) {
validate(fields()[6], value);
this.millis = value;
fieldSetFlags()[6] = true;
return this;
}
/**
* Checks whether the 'millis' field has been set.
* @return True if the 'millis' field has been set, false otherwise.
*/
public boolean hasMillis() {
return fieldSetFlags()[6];
}
/**
* Clears the value of the 'millis' field.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.DateTime.Builder clearMillis() {
millis = null;
fieldSetFlags()[6] = false;
return this;
}
@Override
@SuppressWarnings("unchecked")
public DateTime build() {
try {
DateTime record = new DateTime();
record.year = fieldSetFlags()[0] ? this.year : (java.lang.Integer) defaultValue(fields()[0]);
record.month = fieldSetFlags()[1] ? this.month : (java.lang.Integer) defaultValue(fields()[1]);
record.day = fieldSetFlags()[2] ? this.day : (java.lang.Integer) defaultValue(fields()[2]);
record.hour = fieldSetFlags()[3] ? this.hour : (java.lang.Integer) defaultValue(fields()[3]);
record.minute = fieldSetFlags()[4] ? this.minute : (java.lang.Integer) defaultValue(fields()[4]);
record.second = fieldSetFlags()[5] ? this.second : (java.lang.Integer) defaultValue(fields()[5]);
record.millis = fieldSetFlags()[6] ? this.millis : (java.lang.Integer) defaultValue(fields()[6]);
return record;
} catch (java.lang.Exception e) {
throw new org.apache.avro.AvroRuntimeException(e);
}
}
}
@SuppressWarnings("unchecked")
private static final org.apache.avro.io.DatumWriter<DateTime>
WRITER$ = (org.apache.avro.io.DatumWriter<DateTime>)MODEL$.createDatumWriter(SCHEMA$);
@Override public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException {
WRITER$.write(this, SpecificData.getEncoder(out));
}
@SuppressWarnings("unchecked")
private static final org.apache.avro.io.DatumReader<DateTime>
READER$ = (org.apache.avro.io.DatumReader<DateTime>)MODEL$.createDatumReader(SCHEMA$);
@Override public void readExternal(java.io.ObjectInput in)
throws java.io.IOException {
READER$.read(this, SpecificData.getDecoder(in));
}
}
/**
* Autogenerated by Avro
*
* DO NOT EDIT DIRECTLY
*/
package com.alibaba.dts.formats.avro;
import org.apache.avro.specific.SpecificData;
import org.apache.avro.message.BinaryMessageEncoder;
import org.apache.avro.message.BinaryMessageDecoder;
import org.apache.avro.message.SchemaStore;
@SuppressWarnings("all")
@org.apache.avro.specific.AvroGenerated
public class Decimal extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
private static final long serialVersionUID = 1122337845226509298L;
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Decimal\",\"namespace\":\"com.alibaba.dts.formats.avro\",\"fields\":[{\"name\":\"value\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"}},{\"name\":\"precision\",\"type\":\"int\"},{\"name\":\"scale\",\"type\":\"int\"}]}");
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
private static SpecificData MODEL$ = new SpecificData();
private static final BinaryMessageEncoder<Decimal> ENCODER =
new BinaryMessageEncoder<Decimal>(MODEL$, SCHEMA$);
private static final BinaryMessageDecoder<Decimal> DECODER =
new BinaryMessageDecoder<Decimal>(MODEL$, SCHEMA$);
/**
* Return the BinaryMessageDecoder instance used by this class.
*/
public static BinaryMessageDecoder<Decimal> getDecoder() {
return DECODER;
}
/**
* Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
* @param resolver a {@link SchemaStore} used to find schemas by fingerprint
*/
public static BinaryMessageDecoder<Decimal> createDecoder(SchemaStore resolver) {
return new BinaryMessageDecoder<Decimal>(MODEL$, SCHEMA$, resolver);
}
/** Serializes this Decimal to a ByteBuffer. */
public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException {
return ENCODER.encode(this);
}
/** Deserializes a Decimal from a ByteBuffer. */
public static Decimal fromByteBuffer(
java.nio.ByteBuffer b) throws java.io.IOException {
return DECODER.decode(b);
}
@Deprecated public java.lang.String value;
@Deprecated public int precision;
@Deprecated public int scale;
/**
* Default constructor. Note that this does not initialize fields
* to their default values from the schema. If that is desired then
* one should use <code>newBuilder()</code>.
*/
public Decimal() {}
/**
* All-args constructor.
* @param value The new value for value
* @param precision The new value for precision
* @param scale The new value for scale
*/
public Decimal(java.lang.String value, java.lang.Integer precision, java.lang.Integer scale) {
this.value = value;
this.precision = precision;
this.scale = scale;
}
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
// Used by DatumWriter. Applications should not call.
public java.lang.Object get(int field$) {
switch (field$) {
case 0: return value;
case 1: return precision;
case 2: return scale;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
// Used by DatumReader. Applications should not call.
@SuppressWarnings(value="unchecked")
public void put(int field$, java.lang.Object value$) {
switch (field$) {
case 0: value = (java.lang.String)value$; break;
case 1: precision = (java.lang.Integer)value$; break;
case 2: scale = (java.lang.Integer)value$; break;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
/**
* Gets the value of the 'value' field.
* @return The value of the 'value' field.
*/
public java.lang.String getValue() {
return value;
}
/**
* Sets the value of the 'value' field.
* @param value the value to set.
*/
public void setValue(java.lang.String value) {
this.value = value;
}
/**
* Gets the value of the 'precision' field.
* @return The value of the 'precision' field.
*/
public java.lang.Integer getPrecision() {
return precision;
}
/**
* Sets the value of the 'precision' field.
* @param value the value to set.
*/
public void setPrecision(java.lang.Integer value) {
this.precision = value;
}
/**
* Gets the value of the 'scale' field.
* @return The value of the 'scale' field.
*/
public java.lang.Integer getScale() {
return scale;
}
/**
* Sets the value of the 'scale' field.
* @param value the value to set.
*/
public void setScale(java.lang.Integer value) {
this.scale = value;
}
/**
* Creates a new Decimal RecordBuilder.
* @return A new Decimal RecordBuilder
*/
public static com.alibaba.dts.formats.avro.Decimal.Builder newBuilder() {
return new com.alibaba.dts.formats.avro.Decimal.Builder();
}
/**
* Creates a new Decimal RecordBuilder by copying an existing Builder.
* @param other The existing builder to copy.
* @return A new Decimal RecordBuilder
*/
public static com.alibaba.dts.formats.avro.Decimal.Builder newBuilder(com.alibaba.dts.formats.avro.Decimal.Builder other) {
return new com.alibaba.dts.formats.avro.Decimal.Builder(other);
}
/**
* Creates a new Decimal RecordBuilder by copying an existing Decimal instance.
* @param other The existing instance to copy.
* @return A new Decimal RecordBuilder
*/
public static com.alibaba.dts.formats.avro.Decimal.Builder newBuilder(com.alibaba.dts.formats.avro.Decimal other) {
return new com.alibaba.dts.formats.avro.Decimal.Builder(other);
}
/**
* RecordBuilder for Decimal instances.
*/
public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<Decimal>
implements org.apache.avro.data.RecordBuilder<Decimal> {
private java.lang.String value;
private int precision;
private int scale;
/** Creates a new Builder */
private Builder() {
super(SCHEMA$);
}
/**
* Creates a Builder by copying an existing Builder.
* @param other The existing Builder to copy.
*/
private Builder(com.alibaba.dts.formats.avro.Decimal.Builder other) {
super(other);
if (isValidValue(fields()[0], other.value)) {
this.value = data().deepCopy(fields()[0].schema(), other.value);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.precision)) {
this.precision = data().deepCopy(fields()[1].schema(), other.precision);
fieldSetFlags()[1] = true;
}
if (isValidValue(fields()[2], other.scale)) {
this.scale = data().deepCopy(fields()[2].schema(), other.scale);
fieldSetFlags()[2] = true;
}
}
/**
* Creates a Builder by copying an existing Decimal instance
* @param other The existing instance to copy.
*/
private Builder(com.alibaba.dts.formats.avro.Decimal other) {
super(SCHEMA$);
if (isValidValue(fields()[0], other.value)) {
this.value = data().deepCopy(fields()[0].schema(), other.value);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.precision)) {
this.precision = data().deepCopy(fields()[1].schema(), other.precision);
fieldSetFlags()[1] = true;
}
if (isValidValue(fields()[2], other.scale)) {
this.scale = data().deepCopy(fields()[2].schema(), other.scale);
fieldSetFlags()[2] = true;
}
}
/**
* Gets the value of the 'value' field.
* @return The value.
*/
public java.lang.String getValue() {
return value;
}
/**
* Sets the value of the 'value' field.
* @param value The value of 'value'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Decimal.Builder setValue(java.lang.String value) {
validate(fields()[0], value);
this.value = value;
fieldSetFlags()[0] = true;
return this;
}
/**
* Checks whether the 'value' field has been set.
* @return True if the 'value' field has been set, false otherwise.
*/
public boolean hasValue() {
return fieldSetFlags()[0];
}
/**
* Clears the value of the 'value' field.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Decimal.Builder clearValue() {
value = null;
fieldSetFlags()[0] = false;
return this;
}
/**
* Gets the value of the 'precision' field.
* @return The value.
*/
public java.lang.Integer getPrecision() {
return precision;
}
/**
* Sets the value of the 'precision' field.
* @param value The value of 'precision'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Decimal.Builder setPrecision(int value) {
validate(fields()[1], value);
this.precision = value;
fieldSetFlags()[1] = true;
return this;
}
/**
* Checks whether the 'precision' field has been set.
* @return True if the 'precision' field has been set, false otherwise.
*/
public boolean hasPrecision() {
return fieldSetFlags()[1];
}
/**
* Clears the value of the 'precision' field.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Decimal.Builder clearPrecision() {
fieldSetFlags()[1] = false;
return this;
}
/**
* Gets the value of the 'scale' field.
* @return The value.
*/
public java.lang.Integer getScale() {
return scale;
}
/**
* Sets the value of the 'scale' field.
* @param value The value of 'scale'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Decimal.Builder setScale(int value) {
validate(fields()[2], value);
this.scale = value;
fieldSetFlags()[2] = true;
return this;
}
/**
* Checks whether the 'scale' field has been set.
* @return True if the 'scale' field has been set, false otherwise.
*/
public boolean hasScale() {
return fieldSetFlags()[2];
}
/**
* Clears the value of the 'scale' field.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Decimal.Builder clearScale() {
fieldSetFlags()[2] = false;
return this;
}
@Override
@SuppressWarnings("unchecked")
public Decimal build() {
try {
Decimal record = new Decimal();
record.value = fieldSetFlags()[0] ? this.value : (java.lang.String) defaultValue(fields()[0]);
record.precision = fieldSetFlags()[1] ? this.precision : (java.lang.Integer) defaultValue(fields()[1]);
record.scale = fieldSetFlags()[2] ? this.scale : (java.lang.Integer) defaultValue(fields()[2]);
return record;
} catch (java.lang.Exception e) {
throw new org.apache.avro.AvroRuntimeException(e);
}
}
}
@SuppressWarnings("unchecked")
private static final org.apache.avro.io.DatumWriter<Decimal>
WRITER$ = (org.apache.avro.io.DatumWriter<Decimal>)MODEL$.createDatumWriter(SCHEMA$);
@Override public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException {
WRITER$.write(this, SpecificData.getEncoder(out));
}
@SuppressWarnings("unchecked")
private static final org.apache.avro.io.DatumReader<Decimal>
READER$ = (org.apache.avro.io.DatumReader<Decimal>)MODEL$.createDatumReader(SCHEMA$);
@Override public void readExternal(java.io.ObjectInput in)
throws java.io.IOException {
READER$.read(this, SpecificData.getDecoder(in));
}
}
/**
* Autogenerated by Avro
*
* DO NOT EDIT DIRECTLY
*/
package com.alibaba.dts.formats.avro;
@SuppressWarnings("all")
@org.apache.avro.specific.AvroGenerated
public enum EmptyObject {
NULL, NONE ;
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"enum\",\"name\":\"EmptyObject\",\"namespace\":\"com.alibaba.dts.formats.avro\",\"symbols\":[\"NULL\",\"NONE\"]}");
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
}
/**
* Autogenerated by Avro
*
* DO NOT EDIT DIRECTLY
*/
package com.alibaba.dts.formats.avro;
import org.apache.avro.specific.SpecificData;
import org.apache.avro.message.BinaryMessageEncoder;
import org.apache.avro.message.BinaryMessageDecoder;
import org.apache.avro.message.SchemaStore;
@SuppressWarnings("all")
@org.apache.avro.specific.AvroGenerated
public class Field extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
private static final long serialVersionUID = 49929941316960932L;
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Field\",\"namespace\":\"com.alibaba.dts.formats.avro\",\"fields\":[{\"name\":\"name\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"}},{\"name\":\"dataTypeNumber\",\"type\":\"int\"}]}");
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
private static SpecificData MODEL$ = new SpecificData();
private static final BinaryMessageEncoder<Field> ENCODER =
new BinaryMessageEncoder<Field>(MODEL$, SCHEMA$);
private static final BinaryMessageDecoder<Field> DECODER =
new BinaryMessageDecoder<Field>(MODEL$, SCHEMA$);
/**
* Return the BinaryMessageDecoder instance used by this class.
*/
public static BinaryMessageDecoder<Field> getDecoder() {
return DECODER;
}
/**
* Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
* @param resolver a {@link SchemaStore} used to find schemas by fingerprint
*/
public static BinaryMessageDecoder<Field> createDecoder(SchemaStore resolver) {
return new BinaryMessageDecoder<Field>(MODEL$, SCHEMA$, resolver);
}
/** Serializes this Field to a ByteBuffer. */
public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException {
return ENCODER.encode(this);
}
/** Deserializes a Field from a ByteBuffer. */
public static Field fromByteBuffer(
java.nio.ByteBuffer b) throws java.io.IOException {
return DECODER.decode(b);
}
@Deprecated public java.lang.String name;
@Deprecated public int dataTypeNumber;
/**
* Default constructor. Note that this does not initialize fields
* to their default values from the schema. If that is desired then
* one should use <code>newBuilder()</code>.
*/
public Field() {}
/**
* All-args constructor.
* @param name The new value for name
* @param dataTypeNumber The new value for dataTypeNumber
*/
public Field(java.lang.String name, java.lang.Integer dataTypeNumber) {
this.name = name;
this.dataTypeNumber = dataTypeNumber;
}
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
// Used by DatumWriter. Applications should not call.
public java.lang.Object get(int field$) {
switch (field$) {
case 0: return name;
case 1: return dataTypeNumber;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
// Used by DatumReader. Applications should not call.
@SuppressWarnings(value="unchecked")
public void put(int field$, java.lang.Object value$) {
switch (field$) {
case 0: name = (java.lang.String)value$; break;
case 1: dataTypeNumber = (java.lang.Integer)value$; break;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
/**
* Gets the value of the 'name' field.
* @return The value of the 'name' field.
*/
public java.lang.String getName() {
return name;
}
/**
* Sets the value of the 'name' field.
* @param value the value to set.
*/
public void setName(java.lang.String value) {
this.name = value;
}
/**
* Gets the value of the 'dataTypeNumber' field.
* @return The value of the 'dataTypeNumber' field.
*/
public java.lang.Integer getDataTypeNumber() {
return dataTypeNumber;
}
/**
* Sets the value of the 'dataTypeNumber' field.
* @param value the value to set.
*/
public void setDataTypeNumber(java.lang.Integer value) {
this.dataTypeNumber = value;
}
/**
* Creates a new Field RecordBuilder.
* @return A new Field RecordBuilder
*/
public static com.alibaba.dts.formats.avro.Field.Builder newBuilder() {
return new com.alibaba.dts.formats.avro.Field.Builder();
}
/**
* Creates a new Field RecordBuilder by copying an existing Builder.
* @param other The existing builder to copy.
* @return A new Field RecordBuilder
*/
public static com.alibaba.dts.formats.avro.Field.Builder newBuilder(com.alibaba.dts.formats.avro.Field.Builder other) {
return new com.alibaba.dts.formats.avro.Field.Builder(other);
}
/**
* Creates a new Field RecordBuilder by copying an existing Field instance.
* @param other The existing instance to copy.
* @return A new Field RecordBuilder
*/
public static com.alibaba.dts.formats.avro.Field.Builder newBuilder(com.alibaba.dts.formats.avro.Field other) {
return new com.alibaba.dts.formats.avro.Field.Builder(other);
}
/**
* RecordBuilder for Field instances.
*/
public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<Field>
implements org.apache.avro.data.RecordBuilder<Field> {
private java.lang.String name;
private int dataTypeNumber;
/** Creates a new Builder */
private Builder() {
super(SCHEMA$);
}
/**
* Creates a Builder by copying an existing Builder.
* @param other The existing Builder to copy.
*/
private Builder(com.alibaba.dts.formats.avro.Field.Builder other) {
super(other);
if (isValidValue(fields()[0], other.name)) {
this.name = data().deepCopy(fields()[0].schema(), other.name);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.dataTypeNumber)) {
this.dataTypeNumber = data().deepCopy(fields()[1].schema(), other.dataTypeNumber);
fieldSetFlags()[1] = true;
}
}
/**
* Creates a Builder by copying an existing Field instance
* @param other The existing instance to copy.
*/
private Builder(com.alibaba.dts.formats.avro.Field other) {
super(SCHEMA$);
if (isValidValue(fields()[0], other.name)) {
this.name = data().deepCopy(fields()[0].schema(), other.name);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.dataTypeNumber)) {
this.dataTypeNumber = data().deepCopy(fields()[1].schema(), other.dataTypeNumber);
fieldSetFlags()[1] = true;
}
}
/**
* Gets the value of the 'name' field.
* @return The value.
*/
public java.lang.String getName() {
return name;
}
/**
* Sets the value of the 'name' field.
* @param value The value of 'name'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Field.Builder setName(java.lang.String value) {
validate(fields()[0], value);
this.name = value;
fieldSetFlags()[0] = true;
return this;
}
/**
* Checks whether the 'name' field has been set.
* @return True if the 'name' field has been set, false otherwise.
*/
public boolean hasName() {
return fieldSetFlags()[0];
}
/**
* Clears the value of the 'name' field.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Field.Builder clearName() {
name = null;
fieldSetFlags()[0] = false;
return this;
}
/**
* Gets the value of the 'dataTypeNumber' field.
* @return The value.
*/
public java.lang.Integer getDataTypeNumber() {
return dataTypeNumber;
}
/**
* Sets the value of the 'dataTypeNumber' field.
* @param value The value of 'dataTypeNumber'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Field.Builder setDataTypeNumber(int value) {
validate(fields()[1], value);
this.dataTypeNumber = value;
fieldSetFlags()[1] = true;
return this;
}
/**
* Checks whether the 'dataTypeNumber' field has been set.
* @return True if the 'dataTypeNumber' field has been set, false otherwise.
*/
public boolean hasDataTypeNumber() {
return fieldSetFlags()[1];
}
/**
* Clears the value of the 'dataTypeNumber' field.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Field.Builder clearDataTypeNumber() {
fieldSetFlags()[1] = false;
return this;
}
@Override
@SuppressWarnings("unchecked")
public Field build() {
try {
Field record = new Field();
record.name = fieldSetFlags()[0] ? this.name : (java.lang.String) defaultValue(fields()[0]);
record.dataTypeNumber = fieldSetFlags()[1] ? this.dataTypeNumber : (java.lang.Integer) defaultValue(fields()[1]);
return record;
} catch (java.lang.Exception e) {
throw new org.apache.avro.AvroRuntimeException(e);
}
}
}
@SuppressWarnings("unchecked")
private static final org.apache.avro.io.DatumWriter<Field>
WRITER$ = (org.apache.avro.io.DatumWriter<Field>)MODEL$.createDatumWriter(SCHEMA$);
@Override public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException {
WRITER$.write(this, SpecificData.getEncoder(out));
}
@SuppressWarnings("unchecked")
private static final org.apache.avro.io.DatumReader<Field>
READER$ = (org.apache.avro.io.DatumReader<Field>)MODEL$.createDatumReader(SCHEMA$);
@Override public void readExternal(java.io.ObjectInput in)
throws java.io.IOException {
READER$.read(this, SpecificData.getDecoder(in));
}
}
/**
* Autogenerated by Avro
*
* DO NOT EDIT DIRECTLY
*/
package com.alibaba.dts.formats.avro;
import org.apache.avro.specific.SpecificData;
import org.apache.avro.message.BinaryMessageEncoder;
import org.apache.avro.message.BinaryMessageDecoder;
import org.apache.avro.message.SchemaStore;
@SuppressWarnings("all")
@org.apache.avro.specific.AvroGenerated
public class Float extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
private static final long serialVersionUID = -1896820785407439119L;
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Float\",\"namespace\":\"com.alibaba.dts.formats.avro\",\"fields\":[{\"name\":\"value\",\"type\":\"double\"},{\"name\":\"precision\",\"type\":\"int\"},{\"name\":\"scale\",\"type\":\"int\"}]}");
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
private static SpecificData MODEL$ = new SpecificData();
private static final BinaryMessageEncoder<Float> ENCODER =
new BinaryMessageEncoder<Float>(MODEL$, SCHEMA$);
private static final BinaryMessageDecoder<Float> DECODER =
new BinaryMessageDecoder<Float>(MODEL$, SCHEMA$);
/**
* Return the BinaryMessageDecoder instance used by this class.
*/
public static BinaryMessageDecoder<Float> getDecoder() {
return DECODER;
}
/**
* Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
* @param resolver a {@link SchemaStore} used to find schemas by fingerprint
*/
public static BinaryMessageDecoder<Float> createDecoder(SchemaStore resolver) {
return new BinaryMessageDecoder<Float>(MODEL$, SCHEMA$, resolver);
}
/** Serializes this Float to a ByteBuffer. */
public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException {
return ENCODER.encode(this);
}
/** Deserializes a Float from a ByteBuffer. */
public static Float fromByteBuffer(
java.nio.ByteBuffer b) throws java.io.IOException {
return DECODER.decode(b);
}
@Deprecated public double value;
@Deprecated public int precision;
@Deprecated public int scale;
/**
* Default constructor. Note that this does not initialize fields
* to their default values from the schema. If that is desired then
* one should use <code>newBuilder()</code>.
*/
public Float() {}
/**
* All-args constructor.
* @param value The new value for value
* @param precision The new value for precision
* @param scale The new value for scale
*/
public Float(java.lang.Double value, java.lang.Integer precision, java.lang.Integer scale) {
this.value = value;
this.precision = precision;
this.scale = scale;
}
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
// Used by DatumWriter. Applications should not call.
public java.lang.Object get(int field$) {
switch (field$) {
case 0: return value;
case 1: return precision;
case 2: return scale;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
// Used by DatumReader. Applications should not call.
@SuppressWarnings(value="unchecked")
public void put(int field$, java.lang.Object value$) {
switch (field$) {
case 0: value = (java.lang.Double)value$; break;
case 1: precision = (java.lang.Integer)value$; break;
case 2: scale = (java.lang.Integer)value$; break;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
/**
* Gets the value of the 'value' field.
* @return The value of the 'value' field.
*/
public java.lang.Double getValue() {
return value;
}
/**
* Sets the value of the 'value' field.
* @param value the value to set.
*/
public void setValue(java.lang.Double value) {
this.value = value;
}
/**
* Gets the value of the 'precision' field.
* @return The value of the 'precision' field.
*/
public java.lang.Integer getPrecision() {
return precision;
}
/**
* Sets the value of the 'precision' field.
* @param value the value to set.
*/
public void setPrecision(java.lang.Integer value) {
this.precision = value;
}
/**
* Gets the value of the 'scale' field.
* @return The value of the 'scale' field.
*/
public java.lang.Integer getScale() {
return scale;
}
/**
* Sets the value of the 'scale' field.
* @param value the value to set.
*/
public void setScale(java.lang.Integer value) {
this.scale = value;
}
/**
* Creates a new Float RecordBuilder.
* @return A new Float RecordBuilder
*/
public static com.alibaba.dts.formats.avro.Float.Builder newBuilder() {
return new com.alibaba.dts.formats.avro.Float.Builder();
}
/**
* Creates a new Float RecordBuilder by copying an existing Builder.
* @param other The existing builder to copy.
* @return A new Float RecordBuilder
*/
public static com.alibaba.dts.formats.avro.Float.Builder newBuilder(com.alibaba.dts.formats.avro.Float.Builder other) {
return new com.alibaba.dts.formats.avro.Float.Builder(other);
}
/**
* Creates a new Float RecordBuilder by copying an existing Float instance.
* @param other The existing instance to copy.
* @return A new Float RecordBuilder
*/
public static com.alibaba.dts.formats.avro.Float.Builder newBuilder(com.alibaba.dts.formats.avro.Float other) {
return new com.alibaba.dts.formats.avro.Float.Builder(other);
}
/**
* RecordBuilder for Float instances.
*/
public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<Float>
implements org.apache.avro.data.RecordBuilder<Float> {
private double value;
private int precision;
private int scale;
/** Creates a new Builder */
private Builder() {
super(SCHEMA$);
}
/**
* Creates a Builder by copying an existing Builder.
* @param other The existing Builder to copy.
*/
private Builder(com.alibaba.dts.formats.avro.Float.Builder other) {
super(other);
if (isValidValue(fields()[0], other.value)) {
this.value = data().deepCopy(fields()[0].schema(), other.value);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.precision)) {
this.precision = data().deepCopy(fields()[1].schema(), other.precision);
fieldSetFlags()[1] = true;
}
if (isValidValue(fields()[2], other.scale)) {
this.scale = data().deepCopy(fields()[2].schema(), other.scale);
fieldSetFlags()[2] = true;
}
}
/**
* Creates a Builder by copying an existing Float instance
* @param other The existing instance to copy.
*/
private Builder(com.alibaba.dts.formats.avro.Float other) {
super(SCHEMA$);
if (isValidValue(fields()[0], other.value)) {
this.value = data().deepCopy(fields()[0].schema(), other.value);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.precision)) {
this.precision = data().deepCopy(fields()[1].schema(), other.precision);
fieldSetFlags()[1] = true;
}
if (isValidValue(fields()[2], other.scale)) {
this.scale = data().deepCopy(fields()[2].schema(), other.scale);
fieldSetFlags()[2] = true;
}
}
/**
* Gets the value of the 'value' field.
* @return The value.
*/
public java.lang.Double getValue() {
return value;
}
/**
* Sets the value of the 'value' field.
* @param value The value of 'value'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Float.Builder setValue(double value) {
validate(fields()[0], value);
this.value = value;
fieldSetFlags()[0] = true;
return this;
}
/**
* Checks whether the 'value' field has been set.
* @return True if the 'value' field has been set, false otherwise.
*/
public boolean hasValue() {
return fieldSetFlags()[0];
}
/**
* Clears the value of the 'value' field.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Float.Builder clearValue() {
fieldSetFlags()[0] = false;
return this;
}
/**
* Gets the value of the 'precision' field.
* @return The value.
*/
public java.lang.Integer getPrecision() {
return precision;
}
/**
* Sets the value of the 'precision' field.
* @param value The value of 'precision'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Float.Builder setPrecision(int value) {
validate(fields()[1], value);
this.precision = value;
fieldSetFlags()[1] = true;
return this;
}
/**
* Checks whether the 'precision' field has been set.
* @return True if the 'precision' field has been set, false otherwise.
*/
public boolean hasPrecision() {
return fieldSetFlags()[1];
}
/**
* Clears the value of the 'precision' field.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Float.Builder clearPrecision() {
fieldSetFlags()[1] = false;
return this;
}
/**
* Gets the value of the 'scale' field.
* @return The value.
*/
public java.lang.Integer getScale() {
return scale;
}
/**
* Sets the value of the 'scale' field.
* @param value The value of 'scale'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Float.Builder setScale(int value) {
validate(fields()[2], value);
this.scale = value;
fieldSetFlags()[2] = true;
return this;
}
/**
* Checks whether the 'scale' field has been set.
* @return True if the 'scale' field has been set, false otherwise.
*/
public boolean hasScale() {
return fieldSetFlags()[2];
}
/**
* Clears the value of the 'scale' field.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Float.Builder clearScale() {
fieldSetFlags()[2] = false;
return this;
}
@Override
@SuppressWarnings("unchecked")
public Float build() {
try {
Float record = new Float();
record.value = fieldSetFlags()[0] ? this.value : (java.lang.Double) defaultValue(fields()[0]);
record.precision = fieldSetFlags()[1] ? this.precision : (java.lang.Integer) defaultValue(fields()[1]);
record.scale = fieldSetFlags()[2] ? this.scale : (java.lang.Integer) defaultValue(fields()[2]);
return record;
} catch (java.lang.Exception e) {
throw new org.apache.avro.AvroRuntimeException(e);
}
}
}
@SuppressWarnings("unchecked")
private static final org.apache.avro.io.DatumWriter<Float>
WRITER$ = (org.apache.avro.io.DatumWriter<Float>)MODEL$.createDatumWriter(SCHEMA$);
@Override public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException {
WRITER$.write(this, SpecificData.getEncoder(out));
}
@SuppressWarnings("unchecked")
private static final org.apache.avro.io.DatumReader<Float>
READER$ = (org.apache.avro.io.DatumReader<Float>)MODEL$.createDatumReader(SCHEMA$);
@Override public void readExternal(java.io.ObjectInput in)
throws java.io.IOException {
READER$.read(this, SpecificData.getDecoder(in));
}
}
/**
* Autogenerated by Avro
*
* DO NOT EDIT DIRECTLY
*/
package com.alibaba.dts.formats.avro;
import org.apache.avro.specific.SpecificData;
import org.apache.avro.message.BinaryMessageEncoder;
import org.apache.avro.message.BinaryMessageDecoder;
import org.apache.avro.message.SchemaStore;
@SuppressWarnings("all")
@org.apache.avro.specific.AvroGenerated
public class Integer extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
private static final long serialVersionUID = 8676388679064639164L;
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Integer\",\"namespace\":\"com.alibaba.dts.formats.avro\",\"fields\":[{\"name\":\"precision\",\"type\":\"int\"},{\"name\":\"value\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"}}]}");
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
private static SpecificData MODEL$ = new SpecificData();
private static final BinaryMessageEncoder<Integer> ENCODER =
new BinaryMessageEncoder<Integer>(MODEL$, SCHEMA$);
private static final BinaryMessageDecoder<Integer> DECODER =
new BinaryMessageDecoder<Integer>(MODEL$, SCHEMA$);
/**
* Return the BinaryMessageDecoder instance used by this class.
*/
public static BinaryMessageDecoder<Integer> getDecoder() {
return DECODER;
}
/**
* Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
* @param resolver a {@link SchemaStore} used to find schemas by fingerprint
*/
public static BinaryMessageDecoder<Integer> createDecoder(SchemaStore resolver) {
return new BinaryMessageDecoder<Integer>(MODEL$, SCHEMA$, resolver);
}
/** Serializes this Integer to a ByteBuffer. */
public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException {
return ENCODER.encode(this);
}
/** Deserializes a Integer from a ByteBuffer. */
public static Integer fromByteBuffer(
java.nio.ByteBuffer b) throws java.io.IOException {
return DECODER.decode(b);
}
@Deprecated public int precision;
@Deprecated public java.lang.String value;
/**
* Default constructor. Note that this does not initialize fields
* to their default values from the schema. If that is desired then
* one should use <code>newBuilder()</code>.
*/
public Integer() {}
/**
* All-args constructor.
* @param precision The new value for precision
* @param value The new value for value
*/
public Integer(java.lang.Integer precision, java.lang.String value) {
this.precision = precision;
this.value = value;
}
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
// Used by DatumWriter. Applications should not call.
public java.lang.Object get(int field$) {
switch (field$) {
case 0: return precision;
case 1: return value;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
// Used by DatumReader. Applications should not call.
@SuppressWarnings(value="unchecked")
public void put(int field$, java.lang.Object value$) {
switch (field$) {
case 0: precision = (java.lang.Integer)value$; break;
case 1: value = (java.lang.String)value$; break;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
/**
* Gets the value of the 'precision' field.
* @return The value of the 'precision' field.
*/
public java.lang.Integer getPrecision() {
return precision;
}
/**
* Sets the value of the 'precision' field.
* @param value the value to set.
*/
public void setPrecision(java.lang.Integer value) {
this.precision = value;
}
/**
* Gets the value of the 'value' field.
* @return The value of the 'value' field.
*/
public java.lang.String getValue() {
return value;
}
/**
* Sets the value of the 'value' field.
* @param value the value to set.
*/
public void setValue(java.lang.String value) {
this.value = value;
}
/**
* Creates a new Integer RecordBuilder.
* @return A new Integer RecordBuilder
*/
public static com.alibaba.dts.formats.avro.Integer.Builder newBuilder() {
return new com.alibaba.dts.formats.avro.Integer.Builder();
}
/**
* Creates a new Integer RecordBuilder by copying an existing Builder.
* @param other The existing builder to copy.
* @return A new Integer RecordBuilder
*/
public static com.alibaba.dts.formats.avro.Integer.Builder newBuilder(com.alibaba.dts.formats.avro.Integer.Builder other) {
return new com.alibaba.dts.formats.avro.Integer.Builder(other);
}
/**
* Creates a new Integer RecordBuilder by copying an existing Integer instance.
* @param other The existing instance to copy.
* @return A new Integer RecordBuilder
*/
public static com.alibaba.dts.formats.avro.Integer.Builder newBuilder(com.alibaba.dts.formats.avro.Integer other) {
return new com.alibaba.dts.formats.avro.Integer.Builder(other);
}
/**
* RecordBuilder for Integer instances.
*/
public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<Integer>
implements org.apache.avro.data.RecordBuilder<Integer> {
private int precision;
private java.lang.String value;
/** Creates a new Builder */
private Builder() {
super(SCHEMA$);
}
/**
* Creates a Builder by copying an existing Builder.
* @param other The existing Builder to copy.
*/
private Builder(com.alibaba.dts.formats.avro.Integer.Builder other) {
super(other);
if (isValidValue(fields()[0], other.precision)) {
this.precision = data().deepCopy(fields()[0].schema(), other.precision);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.value)) {
this.value = data().deepCopy(fields()[1].schema(), other.value);
fieldSetFlags()[1] = true;
}
}
/**
* Creates a Builder by copying an existing Integer instance
* @param other The existing instance to copy.
*/
private Builder(com.alibaba.dts.formats.avro.Integer other) {
super(SCHEMA$);
if (isValidValue(fields()[0], other.precision)) {
this.precision = data().deepCopy(fields()[0].schema(), other.precision);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.value)) {
this.value = data().deepCopy(fields()[1].schema(), other.value);
fieldSetFlags()[1] = true;
}
}
/**
* Gets the value of the 'precision' field.
* @return The value.
*/
public java.lang.Integer getPrecision() {
return precision;
}
/**
* Sets the value of the 'precision' field.
* @param value The value of 'precision'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Integer.Builder setPrecision(int value) {
validate(fields()[0], value);
this.precision = value;
fieldSetFlags()[0] = true;
return this;
}
/**
* Checks whether the 'precision' field has been set.
* @return True if the 'precision' field has been set, false otherwise.
*/
public boolean hasPrecision() {
return fieldSetFlags()[0];
}
/**
* Clears the value of the 'precision' field.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Integer.Builder clearPrecision() {
fieldSetFlags()[0] = false;
return this;
}
/**
* Gets the value of the 'value' field.
* @return The value.
*/
public java.lang.String getValue() {
return value;
}
/**
* Sets the value of the 'value' field.
* @param value The value of 'value'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Integer.Builder setValue(java.lang.String value) {
validate(fields()[1], value);
this.value = value;
fieldSetFlags()[1] = true;
return this;
}
/**
* Checks whether the 'value' field has been set.
* @return True if the 'value' field has been set, false otherwise.
*/
public boolean hasValue() {
return fieldSetFlags()[1];
}
/**
* Clears the value of the 'value' field.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Integer.Builder clearValue() {
value = null;
fieldSetFlags()[1] = false;
return this;
}
@Override
@SuppressWarnings("unchecked")
public Integer build() {
try {
Integer record = new Integer();
record.precision = fieldSetFlags()[0] ? this.precision : (java.lang.Integer) defaultValue(fields()[0]);
record.value = fieldSetFlags()[1] ? this.value : (java.lang.String) defaultValue(fields()[1]);
return record;
} catch (java.lang.Exception e) {
throw new org.apache.avro.AvroRuntimeException(e);
}
}
}
@SuppressWarnings("unchecked")
private static final org.apache.avro.io.DatumWriter<Integer>
WRITER$ = (org.apache.avro.io.DatumWriter<Integer>)MODEL$.createDatumWriter(SCHEMA$);
@Override public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException {
WRITER$.write(this, SpecificData.getEncoder(out));
}
@SuppressWarnings("unchecked")
private static final org.apache.avro.io.DatumReader<Integer>
READER$ = (org.apache.avro.io.DatumReader<Integer>)MODEL$.createDatumReader(SCHEMA$);
@Override public void readExternal(java.io.ObjectInput in)
throws java.io.IOException {
READER$.read(this, SpecificData.getDecoder(in));
}
}
/**
* Autogenerated by Avro
*
* DO NOT EDIT DIRECTLY
*/
package com.alibaba.dts.formats.avro;
@SuppressWarnings("all")
@org.apache.avro.specific.AvroGenerated
public enum Operation {
INSERT, UPDATE, DELETE, DDL, BEGIN, COMMIT, ROLLBACK, ABORT, HEARTBEAT, CHECKPOINT, COMMAND, FILL, FINISH, CONTROL, RDB, NOOP, INIT ;
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"enum\",\"name\":\"Operation\",\"namespace\":\"com.alibaba.dts.formats.avro\",\"symbols\":[\"INSERT\",\"UPDATE\",\"DELETE\",\"DDL\",\"BEGIN\",\"COMMIT\",\"ROLLBACK\",\"ABORT\",\"HEARTBEAT\",\"CHECKPOINT\",\"COMMAND\",\"FILL\",\"FINISH\",\"CONTROL\",\"RDB\",\"NOOP\",\"INIT\"]}");
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
}
/**
* Autogenerated by Avro
*
* DO NOT EDIT DIRECTLY
*/
package com.alibaba.dts.formats.avro;
import org.apache.avro.specific.SpecificData;
import org.apache.avro.message.BinaryMessageEncoder;
import org.apache.avro.message.BinaryMessageDecoder;
import org.apache.avro.message.SchemaStore;
@SuppressWarnings("all")
@org.apache.avro.specific.AvroGenerated
public class Record extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
private static final long serialVersionUID = -5842551457902705544L;
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Record\",\"namespace\":\"com.alibaba.dts.formats.avro\",\"fields\":[{\"name\":\"version\",\"type\":\"int\",\"doc\":\"version infomation\"},{\"name\":\"id\",\"type\":\"long\",\"doc\":\"unique id of this record in the whole stream\"},{\"name\":\"sourceTimestamp\",\"type\":\"long\",\"doc\":\"record log timestamp\"},{\"name\":\"sourcePosition\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"},\"doc\":\"record source location information\"},{\"name\":\"safeSourcePosition\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"},\"doc\":\"safe record source location information, use to recovery.\",\"default\":\"\"},{\"name\":\"sourceTxid\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"},\"doc\":\"record transation id\",\"default\":\"\"},{\"name\":\"source\",\"type\":{\"type\":\"record\",\"name\":\"Source\",\"fields\":[{\"name\":\"sourceType\",\"type\":{\"type\":\"enum\",\"name\":\"SourceType\",\"symbols\":[\"MySQL\",\"Oracle\",\"SQLServer\",\"PostgreSQL\",\"MongoDB\",\"Redis\",\"DB2\",\"PPAS\",\"DRDS\",\"HBASE\",\"HDFS\",\"FILE\",\"OTHER\"]}},{\"name\":\"version\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"},\"doc\":\"source datasource version information\"}]},\"doc\":\"source dataource\"},{\"name\":\"operation\",\"type\":{\"type\":\"enum\",\"name\":\"Operation\",\"symbols\":[\"INSERT\",\"UPDATE\",\"DELETE\",\"DDL\",\"BEGIN\",\"COMMIT\",\"ROLLBACK\",\"ABORT\",\"HEARTBEAT\",\"CHECKPOINT\",\"COMMAND\",\"FILL\",\"FINISH\",\"CONTROL\",\"RDB\",\"NOOP\",\"INIT\"]},\"namespace\":\"com.alibaba.dts.formats.avro\"},{\"name\":\"objectName\",\"type\":[\"null\",{\"type\":\"string\",\"avro.java.string\":\"String\"}],\"default\":null},{\"name\":\"processTimestamps\",\"type\":[\"null\",{\"type\":\"array\",\"items\":\"long\"}],\"doc\":\"time when this record is processed along the stream dataflow\",\"default\":null},{\"name\":\"tags\",\"type\":{\"type\":\"map\",\"values\":{\"type\":\"string\",\"avro.java.string\":\"String\"},\"avro.java.string\":\"String\"},\"doc\":\"tags to identify properties of this record\",\"default\":{}},{\"name\":\"fields\",\"type\":[\"null\",{\"type\":\"string\",\"avro.java.string\":\"String\"},{\"type\":\"array\",\"items\":{\"type\":\"record\",\"name\":\"Field\",\"fields\":[{\"name\":\"name\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"}},{\"name\":\"dataTypeNumber\",\"type\":\"int\"}]}}],\"default\":null},{\"name\":\"beforeImages\",\"type\":[\"null\",{\"type\":\"string\",\"avro.java.string\":\"String\"},{\"type\":\"array\",\"items\":[\"null\",{\"type\":\"record\",\"name\":\"Integer\",\"fields\":[{\"name\":\"precision\",\"type\":\"int\"},{\"name\":\"value\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"}}]},{\"type\":\"record\",\"name\":\"Character\",\"fields\":[{\"name\":\"charset\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"}},{\"name\":\"value\",\"type\":\"bytes\"}]},{\"type\":\"record\",\"name\":\"Decimal\",\"fields\":[{\"name\":\"value\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"}},{\"name\":\"precision\",\"type\":\"int\"},{\"name\":\"scale\",\"type\":\"int\"}]},{\"type\":\"record\",\"name\":\"Float\",\"fields\":[{\"name\":\"value\",\"type\":\"double\"},{\"name\":\"precision\",\"type\":\"int\"},{\"name\":\"scale\",\"type\":\"int\"}]},{\"type\":\"record\",\"name\":\"Timestamp\",\"fields\":[{\"name\":\"timestamp\",\"type\":\"long\"},{\"name\":\"millis\",\"type\":\"int\"}]},{\"type\":\"record\",\"name\":\"DateTime\",\"fields\":[{\"name\":\"year\",\"type\":[\"null\",\"int\"],\"default\":null},{\"name\":\"month\",\"type\":[\"null\",\"int\"],\"default\":null},{\"name\":\"day\",\"type\":[\"null\",\"int\"],\"default\":null},{\"name\":\"hour\",\"type\":[\"null\",\"int\"],\"default\":null},{\"name\":\"minute\",\"type\":[\"null\",\"int\"],\"default\":null},{\"name\":\"second\",\"type\":[\"null\",\"int\"],\"default\":null},{\"name\":\"millis\",\"type\":[\"null\",\"int\"],\"default\":null}]},{\"type\":\"record\",\"name\":\"TimestampWithTimeZone\",\"fields\":[{\"name\":\"value\",\"type\":\"DateTime\"},{\"name\":\"timezone\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"}}]},{\"type\":\"record\",\"name\":\"BinaryGeometry\",\"fields\":[{\"name\":\"type\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"}},{\"name\":\"value\",\"type\":\"bytes\"}]},{\"type\":\"record\",\"name\":\"TextGeometry\",\"fields\":[{\"name\":\"type\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"}},{\"name\":\"value\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"}}]},{\"type\":\"record\",\"name\":\"BinaryObject\",\"fields\":[{\"name\":\"type\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"}},{\"name\":\"value\",\"type\":\"bytes\"}]},{\"type\":\"record\",\"name\":\"TextObject\",\"fields\":[{\"name\":\"type\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"}},{\"name\":\"value\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"}}]},{\"type\":\"enum\",\"name\":\"EmptyObject\",\"symbols\":[\"NULL\",\"NONE\"]}]}],\"default\":null},{\"name\":\"afterImages\",\"type\":[\"null\",{\"type\":\"string\",\"avro.java.string\":\"String\"},{\"type\":\"array\",\"items\":[\"null\",\"Integer\",\"Character\",\"Decimal\",\"Float\",\"Timestamp\",\"DateTime\",\"TimestampWithTimeZone\",\"BinaryGeometry\",\"TextGeometry\",\"BinaryObject\",\"TextObject\",\"EmptyObject\"]}],\"default\":null},{\"name\":\"bornTimestamp\",\"type\":\"long\",\"doc\":\"the timestamp in unit of millisecond that record is born in source\",\"default\":0}]}");
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
private static SpecificData MODEL$ = new SpecificData();
private static final BinaryMessageEncoder<Record> ENCODER =
new BinaryMessageEncoder<Record>(MODEL$, SCHEMA$);
private static final BinaryMessageDecoder<Record> DECODER =
new BinaryMessageDecoder<Record>(MODEL$, SCHEMA$);
/**
* Return the BinaryMessageDecoder instance used by this class.
*/
public static BinaryMessageDecoder<Record> getDecoder() {
return DECODER;
}
/**
* Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
* @param resolver a {@link SchemaStore} used to find schemas by fingerprint
*/
public static BinaryMessageDecoder<Record> createDecoder(SchemaStore resolver) {
return new BinaryMessageDecoder<Record>(MODEL$, SCHEMA$, resolver);
}
/** Serializes this Record to a ByteBuffer. */
public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException {
return ENCODER.encode(this);
}
/** Deserializes a Record from a ByteBuffer. */
public static Record fromByteBuffer(
java.nio.ByteBuffer b) throws java.io.IOException {
return DECODER.decode(b);
}
/** version infomation */
@Deprecated public int version;
/** unique id of this record in the whole stream */
@Deprecated public long id;
/** record log timestamp */
@Deprecated public long sourceTimestamp;
/** record source location information */
@Deprecated public java.lang.String sourcePosition;
/** safe record source location information, use to recovery. */
@Deprecated public java.lang.String safeSourcePosition;
/** record transation id */
@Deprecated public java.lang.String sourceTxid;
/** source dataource */
@Deprecated public com.alibaba.dts.formats.avro.Source source;
@Deprecated public com.alibaba.dts.formats.avro.Operation operation;
@Deprecated public java.lang.String objectName;
/** time when this record is processed along the stream dataflow */
@Deprecated public java.util.List<java.lang.Long> processTimestamps;
/** tags to identify properties of this record */
@Deprecated public java.util.Map<java.lang.String,java.lang.String> tags;
@Deprecated public java.lang.Object fields;
@Deprecated public java.lang.Object beforeImages;
@Deprecated public java.lang.Object afterImages;
/** the timestamp in unit of millisecond that record is born in source */
@Deprecated public long bornTimestamp;
/**
* Default constructor. Note that this does not initialize fields
* to their default values from the schema. If that is desired then
* one should use <code>newBuilder()</code>.
*/
public Record() {}
/**
* All-args constructor.
* @param version version infomation
* @param id unique id of this record in the whole stream
* @param sourceTimestamp record log timestamp
* @param sourcePosition record source location information
* @param safeSourcePosition safe record source location information, use to recovery.
* @param sourceTxid record transation id
* @param source source dataource
* @param operation The new value for operation
* @param objectName The new value for objectName
* @param processTimestamps time when this record is processed along the stream dataflow
* @param tags tags to identify properties of this record
* @param fields The new value for fields
* @param beforeImages The new value for beforeImages
* @param afterImages The new value for afterImages
* @param bornTimestamp the timestamp in unit of millisecond that record is born in source
*/
public Record(java.lang.Integer version, java.lang.Long id, java.lang.Long sourceTimestamp, java.lang.String sourcePosition, java.lang.String safeSourcePosition, java.lang.String sourceTxid, com.alibaba.dts.formats.avro.Source source, com.alibaba.dts.formats.avro.Operation operation, java.lang.String objectName, java.util.List<java.lang.Long> processTimestamps, java.util.Map<java.lang.String,java.lang.String> tags, java.lang.Object fields, java.lang.Object beforeImages, java.lang.Object afterImages, java.lang.Long bornTimestamp) {
this.version = version;
this.id = id;
this.sourceTimestamp = sourceTimestamp;
this.sourcePosition = sourcePosition;
this.safeSourcePosition = safeSourcePosition;
this.sourceTxid = sourceTxid;
this.source = source;
this.operation = operation;
this.objectName = objectName;
this.processTimestamps = processTimestamps;
this.tags = tags;
this.fields = fields;
this.beforeImages = beforeImages;
this.afterImages = afterImages;
this.bornTimestamp = bornTimestamp;
}
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
// Used by DatumWriter. Applications should not call.
public java.lang.Object get(int field$) {
switch (field$) {
case 0: return version;
case 1: return id;
case 2: return sourceTimestamp;
case 3: return sourcePosition;
case 4: return safeSourcePosition;
case 5: return sourceTxid;
case 6: return source;
case 7: return operation;
case 8: return objectName;
case 9: return processTimestamps;
case 10: return tags;
case 11: return fields;
case 12: return beforeImages;
case 13: return afterImages;
case 14: return bornTimestamp;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
// Used by DatumReader. Applications should not call.
@SuppressWarnings(value="unchecked")
public void put(int field$, java.lang.Object value$) {
switch (field$) {
case 0: version = (java.lang.Integer)value$; break;
case 1: id = (java.lang.Long)value$; break;
case 2: sourceTimestamp = (java.lang.Long)value$; break;
case 3: sourcePosition = (java.lang.String)value$; break;
case 4: safeSourcePosition = (java.lang.String)value$; break;
case 5: sourceTxid = (java.lang.String)value$; break;
case 6: source = (com.alibaba.dts.formats.avro.Source)value$; break;
case 7: operation = (com.alibaba.dts.formats.avro.Operation)value$; break;
case 8: objectName = (java.lang.String)value$; break;
case 9: processTimestamps = (java.util.List<java.lang.Long>)value$; break;
case 10: tags = (java.util.Map<java.lang.String,java.lang.String>)value$; break;
case 11: fields = (java.lang.Object)value$; break;
case 12: beforeImages = (java.lang.Object)value$; break;
case 13: afterImages = (java.lang.Object)value$; break;
case 14: bornTimestamp = (java.lang.Long)value$; break;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
/**
* Gets the value of the 'version' field.
* @return version infomation
*/
public java.lang.Integer getVersion() {
return version;
}
/**
* Sets the value of the 'version' field.
* version infomation
* @param value the value to set.
*/
public void setVersion(java.lang.Integer value) {
this.version = value;
}
/**
* Gets the value of the 'id' field.
* @return unique id of this record in the whole stream
*/
public java.lang.Long getId() {
return id;
}
/**
* Sets the value of the 'id' field.
* unique id of this record in the whole stream
* @param value the value to set.
*/
public void setId(java.lang.Long value) {
this.id = value;
}
/**
* Gets the value of the 'sourceTimestamp' field.
* @return record log timestamp
*/
public java.lang.Long getSourceTimestamp() {
return sourceTimestamp;
}
/**
* Sets the value of the 'sourceTimestamp' field.
* record log timestamp
* @param value the value to set.
*/
public void setSourceTimestamp(java.lang.Long value) {
this.sourceTimestamp = value;
}
/**
* Gets the value of the 'sourcePosition' field.
* @return record source location information
*/
public java.lang.String getSourcePosition() {
return sourcePosition;
}
/**
* Sets the value of the 'sourcePosition' field.
* record source location information
* @param value the value to set.
*/
public void setSourcePosition(java.lang.String value) {
this.sourcePosition = value;
}
/**
* Gets the value of the 'safeSourcePosition' field.
* @return safe record source location information, use to recovery.
*/
public java.lang.String getSafeSourcePosition() {
return safeSourcePosition;
}
/**
* Sets the value of the 'safeSourcePosition' field.
* safe record source location information, use to recovery.
* @param value the value to set.
*/
public void setSafeSourcePosition(java.lang.String value) {
this.safeSourcePosition = value;
}
/**
* Gets the value of the 'sourceTxid' field.
* @return record transation id
*/
public java.lang.String getSourceTxid() {
return sourceTxid;
}
/**
* Sets the value of the 'sourceTxid' field.
* record transation id
* @param value the value to set.
*/
public void setSourceTxid(java.lang.String value) {
this.sourceTxid = value;
}
/**
* Gets the value of the 'source' field.
* @return source dataource
*/
public com.alibaba.dts.formats.avro.Source getSource() {
return source;
}
/**
* Sets the value of the 'source' field.
* source dataource
* @param value the value to set.
*/
public void setSource(com.alibaba.dts.formats.avro.Source value) {
this.source = value;
}
/**
* Gets the value of the 'operation' field.
* @return The value of the 'operation' field.
*/
public com.alibaba.dts.formats.avro.Operation getOperation() {
return operation;
}
/**
* Sets the value of the 'operation' field.
* @param value the value to set.
*/
public void setOperation(com.alibaba.dts.formats.avro.Operation value) {
this.operation = value;
}
/**
* Gets the value of the 'objectName' field.
* @return The value of the 'objectName' field.
*/
public java.lang.String getObjectName() {
return objectName;
}
/**
* Sets the value of the 'objectName' field.
* @param value the value to set.
*/
public void setObjectName(java.lang.String value) {
this.objectName = value;
}
/**
* Gets the value of the 'processTimestamps' field.
* @return time when this record is processed along the stream dataflow
*/
public java.util.List<java.lang.Long> getProcessTimestamps() {
return processTimestamps;
}
/**
* Sets the value of the 'processTimestamps' field.
* time when this record is processed along the stream dataflow
* @param value the value to set.
*/
public void setProcessTimestamps(java.util.List<java.lang.Long> value) {
this.processTimestamps = value;
}
/**
* Gets the value of the 'tags' field.
* @return tags to identify properties of this record
*/
public java.util.Map<java.lang.String,java.lang.String> getTags() {
return tags;
}
/**
* Sets the value of the 'tags' field.
* tags to identify properties of this record
* @param value the value to set.
*/
public void setTags(java.util.Map<java.lang.String,java.lang.String> value) {
this.tags = value;
}
/**
* Gets the value of the 'fields' field.
* @return The value of the 'fields' field.
*/
public java.lang.Object getFields() {
return fields;
}
/**
* Sets the value of the 'fields' field.
* @param value the value to set.
*/
public void setFields(java.lang.Object value) {
this.fields = value;
}
/**
* Gets the value of the 'beforeImages' field.
* @return The value of the 'beforeImages' field.
*/
public java.lang.Object getBeforeImages() {
return beforeImages;
}
/**
* Sets the value of the 'beforeImages' field.
* @param value the value to set.
*/
public void setBeforeImages(java.lang.Object value) {
this.beforeImages = value;
}
/**
* Gets the value of the 'afterImages' field.
* @return The value of the 'afterImages' field.
*/
public java.lang.Object getAfterImages() {
return afterImages;
}
/**
* Sets the value of the 'afterImages' field.
* @param value the value to set.
*/
public void setAfterImages(java.lang.Object value) {
this.afterImages = value;
}
/**
* Gets the value of the 'bornTimestamp' field.
* @return the timestamp in unit of millisecond that record is born in source
*/
public java.lang.Long getBornTimestamp() {
return bornTimestamp;
}
/**
* Sets the value of the 'bornTimestamp' field.
* the timestamp in unit of millisecond that record is born in source
* @param value the value to set.
*/
public void setBornTimestamp(java.lang.Long value) {
this.bornTimestamp = value;
}
/**
* Creates a new Record RecordBuilder.
* @return A new Record RecordBuilder
*/
public static com.alibaba.dts.formats.avro.Record.Builder newBuilder() {
return new com.alibaba.dts.formats.avro.Record.Builder();
}
/**
* Creates a new Record RecordBuilder by copying an existing Builder.
* @param other The existing builder to copy.
* @return A new Record RecordBuilder
*/
public static com.alibaba.dts.formats.avro.Record.Builder newBuilder(com.alibaba.dts.formats.avro.Record.Builder other) {
return new com.alibaba.dts.formats.avro.Record.Builder(other);
}
/**
* Creates a new Record RecordBuilder by copying an existing Record instance.
* @param other The existing instance to copy.
* @return A new Record RecordBuilder
*/
public static com.alibaba.dts.formats.avro.Record.Builder newBuilder(com.alibaba.dts.formats.avro.Record other) {
return new com.alibaba.dts.formats.avro.Record.Builder(other);
}
/**
* RecordBuilder for Record instances.
*/
public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<Record>
implements org.apache.avro.data.RecordBuilder<Record> {
/** version infomation */
private int version;
/** unique id of this record in the whole stream */
private long id;
/** record log timestamp */
private long sourceTimestamp;
/** record source location information */
private java.lang.String sourcePosition;
/** safe record source location information, use to recovery. */
private java.lang.String safeSourcePosition;
/** record transation id */
private java.lang.String sourceTxid;
/** source dataource */
private com.alibaba.dts.formats.avro.Source source;
private com.alibaba.dts.formats.avro.Source.Builder sourceBuilder;
private com.alibaba.dts.formats.avro.Operation operation;
private java.lang.String objectName;
/** time when this record is processed along the stream dataflow */
private java.util.List<java.lang.Long> processTimestamps;
/** tags to identify properties of this record */
private java.util.Map<java.lang.String,java.lang.String> tags;
private java.lang.Object fields;
private java.lang.Object beforeImages;
private java.lang.Object afterImages;
/** the timestamp in unit of millisecond that record is born in source */
private long bornTimestamp;
/** Creates a new Builder */
private Builder() {
super(SCHEMA$);
}
/**
* Creates a Builder by copying an existing Builder.
* @param other The existing Builder to copy.
*/
private Builder(com.alibaba.dts.formats.avro.Record.Builder other) {
super(other);
if (isValidValue(fields()[0], other.version)) {
this.version = data().deepCopy(fields()[0].schema(), other.version);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.id)) {
this.id = data().deepCopy(fields()[1].schema(), other.id);
fieldSetFlags()[1] = true;
}
if (isValidValue(fields()[2], other.sourceTimestamp)) {
this.sourceTimestamp = data().deepCopy(fields()[2].schema(), other.sourceTimestamp);
fieldSetFlags()[2] = true;
}
if (isValidValue(fields()[3], other.sourcePosition)) {
this.sourcePosition = data().deepCopy(fields()[3].schema(), other.sourcePosition);
fieldSetFlags()[3] = true;
}
if (isValidValue(fields()[4], other.safeSourcePosition)) {
this.safeSourcePosition = data().deepCopy(fields()[4].schema(), other.safeSourcePosition);
fieldSetFlags()[4] = true;
}
if (isValidValue(fields()[5], other.sourceTxid)) {
this.sourceTxid = data().deepCopy(fields()[5].schema(), other.sourceTxid);
fieldSetFlags()[5] = true;
}
if (isValidValue(fields()[6], other.source)) {
this.source = data().deepCopy(fields()[6].schema(), other.source);
fieldSetFlags()[6] = true;
}
if (other.hasSourceBuilder()) {
this.sourceBuilder = com.alibaba.dts.formats.avro.Source.newBuilder(other.getSourceBuilder());
}
if (isValidValue(fields()[7], other.operation)) {
this.operation = data().deepCopy(fields()[7].schema(), other.operation);
fieldSetFlags()[7] = true;
}
if (isValidValue(fields()[8], other.objectName)) {
this.objectName = data().deepCopy(fields()[8].schema(), other.objectName);
fieldSetFlags()[8] = true;
}
if (isValidValue(fields()[9], other.processTimestamps)) {
this.processTimestamps = data().deepCopy(fields()[9].schema(), other.processTimestamps);
fieldSetFlags()[9] = true;
}
if (isValidValue(fields()[10], other.tags)) {
this.tags = data().deepCopy(fields()[10].schema(), other.tags);
fieldSetFlags()[10] = true;
}
if (isValidValue(fields()[11], other.fields)) {
this.fields = data().deepCopy(fields()[11].schema(), other.fields);
fieldSetFlags()[11] = true;
}
if (isValidValue(fields()[12], other.beforeImages)) {
this.beforeImages = data().deepCopy(fields()[12].schema(), other.beforeImages);
fieldSetFlags()[12] = true;
}
if (isValidValue(fields()[13], other.afterImages)) {
this.afterImages = data().deepCopy(fields()[13].schema(), other.afterImages);
fieldSetFlags()[13] = true;
}
if (isValidValue(fields()[14], other.bornTimestamp)) {
this.bornTimestamp = data().deepCopy(fields()[14].schema(), other.bornTimestamp);
fieldSetFlags()[14] = true;
}
}
/**
* Creates a Builder by copying an existing Record instance
* @param other The existing instance to copy.
*/
private Builder(com.alibaba.dts.formats.avro.Record other) {
super(SCHEMA$);
if (isValidValue(fields()[0], other.version)) {
this.version = data().deepCopy(fields()[0].schema(), other.version);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.id)) {
this.id = data().deepCopy(fields()[1].schema(), other.id);
fieldSetFlags()[1] = true;
}
if (isValidValue(fields()[2], other.sourceTimestamp)) {
this.sourceTimestamp = data().deepCopy(fields()[2].schema(), other.sourceTimestamp);
fieldSetFlags()[2] = true;
}
if (isValidValue(fields()[3], other.sourcePosition)) {
this.sourcePosition = data().deepCopy(fields()[3].schema(), other.sourcePosition);
fieldSetFlags()[3] = true;
}
if (isValidValue(fields()[4], other.safeSourcePosition)) {
this.safeSourcePosition = data().deepCopy(fields()[4].schema(), other.safeSourcePosition);
fieldSetFlags()[4] = true;
}
if (isValidValue(fields()[5], other.sourceTxid)) {
this.sourceTxid = data().deepCopy(fields()[5].schema(), other.sourceTxid);
fieldSetFlags()[5] = true;
}
if (isValidValue(fields()[6], other.source)) {
this.source = data().deepCopy(fields()[6].schema(), other.source);
fieldSetFlags()[6] = true;
}
this.sourceBuilder = null;
if (isValidValue(fields()[7], other.operation)) {
this.operation = data().deepCopy(fields()[7].schema(), other.operation);
fieldSetFlags()[7] = true;
}
if (isValidValue(fields()[8], other.objectName)) {
this.objectName = data().deepCopy(fields()[8].schema(), other.objectName);
fieldSetFlags()[8] = true;
}
if (isValidValue(fields()[9], other.processTimestamps)) {
this.processTimestamps = data().deepCopy(fields()[9].schema(), other.processTimestamps);
fieldSetFlags()[9] = true;
}
if (isValidValue(fields()[10], other.tags)) {
this.tags = data().deepCopy(fields()[10].schema(), other.tags);
fieldSetFlags()[10] = true;
}
if (isValidValue(fields()[11], other.fields)) {
this.fields = data().deepCopy(fields()[11].schema(), other.fields);
fieldSetFlags()[11] = true;
}
if (isValidValue(fields()[12], other.beforeImages)) {
this.beforeImages = data().deepCopy(fields()[12].schema(), other.beforeImages);
fieldSetFlags()[12] = true;
}
if (isValidValue(fields()[13], other.afterImages)) {
this.afterImages = data().deepCopy(fields()[13].schema(), other.afterImages);
fieldSetFlags()[13] = true;
}
if (isValidValue(fields()[14], other.bornTimestamp)) {
this.bornTimestamp = data().deepCopy(fields()[14].schema(), other.bornTimestamp);
fieldSetFlags()[14] = true;
}
}
/**
* Gets the value of the 'version' field.
* version infomation
* @return The value.
*/
public java.lang.Integer getVersion() {
return version;
}
/**
* Sets the value of the 'version' field.
* version infomation
* @param value The value of 'version'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Record.Builder setVersion(int value) {
validate(fields()[0], value);
this.version = value;
fieldSetFlags()[0] = true;
return this;
}
/**
* Checks whether the 'version' field has been set.
* version infomation
* @return True if the 'version' field has been set, false otherwise.
*/
public boolean hasVersion() {
return fieldSetFlags()[0];
}
/**
* Clears the value of the 'version' field.
* version infomation
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Record.Builder clearVersion() {
fieldSetFlags()[0] = false;
return this;
}
/**
* Gets the value of the 'id' field.
* unique id of this record in the whole stream
* @return The value.
*/
public java.lang.Long getId() {
return id;
}
/**
* Sets the value of the 'id' field.
* unique id of this record in the whole stream
* @param value The value of 'id'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Record.Builder setId(long value) {
validate(fields()[1], value);
this.id = value;
fieldSetFlags()[1] = true;
return this;
}
/**
* Checks whether the 'id' field has been set.
* unique id of this record in the whole stream
* @return True if the 'id' field has been set, false otherwise.
*/
public boolean hasId() {
return fieldSetFlags()[1];
}
/**
* Clears the value of the 'id' field.
* unique id of this record in the whole stream
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Record.Builder clearId() {
fieldSetFlags()[1] = false;
return this;
}
/**
* Gets the value of the 'sourceTimestamp' field.
* record log timestamp
* @return The value.
*/
public java.lang.Long getSourceTimestamp() {
return sourceTimestamp;
}
/**
* Sets the value of the 'sourceTimestamp' field.
* record log timestamp
* @param value The value of 'sourceTimestamp'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Record.Builder setSourceTimestamp(long value) {
validate(fields()[2], value);
this.sourceTimestamp = value;
fieldSetFlags()[2] = true;
return this;
}
/**
* Checks whether the 'sourceTimestamp' field has been set.
* record log timestamp
* @return True if the 'sourceTimestamp' field has been set, false otherwise.
*/
public boolean hasSourceTimestamp() {
return fieldSetFlags()[2];
}
/**
* Clears the value of the 'sourceTimestamp' field.
* record log timestamp
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Record.Builder clearSourceTimestamp() {
fieldSetFlags()[2] = false;
return this;
}
/**
* Gets the value of the 'sourcePosition' field.
* record source location information
* @return The value.
*/
public java.lang.String getSourcePosition() {
return sourcePosition;
}
/**
* Sets the value of the 'sourcePosition' field.
* record source location information
* @param value The value of 'sourcePosition'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Record.Builder setSourcePosition(java.lang.String value) {
validate(fields()[3], value);
this.sourcePosition = value;
fieldSetFlags()[3] = true;
return this;
}
/**
* Checks whether the 'sourcePosition' field has been set.
* record source location information
* @return True if the 'sourcePosition' field has been set, false otherwise.
*/
public boolean hasSourcePosition() {
return fieldSetFlags()[3];
}
/**
* Clears the value of the 'sourcePosition' field.
* record source location information
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Record.Builder clearSourcePosition() {
sourcePosition = null;
fieldSetFlags()[3] = false;
return this;
}
/**
* Gets the value of the 'safeSourcePosition' field.
* safe record source location information, use to recovery.
* @return The value.
*/
public java.lang.String getSafeSourcePosition() {
return safeSourcePosition;
}
/**
* Sets the value of the 'safeSourcePosition' field.
* safe record source location information, use to recovery.
* @param value The value of 'safeSourcePosition'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Record.Builder setSafeSourcePosition(java.lang.String value) {
validate(fields()[4], value);
this.safeSourcePosition = value;
fieldSetFlags()[4] = true;
return this;
}
/**
* Checks whether the 'safeSourcePosition' field has been set.
* safe record source location information, use to recovery.
* @return True if the 'safeSourcePosition' field has been set, false otherwise.
*/
public boolean hasSafeSourcePosition() {
return fieldSetFlags()[4];
}
/**
* Clears the value of the 'safeSourcePosition' field.
* safe record source location information, use to recovery.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Record.Builder clearSafeSourcePosition() {
safeSourcePosition = null;
fieldSetFlags()[4] = false;
return this;
}
/**
* Gets the value of the 'sourceTxid' field.
* record transation id
* @return The value.
*/
public java.lang.String getSourceTxid() {
return sourceTxid;
}
/**
* Sets the value of the 'sourceTxid' field.
* record transation id
* @param value The value of 'sourceTxid'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Record.Builder setSourceTxid(java.lang.String value) {
validate(fields()[5], value);
this.sourceTxid = value;
fieldSetFlags()[5] = true;
return this;
}
/**
* Checks whether the 'sourceTxid' field has been set.
* record transation id
* @return True if the 'sourceTxid' field has been set, false otherwise.
*/
public boolean hasSourceTxid() {
return fieldSetFlags()[5];
}
/**
* Clears the value of the 'sourceTxid' field.
* record transation id
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Record.Builder clearSourceTxid() {
sourceTxid = null;
fieldSetFlags()[5] = false;
return this;
}
/**
* Gets the value of the 'source' field.
* source dataource
* @return The value.
*/
public com.alibaba.dts.formats.avro.Source getSource() {
return source;
}
/**
* Sets the value of the 'source' field.
* source dataource
* @param value The value of 'source'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Record.Builder setSource(com.alibaba.dts.formats.avro.Source value) {
validate(fields()[6], value);
this.sourceBuilder = null;
this.source = value;
fieldSetFlags()[6] = true;
return this;
}
/**
* Checks whether the 'source' field has been set.
* source dataource
* @return True if the 'source' field has been set, false otherwise.
*/
public boolean hasSource() {
return fieldSetFlags()[6];
}
/**
* Gets the Builder instance for the 'source' field and creates one if it doesn't exist yet.
* source dataource
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Source.Builder getSourceBuilder() {
if (sourceBuilder == null) {
if (hasSource()) {
setSourceBuilder(com.alibaba.dts.formats.avro.Source.newBuilder(source));
} else {
setSourceBuilder(com.alibaba.dts.formats.avro.Source.newBuilder());
}
}
return sourceBuilder;
}
/**
* Sets the Builder instance for the 'source' field
* source dataource
* @param value The builder instance that must be set.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Record.Builder setSourceBuilder(com.alibaba.dts.formats.avro.Source.Builder value) {
clearSource();
sourceBuilder = value;
return this;
}
/**
* Checks whether the 'source' field has an active Builder instance
* source dataource
* @return True if the 'source' field has an active Builder instance
*/
public boolean hasSourceBuilder() {
return sourceBuilder != null;
}
/**
* Clears the value of the 'source' field.
* source dataource
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Record.Builder clearSource() {
source = null;
sourceBuilder = null;
fieldSetFlags()[6] = false;
return this;
}
/**
* Gets the value of the 'operation' field.
* @return The value.
*/
public com.alibaba.dts.formats.avro.Operation getOperation() {
return operation;
}
/**
* Sets the value of the 'operation' field.
* @param value The value of 'operation'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Record.Builder setOperation(com.alibaba.dts.formats.avro.Operation value) {
validate(fields()[7], value);
this.operation = value;
fieldSetFlags()[7] = true;
return this;
}
/**
* Checks whether the 'operation' field has been set.
* @return True if the 'operation' field has been set, false otherwise.
*/
public boolean hasOperation() {
return fieldSetFlags()[7];
}
/**
* Clears the value of the 'operation' field.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Record.Builder clearOperation() {
operation = null;
fieldSetFlags()[7] = false;
return this;
}
/**
* Gets the value of the 'objectName' field.
* @return The value.
*/
public java.lang.String getObjectName() {
return objectName;
}
/**
* Sets the value of the 'objectName' field.
* @param value The value of 'objectName'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Record.Builder setObjectName(java.lang.String value) {
validate(fields()[8], value);
this.objectName = value;
fieldSetFlags()[8] = true;
return this;
}
/**
* Checks whether the 'objectName' field has been set.
* @return True if the 'objectName' field has been set, false otherwise.
*/
public boolean hasObjectName() {
return fieldSetFlags()[8];
}
/**
* Clears the value of the 'objectName' field.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Record.Builder clearObjectName() {
objectName = null;
fieldSetFlags()[8] = false;
return this;
}
/**
* Gets the value of the 'processTimestamps' field.
* time when this record is processed along the stream dataflow
* @return The value.
*/
public java.util.List<java.lang.Long> getProcessTimestamps() {
return processTimestamps;
}
/**
* Sets the value of the 'processTimestamps' field.
* time when this record is processed along the stream dataflow
* @param value The value of 'processTimestamps'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Record.Builder setProcessTimestamps(java.util.List<java.lang.Long> value) {
validate(fields()[9], value);
this.processTimestamps = value;
fieldSetFlags()[9] = true;
return this;
}
/**
* Checks whether the 'processTimestamps' field has been set.
* time when this record is processed along the stream dataflow
* @return True if the 'processTimestamps' field has been set, false otherwise.
*/
public boolean hasProcessTimestamps() {
return fieldSetFlags()[9];
}
/**
* Clears the value of the 'processTimestamps' field.
* time when this record is processed along the stream dataflow
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Record.Builder clearProcessTimestamps() {
processTimestamps = null;
fieldSetFlags()[9] = false;
return this;
}
/**
* Gets the value of the 'tags' field.
* tags to identify properties of this record
* @return The value.
*/
public java.util.Map<java.lang.String,java.lang.String> getTags() {
return tags;
}
/**
* Sets the value of the 'tags' field.
* tags to identify properties of this record
* @param value The value of 'tags'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Record.Builder setTags(java.util.Map<java.lang.String,java.lang.String> value) {
validate(fields()[10], value);
this.tags = value;
fieldSetFlags()[10] = true;
return this;
}
/**
* Checks whether the 'tags' field has been set.
* tags to identify properties of this record
* @return True if the 'tags' field has been set, false otherwise.
*/
public boolean hasTags() {
return fieldSetFlags()[10];
}
/**
* Clears the value of the 'tags' field.
* tags to identify properties of this record
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Record.Builder clearTags() {
tags = null;
fieldSetFlags()[10] = false;
return this;
}
/**
* Gets the value of the 'fields' field.
* @return The value.
*/
public java.lang.Object getFields() {
return fields;
}
/**
* Sets the value of the 'fields' field.
* @param value The value of 'fields'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Record.Builder setFields(java.lang.Object value) {
validate(fields()[11], value);
this.fields = value;
fieldSetFlags()[11] = true;
return this;
}
/**
* Checks whether the 'fields' field has been set.
* @return True if the 'fields' field has been set, false otherwise.
*/
public boolean hasFields() {
return fieldSetFlags()[11];
}
/**
* Clears the value of the 'fields' field.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Record.Builder clearFields() {
fields = null;
fieldSetFlags()[11] = false;
return this;
}
/**
* Gets the value of the 'beforeImages' field.
* @return The value.
*/
public java.lang.Object getBeforeImages() {
return beforeImages;
}
/**
* Sets the value of the 'beforeImages' field.
* @param value The value of 'beforeImages'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Record.Builder setBeforeImages(java.lang.Object value) {
validate(fields()[12], value);
this.beforeImages = value;
fieldSetFlags()[12] = true;
return this;
}
/**
* Checks whether the 'beforeImages' field has been set.
* @return True if the 'beforeImages' field has been set, false otherwise.
*/
public boolean hasBeforeImages() {
return fieldSetFlags()[12];
}
/**
* Clears the value of the 'beforeImages' field.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Record.Builder clearBeforeImages() {
beforeImages = null;
fieldSetFlags()[12] = false;
return this;
}
/**
* Gets the value of the 'afterImages' field.
* @return The value.
*/
public java.lang.Object getAfterImages() {
return afterImages;
}
/**
* Sets the value of the 'afterImages' field.
* @param value The value of 'afterImages'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Record.Builder setAfterImages(java.lang.Object value) {
validate(fields()[13], value);
this.afterImages = value;
fieldSetFlags()[13] = true;
return this;
}
/**
* Checks whether the 'afterImages' field has been set.
* @return True if the 'afterImages' field has been set, false otherwise.
*/
public boolean hasAfterImages() {
return fieldSetFlags()[13];
}
/**
* Clears the value of the 'afterImages' field.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Record.Builder clearAfterImages() {
afterImages = null;
fieldSetFlags()[13] = false;
return this;
}
/**
* Gets the value of the 'bornTimestamp' field.
* the timestamp in unit of millisecond that record is born in source
* @return The value.
*/
public java.lang.Long getBornTimestamp() {
return bornTimestamp;
}
/**
* Sets the value of the 'bornTimestamp' field.
* the timestamp in unit of millisecond that record is born in source
* @param value The value of 'bornTimestamp'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Record.Builder setBornTimestamp(long value) {
validate(fields()[14], value);
this.bornTimestamp = value;
fieldSetFlags()[14] = true;
return this;
}
/**
* Checks whether the 'bornTimestamp' field has been set.
* the timestamp in unit of millisecond that record is born in source
* @return True if the 'bornTimestamp' field has been set, false otherwise.
*/
public boolean hasBornTimestamp() {
return fieldSetFlags()[14];
}
/**
* Clears the value of the 'bornTimestamp' field.
* the timestamp in unit of millisecond that record is born in source
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Record.Builder clearBornTimestamp() {
fieldSetFlags()[14] = false;
return this;
}
@Override
@SuppressWarnings("unchecked")
public Record build() {
try {
Record record = new Record();
record.version = fieldSetFlags()[0] ? this.version : (java.lang.Integer) defaultValue(fields()[0]);
record.id = fieldSetFlags()[1] ? this.id : (java.lang.Long) defaultValue(fields()[1]);
record.sourceTimestamp = fieldSetFlags()[2] ? this.sourceTimestamp : (java.lang.Long) defaultValue(fields()[2]);
record.sourcePosition = fieldSetFlags()[3] ? this.sourcePosition : (java.lang.String) defaultValue(fields()[3]);
record.safeSourcePosition = fieldSetFlags()[4] ? this.safeSourcePosition : (java.lang.String) defaultValue(fields()[4]);
record.sourceTxid = fieldSetFlags()[5] ? this.sourceTxid : (java.lang.String) defaultValue(fields()[5]);
if (sourceBuilder != null) {
record.source = this.sourceBuilder.build();
} else {
record.source = fieldSetFlags()[6] ? this.source : (com.alibaba.dts.formats.avro.Source) defaultValue(fields()[6]);
}
record.operation = fieldSetFlags()[7] ? this.operation : (com.alibaba.dts.formats.avro.Operation) defaultValue(fields()[7]);
record.objectName = fieldSetFlags()[8] ? this.objectName : (java.lang.String) defaultValue(fields()[8]);
record.processTimestamps = fieldSetFlags()[9] ? this.processTimestamps : (java.util.List<java.lang.Long>) defaultValue(fields()[9]);
record.tags = fieldSetFlags()[10] ? this.tags : (java.util.Map<java.lang.String,java.lang.String>) defaultValue(fields()[10]);
record.fields = fieldSetFlags()[11] ? this.fields : (java.lang.Object) defaultValue(fields()[11]);
record.beforeImages = fieldSetFlags()[12] ? this.beforeImages : (java.lang.Object) defaultValue(fields()[12]);
record.afterImages = fieldSetFlags()[13] ? this.afterImages : (java.lang.Object) defaultValue(fields()[13]);
record.bornTimestamp = fieldSetFlags()[14] ? this.bornTimestamp : (java.lang.Long) defaultValue(fields()[14]);
return record;
} catch (java.lang.Exception e) {
throw new org.apache.avro.AvroRuntimeException(e);
}
}
}
@SuppressWarnings("unchecked")
private static final org.apache.avro.io.DatumWriter<Record>
WRITER$ = (org.apache.avro.io.DatumWriter<Record>)MODEL$.createDatumWriter(SCHEMA$);
@Override public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException {
WRITER$.write(this, SpecificData.getEncoder(out));
}
@SuppressWarnings("unchecked")
private static final org.apache.avro.io.DatumReader<Record>
READER$ = (org.apache.avro.io.DatumReader<Record>)MODEL$.createDatumReader(SCHEMA$);
@Override public void readExternal(java.io.ObjectInput in)
throws java.io.IOException {
READER$.read(this, SpecificData.getDecoder(in));
}
}
/**
* Autogenerated by Avro
*
* DO NOT EDIT DIRECTLY
*/
package com.alibaba.dts.formats.avro;
import org.apache.avro.specific.SpecificData;
import org.apache.avro.message.BinaryMessageEncoder;
import org.apache.avro.message.BinaryMessageDecoder;
import org.apache.avro.message.SchemaStore;
@SuppressWarnings("all")
@org.apache.avro.specific.AvroGenerated
public class Source extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
private static final long serialVersionUID = 8841831948671771482L;
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Source\",\"namespace\":\"com.alibaba.dts.formats.avro\",\"fields\":[{\"name\":\"sourceType\",\"type\":{\"type\":\"enum\",\"name\":\"SourceType\",\"symbols\":[\"MySQL\",\"Oracle\",\"SQLServer\",\"PostgreSQL\",\"MongoDB\",\"Redis\",\"DB2\",\"PPAS\",\"DRDS\",\"HBASE\",\"HDFS\",\"FILE\",\"OTHER\"]}},{\"name\":\"version\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"},\"doc\":\"source datasource version information\"}]}");
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
private static SpecificData MODEL$ = new SpecificData();
private static final BinaryMessageEncoder<Source> ENCODER =
new BinaryMessageEncoder<Source>(MODEL$, SCHEMA$);
private static final BinaryMessageDecoder<Source> DECODER =
new BinaryMessageDecoder<Source>(MODEL$, SCHEMA$);
/**
* Return the BinaryMessageDecoder instance used by this class.
*/
public static BinaryMessageDecoder<Source> getDecoder() {
return DECODER;
}
/**
* Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
* @param resolver a {@link SchemaStore} used to find schemas by fingerprint
*/
public static BinaryMessageDecoder<Source> createDecoder(SchemaStore resolver) {
return new BinaryMessageDecoder<Source>(MODEL$, SCHEMA$, resolver);
}
/** Serializes this Source to a ByteBuffer. */
public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException {
return ENCODER.encode(this);
}
/** Deserializes a Source from a ByteBuffer. */
public static Source fromByteBuffer(
java.nio.ByteBuffer b) throws java.io.IOException {
return DECODER.decode(b);
}
@Deprecated public com.alibaba.dts.formats.avro.SourceType sourceType;
/** source datasource version information */
@Deprecated public java.lang.String version;
/**
* Default constructor. Note that this does not initialize fields
* to their default values from the schema. If that is desired then
* one should use <code>newBuilder()</code>.
*/
public Source() {}
/**
* All-args constructor.
* @param sourceType The new value for sourceType
* @param version source datasource version information
*/
public Source(com.alibaba.dts.formats.avro.SourceType sourceType, java.lang.String version) {
this.sourceType = sourceType;
this.version = version;
}
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
// Used by DatumWriter. Applications should not call.
public java.lang.Object get(int field$) {
switch (field$) {
case 0: return sourceType;
case 1: return version;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
// Used by DatumReader. Applications should not call.
@SuppressWarnings(value="unchecked")
public void put(int field$, java.lang.Object value$) {
switch (field$) {
case 0: sourceType = (com.alibaba.dts.formats.avro.SourceType)value$; break;
case 1: version = (java.lang.String)value$; break;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
/**
* Gets the value of the 'sourceType' field.
* @return The value of the 'sourceType' field.
*/
public com.alibaba.dts.formats.avro.SourceType getSourceType() {
return sourceType;
}
/**
* Sets the value of the 'sourceType' field.
* @param value the value to set.
*/
public void setSourceType(com.alibaba.dts.formats.avro.SourceType value) {
this.sourceType = value;
}
/**
* Gets the value of the 'version' field.
* @return source datasource version information
*/
public java.lang.String getVersion() {
return version;
}
/**
* Sets the value of the 'version' field.
* source datasource version information
* @param value the value to set.
*/
public void setVersion(java.lang.String value) {
this.version = value;
}
/**
* Creates a new Source RecordBuilder.
* @return A new Source RecordBuilder
*/
public static com.alibaba.dts.formats.avro.Source.Builder newBuilder() {
return new com.alibaba.dts.formats.avro.Source.Builder();
}
/**
* Creates a new Source RecordBuilder by copying an existing Builder.
* @param other The existing builder to copy.
* @return A new Source RecordBuilder
*/
public static com.alibaba.dts.formats.avro.Source.Builder newBuilder(com.alibaba.dts.formats.avro.Source.Builder other) {
return new com.alibaba.dts.formats.avro.Source.Builder(other);
}
/**
* Creates a new Source RecordBuilder by copying an existing Source instance.
* @param other The existing instance to copy.
* @return A new Source RecordBuilder
*/
public static com.alibaba.dts.formats.avro.Source.Builder newBuilder(com.alibaba.dts.formats.avro.Source other) {
return new com.alibaba.dts.formats.avro.Source.Builder(other);
}
/**
* RecordBuilder for Source instances.
*/
public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<Source>
implements org.apache.avro.data.RecordBuilder<Source> {
private com.alibaba.dts.formats.avro.SourceType sourceType;
/** source datasource version information */
private java.lang.String version;
/** Creates a new Builder */
private Builder() {
super(SCHEMA$);
}
/**
* Creates a Builder by copying an existing Builder.
* @param other The existing Builder to copy.
*/
private Builder(com.alibaba.dts.formats.avro.Source.Builder other) {
super(other);
if (isValidValue(fields()[0], other.sourceType)) {
this.sourceType = data().deepCopy(fields()[0].schema(), other.sourceType);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.version)) {
this.version = data().deepCopy(fields()[1].schema(), other.version);
fieldSetFlags()[1] = true;
}
}
/**
* Creates a Builder by copying an existing Source instance
* @param other The existing instance to copy.
*/
private Builder(com.alibaba.dts.formats.avro.Source other) {
super(SCHEMA$);
if (isValidValue(fields()[0], other.sourceType)) {
this.sourceType = data().deepCopy(fields()[0].schema(), other.sourceType);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.version)) {
this.version = data().deepCopy(fields()[1].schema(), other.version);
fieldSetFlags()[1] = true;
}
}
/**
* Gets the value of the 'sourceType' field.
* @return The value.
*/
public com.alibaba.dts.formats.avro.SourceType getSourceType() {
return sourceType;
}
/**
* Sets the value of the 'sourceType' field.
* @param value The value of 'sourceType'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Source.Builder setSourceType(com.alibaba.dts.formats.avro.SourceType value) {
validate(fields()[0], value);
this.sourceType = value;
fieldSetFlags()[0] = true;
return this;
}
/**
* Checks whether the 'sourceType' field has been set.
* @return True if the 'sourceType' field has been set, false otherwise.
*/
public boolean hasSourceType() {
return fieldSetFlags()[0];
}
/**
* Clears the value of the 'sourceType' field.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Source.Builder clearSourceType() {
sourceType = null;
fieldSetFlags()[0] = false;
return this;
}
/**
* Gets the value of the 'version' field.
* source datasource version information
* @return The value.
*/
public java.lang.String getVersion() {
return version;
}
/**
* Sets the value of the 'version' field.
* source datasource version information
* @param value The value of 'version'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Source.Builder setVersion(java.lang.String value) {
validate(fields()[1], value);
this.version = value;
fieldSetFlags()[1] = true;
return this;
}
/**
* Checks whether the 'version' field has been set.
* source datasource version information
* @return True if the 'version' field has been set, false otherwise.
*/
public boolean hasVersion() {
return fieldSetFlags()[1];
}
/**
* Clears the value of the 'version' field.
* source datasource version information
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Source.Builder clearVersion() {
version = null;
fieldSetFlags()[1] = false;
return this;
}
@Override
@SuppressWarnings("unchecked")
public Source build() {
try {
Source record = new Source();
record.sourceType = fieldSetFlags()[0] ? this.sourceType : (com.alibaba.dts.formats.avro.SourceType) defaultValue(fields()[0]);
record.version = fieldSetFlags()[1] ? this.version : (java.lang.String) defaultValue(fields()[1]);
return record;
} catch (java.lang.Exception e) {
throw new org.apache.avro.AvroRuntimeException(e);
}
}
}
@SuppressWarnings("unchecked")
private static final org.apache.avro.io.DatumWriter<Source>
WRITER$ = (org.apache.avro.io.DatumWriter<Source>)MODEL$.createDatumWriter(SCHEMA$);
@Override public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException {
WRITER$.write(this, SpecificData.getEncoder(out));
}
@SuppressWarnings("unchecked")
private static final org.apache.avro.io.DatumReader<Source>
READER$ = (org.apache.avro.io.DatumReader<Source>)MODEL$.createDatumReader(SCHEMA$);
@Override public void readExternal(java.io.ObjectInput in)
throws java.io.IOException {
READER$.read(this, SpecificData.getDecoder(in));
}
}
/**
* Autogenerated by Avro
*
* DO NOT EDIT DIRECTLY
*/
package com.alibaba.dts.formats.avro;
@SuppressWarnings("all")
@org.apache.avro.specific.AvroGenerated
public enum SourceType {
MySQL, Oracle, SQLServer, PostgreSQL, MongoDB, Redis, DB2, PPAS, DRDS, HBASE, HDFS, FILE, OTHER ;
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"enum\",\"name\":\"SourceType\",\"namespace\":\"com.alibaba.dts.formats.avro\",\"symbols\":[\"MySQL\",\"Oracle\",\"SQLServer\",\"PostgreSQL\",\"MongoDB\",\"Redis\",\"DB2\",\"PPAS\",\"DRDS\",\"HBASE\",\"HDFS\",\"FILE\",\"OTHER\"]}");
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
}
/**
* Autogenerated by Avro
*
* DO NOT EDIT DIRECTLY
*/
package com.alibaba.dts.formats.avro;
import org.apache.avro.specific.SpecificData;
import org.apache.avro.message.BinaryMessageEncoder;
import org.apache.avro.message.BinaryMessageDecoder;
import org.apache.avro.message.SchemaStore;
@SuppressWarnings("all")
@org.apache.avro.specific.AvroGenerated
public class TextGeometry extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
private static final long serialVersionUID = 8264944508099388832L;
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"TextGeometry\",\"namespace\":\"com.alibaba.dts.formats.avro\",\"fields\":[{\"name\":\"type\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"}},{\"name\":\"value\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"}}]}");
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
private static SpecificData MODEL$ = new SpecificData();
private static final BinaryMessageEncoder<TextGeometry> ENCODER =
new BinaryMessageEncoder<TextGeometry>(MODEL$, SCHEMA$);
private static final BinaryMessageDecoder<TextGeometry> DECODER =
new BinaryMessageDecoder<TextGeometry>(MODEL$, SCHEMA$);
/**
* Return the BinaryMessageDecoder instance used by this class.
*/
public static BinaryMessageDecoder<TextGeometry> getDecoder() {
return DECODER;
}
/**
* Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
* @param resolver a {@link SchemaStore} used to find schemas by fingerprint
*/
public static BinaryMessageDecoder<TextGeometry> createDecoder(SchemaStore resolver) {
return new BinaryMessageDecoder<TextGeometry>(MODEL$, SCHEMA$, resolver);
}
/** Serializes this TextGeometry to a ByteBuffer. */
public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException {
return ENCODER.encode(this);
}
/** Deserializes a TextGeometry from a ByteBuffer. */
public static TextGeometry fromByteBuffer(
java.nio.ByteBuffer b) throws java.io.IOException {
return DECODER.decode(b);
}
@Deprecated public java.lang.String type;
@Deprecated public java.lang.String value;
/**
* Default constructor. Note that this does not initialize fields
* to their default values from the schema. If that is desired then
* one should use <code>newBuilder()</code>.
*/
public TextGeometry() {}
/**
* All-args constructor.
* @param type The new value for type
* @param value The new value for value
*/
public TextGeometry(java.lang.String type, java.lang.String value) {
this.type = type;
this.value = value;
}
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
// Used by DatumWriter. Applications should not call.
public java.lang.Object get(int field$) {
switch (field$) {
case 0: return type;
case 1: return value;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
// Used by DatumReader. Applications should not call.
@SuppressWarnings(value="unchecked")
public void put(int field$, java.lang.Object value$) {
switch (field$) {
case 0: type = (java.lang.String)value$; break;
case 1: value = (java.lang.String)value$; break;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
/**
* Gets the value of the 'type' field.
* @return The value of the 'type' field.
*/
public java.lang.String getType() {
return type;
}
/**
* Sets the value of the 'type' field.
* @param value the value to set.
*/
public void setType(java.lang.String value) {
this.type = value;
}
/**
* Gets the value of the 'value' field.
* @return The value of the 'value' field.
*/
public java.lang.String getValue() {
return value;
}
/**
* Sets the value of the 'value' field.
* @param value the value to set.
*/
public void setValue(java.lang.String value) {
this.value = value;
}
/**
* Creates a new TextGeometry RecordBuilder.
* @return A new TextGeometry RecordBuilder
*/
public static com.alibaba.dts.formats.avro.TextGeometry.Builder newBuilder() {
return new com.alibaba.dts.formats.avro.TextGeometry.Builder();
}
/**
* Creates a new TextGeometry RecordBuilder by copying an existing Builder.
* @param other The existing builder to copy.
* @return A new TextGeometry RecordBuilder
*/
public static com.alibaba.dts.formats.avro.TextGeometry.Builder newBuilder(com.alibaba.dts.formats.avro.TextGeometry.Builder other) {
return new com.alibaba.dts.formats.avro.TextGeometry.Builder(other);
}
/**
* Creates a new TextGeometry RecordBuilder by copying an existing TextGeometry instance.
* @param other The existing instance to copy.
* @return A new TextGeometry RecordBuilder
*/
public static com.alibaba.dts.formats.avro.TextGeometry.Builder newBuilder(com.alibaba.dts.formats.avro.TextGeometry other) {
return new com.alibaba.dts.formats.avro.TextGeometry.Builder(other);
}
/**
* RecordBuilder for TextGeometry instances.
*/
public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<TextGeometry>
implements org.apache.avro.data.RecordBuilder<TextGeometry> {
private java.lang.String type;
private java.lang.String value;
/** Creates a new Builder */
private Builder() {
super(SCHEMA$);
}
/**
* Creates a Builder by copying an existing Builder.
* @param other The existing Builder to copy.
*/
private Builder(com.alibaba.dts.formats.avro.TextGeometry.Builder other) {
super(other);
if (isValidValue(fields()[0], other.type)) {
this.type = data().deepCopy(fields()[0].schema(), other.type);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.value)) {
this.value = data().deepCopy(fields()[1].schema(), other.value);
fieldSetFlags()[1] = true;
}
}
/**
* Creates a Builder by copying an existing TextGeometry instance
* @param other The existing instance to copy.
*/
private Builder(com.alibaba.dts.formats.avro.TextGeometry other) {
super(SCHEMA$);
if (isValidValue(fields()[0], other.type)) {
this.type = data().deepCopy(fields()[0].schema(), other.type);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.value)) {
this.value = data().deepCopy(fields()[1].schema(), other.value);
fieldSetFlags()[1] = true;
}
}
/**
* Gets the value of the 'type' field.
* @return The value.
*/
public java.lang.String getType() {
return type;
}
/**
* Sets the value of the 'type' field.
* @param value The value of 'type'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.TextGeometry.Builder setType(java.lang.String value) {
validate(fields()[0], value);
this.type = value;
fieldSetFlags()[0] = true;
return this;
}
/**
* Checks whether the 'type' field has been set.
* @return True if the 'type' field has been set, false otherwise.
*/
public boolean hasType() {
return fieldSetFlags()[0];
}
/**
* Clears the value of the 'type' field.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.TextGeometry.Builder clearType() {
type = null;
fieldSetFlags()[0] = false;
return this;
}
/**
* Gets the value of the 'value' field.
* @return The value.
*/
public java.lang.String getValue() {
return value;
}
/**
* Sets the value of the 'value' field.
* @param value The value of 'value'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.TextGeometry.Builder setValue(java.lang.String value) {
validate(fields()[1], value);
this.value = value;
fieldSetFlags()[1] = true;
return this;
}
/**
* Checks whether the 'value' field has been set.
* @return True if the 'value' field has been set, false otherwise.
*/
public boolean hasValue() {
return fieldSetFlags()[1];
}
/**
* Clears the value of the 'value' field.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.TextGeometry.Builder clearValue() {
value = null;
fieldSetFlags()[1] = false;
return this;
}
@Override
@SuppressWarnings("unchecked")
public TextGeometry build() {
try {
TextGeometry record = new TextGeometry();
record.type = fieldSetFlags()[0] ? this.type : (java.lang.String) defaultValue(fields()[0]);
record.value = fieldSetFlags()[1] ? this.value : (java.lang.String) defaultValue(fields()[1]);
return record;
} catch (java.lang.Exception e) {
throw new org.apache.avro.AvroRuntimeException(e);
}
}
}
@SuppressWarnings("unchecked")
private static final org.apache.avro.io.DatumWriter<TextGeometry>
WRITER$ = (org.apache.avro.io.DatumWriter<TextGeometry>)MODEL$.createDatumWriter(SCHEMA$);
@Override public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException {
WRITER$.write(this, SpecificData.getEncoder(out));
}
@SuppressWarnings("unchecked")
private static final org.apache.avro.io.DatumReader<TextGeometry>
READER$ = (org.apache.avro.io.DatumReader<TextGeometry>)MODEL$.createDatumReader(SCHEMA$);
@Override public void readExternal(java.io.ObjectInput in)
throws java.io.IOException {
READER$.read(this, SpecificData.getDecoder(in));
}
}
/**
* Autogenerated by Avro
*
* DO NOT EDIT DIRECTLY
*/
package com.alibaba.dts.formats.avro;
import org.apache.avro.specific.SpecificData;
import org.apache.avro.message.BinaryMessageEncoder;
import org.apache.avro.message.BinaryMessageDecoder;
import org.apache.avro.message.SchemaStore;
@SuppressWarnings("all")
@org.apache.avro.specific.AvroGenerated
public class TextObject extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
private static final long serialVersionUID = -4704733630955722876L;
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"TextObject\",\"namespace\":\"com.alibaba.dts.formats.avro\",\"fields\":[{\"name\":\"type\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"}},{\"name\":\"value\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"}}]}");
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
private static SpecificData MODEL$ = new SpecificData();
private static final BinaryMessageEncoder<TextObject> ENCODER =
new BinaryMessageEncoder<TextObject>(MODEL$, SCHEMA$);
private static final BinaryMessageDecoder<TextObject> DECODER =
new BinaryMessageDecoder<TextObject>(MODEL$, SCHEMA$);
/**
* Return the BinaryMessageDecoder instance used by this class.
*/
public static BinaryMessageDecoder<TextObject> getDecoder() {
return DECODER;
}
/**
* Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
* @param resolver a {@link SchemaStore} used to find schemas by fingerprint
*/
public static BinaryMessageDecoder<TextObject> createDecoder(SchemaStore resolver) {
return new BinaryMessageDecoder<TextObject>(MODEL$, SCHEMA$, resolver);
}
/** Serializes this TextObject to a ByteBuffer. */
public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException {
return ENCODER.encode(this);
}
/** Deserializes a TextObject from a ByteBuffer. */
public static TextObject fromByteBuffer(
java.nio.ByteBuffer b) throws java.io.IOException {
return DECODER.decode(b);
}
@Deprecated public java.lang.String type;
@Deprecated public java.lang.String value;
/**
* Default constructor. Note that this does not initialize fields
* to their default values from the schema. If that is desired then
* one should use <code>newBuilder()</code>.
*/
public TextObject() {}
/**
* All-args constructor.
* @param type The new value for type
* @param value The new value for value
*/
public TextObject(java.lang.String type, java.lang.String value) {
this.type = type;
this.value = value;
}
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
// Used by DatumWriter. Applications should not call.
public java.lang.Object get(int field$) {
switch (field$) {
case 0: return type;
case 1: return value;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
// Used by DatumReader. Applications should not call.
@SuppressWarnings(value="unchecked")
public void put(int field$, java.lang.Object value$) {
switch (field$) {
case 0: type = (java.lang.String)value$; break;
case 1: value = (java.lang.String)value$; break;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
/**
* Gets the value of the 'type' field.
* @return The value of the 'type' field.
*/
public java.lang.String getType() {
return type;
}
/**
* Sets the value of the 'type' field.
* @param value the value to set.
*/
public void setType(java.lang.String value) {
this.type = value;
}
/**
* Gets the value of the 'value' field.
* @return The value of the 'value' field.
*/
public java.lang.String getValue() {
return value;
}
/**
* Sets the value of the 'value' field.
* @param value the value to set.
*/
public void setValue(java.lang.String value) {
this.value = value;
}
/**
* Creates a new TextObject RecordBuilder.
* @return A new TextObject RecordBuilder
*/
public static com.alibaba.dts.formats.avro.TextObject.Builder newBuilder() {
return new com.alibaba.dts.formats.avro.TextObject.Builder();
}
/**
* Creates a new TextObject RecordBuilder by copying an existing Builder.
* @param other The existing builder to copy.
* @return A new TextObject RecordBuilder
*/
public static com.alibaba.dts.formats.avro.TextObject.Builder newBuilder(com.alibaba.dts.formats.avro.TextObject.Builder other) {
return new com.alibaba.dts.formats.avro.TextObject.Builder(other);
}
/**
* Creates a new TextObject RecordBuilder by copying an existing TextObject instance.
* @param other The existing instance to copy.
* @return A new TextObject RecordBuilder
*/
public static com.alibaba.dts.formats.avro.TextObject.Builder newBuilder(com.alibaba.dts.formats.avro.TextObject other) {
return new com.alibaba.dts.formats.avro.TextObject.Builder(other);
}
/**
* RecordBuilder for TextObject instances.
*/
public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<TextObject>
implements org.apache.avro.data.RecordBuilder<TextObject> {
private java.lang.String type;
private java.lang.String value;
/** Creates a new Builder */
private Builder() {
super(SCHEMA$);
}
/**
* Creates a Builder by copying an existing Builder.
* @param other The existing Builder to copy.
*/
private Builder(com.alibaba.dts.formats.avro.TextObject.Builder other) {
super(other);
if (isValidValue(fields()[0], other.type)) {
this.type = data().deepCopy(fields()[0].schema(), other.type);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.value)) {
this.value = data().deepCopy(fields()[1].schema(), other.value);
fieldSetFlags()[1] = true;
}
}
/**
* Creates a Builder by copying an existing TextObject instance
* @param other The existing instance to copy.
*/
private Builder(com.alibaba.dts.formats.avro.TextObject other) {
super(SCHEMA$);
if (isValidValue(fields()[0], other.type)) {
this.type = data().deepCopy(fields()[0].schema(), other.type);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.value)) {
this.value = data().deepCopy(fields()[1].schema(), other.value);
fieldSetFlags()[1] = true;
}
}
/**
* Gets the value of the 'type' field.
* @return The value.
*/
public java.lang.String getType() {
return type;
}
/**
* Sets the value of the 'type' field.
* @param value The value of 'type'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.TextObject.Builder setType(java.lang.String value) {
validate(fields()[0], value);
this.type = value;
fieldSetFlags()[0] = true;
return this;
}
/**
* Checks whether the 'type' field has been set.
* @return True if the 'type' field has been set, false otherwise.
*/
public boolean hasType() {
return fieldSetFlags()[0];
}
/**
* Clears the value of the 'type' field.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.TextObject.Builder clearType() {
type = null;
fieldSetFlags()[0] = false;
return this;
}
/**
* Gets the value of the 'value' field.
* @return The value.
*/
public java.lang.String getValue() {
return value;
}
/**
* Sets the value of the 'value' field.
* @param value The value of 'value'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.TextObject.Builder setValue(java.lang.String value) {
validate(fields()[1], value);
this.value = value;
fieldSetFlags()[1] = true;
return this;
}
/**
* Checks whether the 'value' field has been set.
* @return True if the 'value' field has been set, false otherwise.
*/
public boolean hasValue() {
return fieldSetFlags()[1];
}
/**
* Clears the value of the 'value' field.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.TextObject.Builder clearValue() {
value = null;
fieldSetFlags()[1] = false;
return this;
}
@Override
@SuppressWarnings("unchecked")
public TextObject build() {
try {
TextObject record = new TextObject();
record.type = fieldSetFlags()[0] ? this.type : (java.lang.String) defaultValue(fields()[0]);
record.value = fieldSetFlags()[1] ? this.value : (java.lang.String) defaultValue(fields()[1]);
return record;
} catch (java.lang.Exception e) {
throw new org.apache.avro.AvroRuntimeException(e);
}
}
}
@SuppressWarnings("unchecked")
private static final org.apache.avro.io.DatumWriter<TextObject>
WRITER$ = (org.apache.avro.io.DatumWriter<TextObject>)MODEL$.createDatumWriter(SCHEMA$);
@Override public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException {
WRITER$.write(this, SpecificData.getEncoder(out));
}
@SuppressWarnings("unchecked")
private static final org.apache.avro.io.DatumReader<TextObject>
READER$ = (org.apache.avro.io.DatumReader<TextObject>)MODEL$.createDatumReader(SCHEMA$);
@Override public void readExternal(java.io.ObjectInput in)
throws java.io.IOException {
READER$.read(this, SpecificData.getDecoder(in));
}
}
/**
* Autogenerated by Avro
*
* DO NOT EDIT DIRECTLY
*/
package com.alibaba.dts.formats.avro;
import org.apache.avro.specific.SpecificData;
import org.apache.avro.message.BinaryMessageEncoder;
import org.apache.avro.message.BinaryMessageDecoder;
import org.apache.avro.message.SchemaStore;
@SuppressWarnings("all")
@org.apache.avro.specific.AvroGenerated
public class Timestamp extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
private static final long serialVersionUID = 9104952719193464206L;
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Timestamp\",\"namespace\":\"com.alibaba.dts.formats.avro\",\"fields\":[{\"name\":\"timestamp\",\"type\":\"long\"},{\"name\":\"millis\",\"type\":\"int\"}]}");
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
private static SpecificData MODEL$ = new SpecificData();
private static final BinaryMessageEncoder<Timestamp> ENCODER =
new BinaryMessageEncoder<Timestamp>(MODEL$, SCHEMA$);
private static final BinaryMessageDecoder<Timestamp> DECODER =
new BinaryMessageDecoder<Timestamp>(MODEL$, SCHEMA$);
/**
* Return the BinaryMessageDecoder instance used by this class.
*/
public static BinaryMessageDecoder<Timestamp> getDecoder() {
return DECODER;
}
/**
* Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
* @param resolver a {@link SchemaStore} used to find schemas by fingerprint
*/
public static BinaryMessageDecoder<Timestamp> createDecoder(SchemaStore resolver) {
return new BinaryMessageDecoder<Timestamp>(MODEL$, SCHEMA$, resolver);
}
/** Serializes this Timestamp to a ByteBuffer. */
public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException {
return ENCODER.encode(this);
}
/** Deserializes a Timestamp from a ByteBuffer. */
public static Timestamp fromByteBuffer(
java.nio.ByteBuffer b) throws java.io.IOException {
return DECODER.decode(b);
}
@Deprecated public long timestamp;
@Deprecated public int millis;
/**
* Default constructor. Note that this does not initialize fields
* to their default values from the schema. If that is desired then
* one should use <code>newBuilder()</code>.
*/
public Timestamp() {}
/**
* All-args constructor.
* @param timestamp The new value for timestamp
* @param millis The new value for millis
*/
public Timestamp(java.lang.Long timestamp, java.lang.Integer millis) {
this.timestamp = timestamp;
this.millis = millis;
}
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
// Used by DatumWriter. Applications should not call.
public java.lang.Object get(int field$) {
switch (field$) {
case 0: return timestamp;
case 1: return millis;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
// Used by DatumReader. Applications should not call.
@SuppressWarnings(value="unchecked")
public void put(int field$, java.lang.Object value$) {
switch (field$) {
case 0: timestamp = (java.lang.Long)value$; break;
case 1: millis = (java.lang.Integer)value$; break;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
/**
* Gets the value of the 'timestamp' field.
* @return The value of the 'timestamp' field.
*/
public java.lang.Long getTimestamp() {
return timestamp;
}
/**
* Sets the value of the 'timestamp' field.
* @param value the value to set.
*/
public void setTimestamp(java.lang.Long value) {
this.timestamp = value;
}
/**
* Gets the value of the 'millis' field.
* @return The value of the 'millis' field.
*/
public java.lang.Integer getMillis() {
return millis;
}
/**
* Sets the value of the 'millis' field.
* @param value the value to set.
*/
public void setMillis(java.lang.Integer value) {
this.millis = value;
}
/**
* Creates a new Timestamp RecordBuilder.
* @return A new Timestamp RecordBuilder
*/
public static com.alibaba.dts.formats.avro.Timestamp.Builder newBuilder() {
return new com.alibaba.dts.formats.avro.Timestamp.Builder();
}
/**
* Creates a new Timestamp RecordBuilder by copying an existing Builder.
* @param other The existing builder to copy.
* @return A new Timestamp RecordBuilder
*/
public static com.alibaba.dts.formats.avro.Timestamp.Builder newBuilder(com.alibaba.dts.formats.avro.Timestamp.Builder other) {
return new com.alibaba.dts.formats.avro.Timestamp.Builder(other);
}
/**
* Creates a new Timestamp RecordBuilder by copying an existing Timestamp instance.
* @param other The existing instance to copy.
* @return A new Timestamp RecordBuilder
*/
public static com.alibaba.dts.formats.avro.Timestamp.Builder newBuilder(com.alibaba.dts.formats.avro.Timestamp other) {
return new com.alibaba.dts.formats.avro.Timestamp.Builder(other);
}
/**
* RecordBuilder for Timestamp instances.
*/
public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<Timestamp>
implements org.apache.avro.data.RecordBuilder<Timestamp> {
private long timestamp;
private int millis;
/** Creates a new Builder */
private Builder() {
super(SCHEMA$);
}
/**
* Creates a Builder by copying an existing Builder.
* @param other The existing Builder to copy.
*/
private Builder(com.alibaba.dts.formats.avro.Timestamp.Builder other) {
super(other);
if (isValidValue(fields()[0], other.timestamp)) {
this.timestamp = data().deepCopy(fields()[0].schema(), other.timestamp);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.millis)) {
this.millis = data().deepCopy(fields()[1].schema(), other.millis);
fieldSetFlags()[1] = true;
}
}
/**
* Creates a Builder by copying an existing Timestamp instance
* @param other The existing instance to copy.
*/
private Builder(com.alibaba.dts.formats.avro.Timestamp other) {
super(SCHEMA$);
if (isValidValue(fields()[0], other.timestamp)) {
this.timestamp = data().deepCopy(fields()[0].schema(), other.timestamp);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.millis)) {
this.millis = data().deepCopy(fields()[1].schema(), other.millis);
fieldSetFlags()[1] = true;
}
}
/**
* Gets the value of the 'timestamp' field.
* @return The value.
*/
public java.lang.Long getTimestamp() {
return timestamp;
}
/**
* Sets the value of the 'timestamp' field.
* @param value The value of 'timestamp'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Timestamp.Builder setTimestamp(long value) {
validate(fields()[0], value);
this.timestamp = value;
fieldSetFlags()[0] = true;
return this;
}
/**
* Checks whether the 'timestamp' field has been set.
* @return True if the 'timestamp' field has been set, false otherwise.
*/
public boolean hasTimestamp() {
return fieldSetFlags()[0];
}
/**
* Clears the value of the 'timestamp' field.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Timestamp.Builder clearTimestamp() {
fieldSetFlags()[0] = false;
return this;
}
/**
* Gets the value of the 'millis' field.
* @return The value.
*/
public java.lang.Integer getMillis() {
return millis;
}
/**
* Sets the value of the 'millis' field.
* @param value The value of 'millis'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Timestamp.Builder setMillis(int value) {
validate(fields()[1], value);
this.millis = value;
fieldSetFlags()[1] = true;
return this;
}
/**
* Checks whether the 'millis' field has been set.
* @return True if the 'millis' field has been set, false otherwise.
*/
public boolean hasMillis() {
return fieldSetFlags()[1];
}
/**
* Clears the value of the 'millis' field.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.Timestamp.Builder clearMillis() {
fieldSetFlags()[1] = false;
return this;
}
@Override
@SuppressWarnings("unchecked")
public Timestamp build() {
try {
Timestamp record = new Timestamp();
record.timestamp = fieldSetFlags()[0] ? this.timestamp : (java.lang.Long) defaultValue(fields()[0]);
record.millis = fieldSetFlags()[1] ? this.millis : (java.lang.Integer) defaultValue(fields()[1]);
return record;
} catch (java.lang.Exception e) {
throw new org.apache.avro.AvroRuntimeException(e);
}
}
}
@SuppressWarnings("unchecked")
private static final org.apache.avro.io.DatumWriter<Timestamp>
WRITER$ = (org.apache.avro.io.DatumWriter<Timestamp>)MODEL$.createDatumWriter(SCHEMA$);
@Override public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException {
WRITER$.write(this, SpecificData.getEncoder(out));
}
@SuppressWarnings("unchecked")
private static final org.apache.avro.io.DatumReader<Timestamp>
READER$ = (org.apache.avro.io.DatumReader<Timestamp>)MODEL$.createDatumReader(SCHEMA$);
@Override public void readExternal(java.io.ObjectInput in)
throws java.io.IOException {
READER$.read(this, SpecificData.getDecoder(in));
}
}
/**
* Autogenerated by Avro
*
* DO NOT EDIT DIRECTLY
*/
package com.alibaba.dts.formats.avro;
import org.apache.avro.specific.SpecificData;
import org.apache.avro.message.BinaryMessageEncoder;
import org.apache.avro.message.BinaryMessageDecoder;
import org.apache.avro.message.SchemaStore;
@SuppressWarnings("all")
@org.apache.avro.specific.AvroGenerated
public class TimestampWithTimeZone extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
private static final long serialVersionUID = -5089347690050137038L;
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"TimestampWithTimeZone\",\"namespace\":\"com.alibaba.dts.formats.avro\",\"fields\":[{\"name\":\"value\",\"type\":{\"type\":\"record\",\"name\":\"DateTime\",\"fields\":[{\"name\":\"year\",\"type\":[\"null\",\"int\"],\"default\":null},{\"name\":\"month\",\"type\":[\"null\",\"int\"],\"default\":null},{\"name\":\"day\",\"type\":[\"null\",\"int\"],\"default\":null},{\"name\":\"hour\",\"type\":[\"null\",\"int\"],\"default\":null},{\"name\":\"minute\",\"type\":[\"null\",\"int\"],\"default\":null},{\"name\":\"second\",\"type\":[\"null\",\"int\"],\"default\":null},{\"name\":\"millis\",\"type\":[\"null\",\"int\"],\"default\":null}]}},{\"name\":\"timezone\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"}}]}");
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
private static SpecificData MODEL$ = new SpecificData();
private static final BinaryMessageEncoder<TimestampWithTimeZone> ENCODER =
new BinaryMessageEncoder<TimestampWithTimeZone>(MODEL$, SCHEMA$);
private static final BinaryMessageDecoder<TimestampWithTimeZone> DECODER =
new BinaryMessageDecoder<TimestampWithTimeZone>(MODEL$, SCHEMA$);
/**
* Return the BinaryMessageDecoder instance used by this class.
*/
public static BinaryMessageDecoder<TimestampWithTimeZone> getDecoder() {
return DECODER;
}
/**
* Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
* @param resolver a {@link SchemaStore} used to find schemas by fingerprint
*/
public static BinaryMessageDecoder<TimestampWithTimeZone> createDecoder(SchemaStore resolver) {
return new BinaryMessageDecoder<TimestampWithTimeZone>(MODEL$, SCHEMA$, resolver);
}
/** Serializes this TimestampWithTimeZone to a ByteBuffer. */
public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException {
return ENCODER.encode(this);
}
/** Deserializes a TimestampWithTimeZone from a ByteBuffer. */
public static TimestampWithTimeZone fromByteBuffer(
java.nio.ByteBuffer b) throws java.io.IOException {
return DECODER.decode(b);
}
@Deprecated public com.alibaba.dts.formats.avro.DateTime value;
@Deprecated public java.lang.String timezone;
/**
* Default constructor. Note that this does not initialize fields
* to their default values from the schema. If that is desired then
* one should use <code>newBuilder()</code>.
*/
public TimestampWithTimeZone() {}
/**
* All-args constructor.
* @param value The new value for value
* @param timezone The new value for timezone
*/
public TimestampWithTimeZone(com.alibaba.dts.formats.avro.DateTime value, java.lang.String timezone) {
this.value = value;
this.timezone = timezone;
}
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
// Used by DatumWriter. Applications should not call.
public java.lang.Object get(int field$) {
switch (field$) {
case 0: return value;
case 1: return timezone;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
// Used by DatumReader. Applications should not call.
@SuppressWarnings(value="unchecked")
public void put(int field$, java.lang.Object value$) {
switch (field$) {
case 0: value = (com.alibaba.dts.formats.avro.DateTime)value$; break;
case 1: timezone = (java.lang.String)value$; break;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
/**
* Gets the value of the 'value' field.
* @return The value of the 'value' field.
*/
public com.alibaba.dts.formats.avro.DateTime getValue() {
return value;
}
/**
* Sets the value of the 'value' field.
* @param value the value to set.
*/
public void setValue(com.alibaba.dts.formats.avro.DateTime value) {
this.value = value;
}
/**
* Gets the value of the 'timezone' field.
* @return The value of the 'timezone' field.
*/
public java.lang.String getTimezone() {
return timezone;
}
/**
* Sets the value of the 'timezone' field.
* @param value the value to set.
*/
public void setTimezone(java.lang.String value) {
this.timezone = value;
}
/**
* Creates a new TimestampWithTimeZone RecordBuilder.
* @return A new TimestampWithTimeZone RecordBuilder
*/
public static com.alibaba.dts.formats.avro.TimestampWithTimeZone.Builder newBuilder() {
return new com.alibaba.dts.formats.avro.TimestampWithTimeZone.Builder();
}
/**
* Creates a new TimestampWithTimeZone RecordBuilder by copying an existing Builder.
* @param other The existing builder to copy.
* @return A new TimestampWithTimeZone RecordBuilder
*/
public static com.alibaba.dts.formats.avro.TimestampWithTimeZone.Builder newBuilder(com.alibaba.dts.formats.avro.TimestampWithTimeZone.Builder other) {
return new com.alibaba.dts.formats.avro.TimestampWithTimeZone.Builder(other);
}
/**
* Creates a new TimestampWithTimeZone RecordBuilder by copying an existing TimestampWithTimeZone instance.
* @param other The existing instance to copy.
* @return A new TimestampWithTimeZone RecordBuilder
*/
public static com.alibaba.dts.formats.avro.TimestampWithTimeZone.Builder newBuilder(com.alibaba.dts.formats.avro.TimestampWithTimeZone other) {
return new com.alibaba.dts.formats.avro.TimestampWithTimeZone.Builder(other);
}
/**
* RecordBuilder for TimestampWithTimeZone instances.
*/
public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<TimestampWithTimeZone>
implements org.apache.avro.data.RecordBuilder<TimestampWithTimeZone> {
private com.alibaba.dts.formats.avro.DateTime value;
private com.alibaba.dts.formats.avro.DateTime.Builder valueBuilder;
private java.lang.String timezone;
/** Creates a new Builder */
private Builder() {
super(SCHEMA$);
}
/**
* Creates a Builder by copying an existing Builder.
* @param other The existing Builder to copy.
*/
private Builder(com.alibaba.dts.formats.avro.TimestampWithTimeZone.Builder other) {
super(other);
if (isValidValue(fields()[0], other.value)) {
this.value = data().deepCopy(fields()[0].schema(), other.value);
fieldSetFlags()[0] = true;
}
if (other.hasValueBuilder()) {
this.valueBuilder = com.alibaba.dts.formats.avro.DateTime.newBuilder(other.getValueBuilder());
}
if (isValidValue(fields()[1], other.timezone)) {
this.timezone = data().deepCopy(fields()[1].schema(), other.timezone);
fieldSetFlags()[1] = true;
}
}
/**
* Creates a Builder by copying an existing TimestampWithTimeZone instance
* @param other The existing instance to copy.
*/
private Builder(com.alibaba.dts.formats.avro.TimestampWithTimeZone other) {
super(SCHEMA$);
if (isValidValue(fields()[0], other.value)) {
this.value = data().deepCopy(fields()[0].schema(), other.value);
fieldSetFlags()[0] = true;
}
this.valueBuilder = null;
if (isValidValue(fields()[1], other.timezone)) {
this.timezone = data().deepCopy(fields()[1].schema(), other.timezone);
fieldSetFlags()[1] = true;
}
}
/**
* Gets the value of the 'value' field.
* @return The value.
*/
public com.alibaba.dts.formats.avro.DateTime getValue() {
return value;
}
/**
* Sets the value of the 'value' field.
* @param value The value of 'value'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.TimestampWithTimeZone.Builder setValue(com.alibaba.dts.formats.avro.DateTime value) {
validate(fields()[0], value);
this.valueBuilder = null;
this.value = value;
fieldSetFlags()[0] = true;
return this;
}
/**
* Checks whether the 'value' field has been set.
* @return True if the 'value' field has been set, false otherwise.
*/
public boolean hasValue() {
return fieldSetFlags()[0];
}
/**
* Gets the Builder instance for the 'value' field and creates one if it doesn't exist yet.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.DateTime.Builder getValueBuilder() {
if (valueBuilder == null) {
if (hasValue()) {
setValueBuilder(com.alibaba.dts.formats.avro.DateTime.newBuilder(value));
} else {
setValueBuilder(com.alibaba.dts.formats.avro.DateTime.newBuilder());
}
}
return valueBuilder;
}
/**
* Sets the Builder instance for the 'value' field
* @param value The builder instance that must be set.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.TimestampWithTimeZone.Builder setValueBuilder(com.alibaba.dts.formats.avro.DateTime.Builder value) {
clearValue();
valueBuilder = value;
return this;
}
/**
* Checks whether the 'value' field has an active Builder instance
* @return True if the 'value' field has an active Builder instance
*/
public boolean hasValueBuilder() {
return valueBuilder != null;
}
/**
* Clears the value of the 'value' field.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.TimestampWithTimeZone.Builder clearValue() {
value = null;
valueBuilder = null;
fieldSetFlags()[0] = false;
return this;
}
/**
* Gets the value of the 'timezone' field.
* @return The value.
*/
public java.lang.String getTimezone() {
return timezone;
}
/**
* Sets the value of the 'timezone' field.
* @param value The value of 'timezone'.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.TimestampWithTimeZone.Builder setTimezone(java.lang.String value) {
validate(fields()[1], value);
this.timezone = value;
fieldSetFlags()[1] = true;
return this;
}
/**
* Checks whether the 'timezone' field has been set.
* @return True if the 'timezone' field has been set, false otherwise.
*/
public boolean hasTimezone() {
return fieldSetFlags()[1];
}
/**
* Clears the value of the 'timezone' field.
* @return This builder.
*/
public com.alibaba.dts.formats.avro.TimestampWithTimeZone.Builder clearTimezone() {
timezone = null;
fieldSetFlags()[1] = false;
return this;
}
@Override
@SuppressWarnings("unchecked")
public TimestampWithTimeZone build() {
try {
TimestampWithTimeZone record = new TimestampWithTimeZone();
if (valueBuilder != null) {
record.value = this.valueBuilder.build();
} else {
record.value = fieldSetFlags()[0] ? this.value : (com.alibaba.dts.formats.avro.DateTime) defaultValue(fields()[0]);
}
record.timezone = fieldSetFlags()[1] ? this.timezone : (java.lang.String) defaultValue(fields()[1]);
return record;
} catch (java.lang.Exception e) {
throw new org.apache.avro.AvroRuntimeException(e);
}
}
}
@SuppressWarnings("unchecked")
private static final org.apache.avro.io.DatumWriter<TimestampWithTimeZone>
WRITER$ = (org.apache.avro.io.DatumWriter<TimestampWithTimeZone>)MODEL$.createDatumWriter(SCHEMA$);
@Override public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException {
WRITER$.write(this, SpecificData.getEncoder(out));
}
@SuppressWarnings("unchecked")
private static final org.apache.avro.io.DatumReader<TimestampWithTimeZone>
READER$ = (org.apache.avro.io.DatumReader<TimestampWithTimeZone>)MODEL$.createDatumReader(SCHEMA$);
@Override public void readExternal(java.io.ObjectInput in)
throws java.io.IOException {
READER$.read(this, SpecificData.getDecoder(in));
}
}
package com.alibaba.dts.metastore;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.apache.kafka.clients.consumer.OffsetAndMetadata;
import org.apache.kafka.clients.consumer.OffsetCommitCallback;
import org.apache.kafka.common.KafkaException;
import org.apache.kafka.common.TopicPartition;
import org.apache.kafka.common.internals.KafkaFutureImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.dts.common.Checkpoint;
import java.util.Collections;
import java.util.Map;
import java.util.concurrent.Future;
public class KafkaMetaStore implements MetaStore<Checkpoint> {
private static final Logger log = LoggerFactory.getLogger(KafkaMetaStore.class);
private volatile KafkaConsumer kafkaConsumer;
public KafkaMetaStore(KafkaConsumer kafkaConsumer) {
this.kafkaConsumer = kafkaConsumer;
}
public void resetKafkaConsumer(KafkaConsumer newConsumer) {
this.kafkaConsumer = newConsumer;
}
@Override
public Future<Checkpoint> serializeTo(TopicPartition topicPartition, String group, Checkpoint value) {
KafkaFutureImpl ret = new KafkaFutureImpl();
if (null != kafkaConsumer) {
OffsetAndMetadata offsetAndMetadata = new OffsetAndMetadata(value.getOffset(), String.valueOf(value.getTimeStamp()));
// Notice: commitAsync is only put commit offset request to sending queue, the future result will be driven by KafkaConsumer.poll() function
// So if you only call this method but not poll, you may not wait offset commit call back
kafkaConsumer.commitAsync(Collections.singletonMap(topicPartition, offsetAndMetadata), new OffsetCommitCallback() {
@Override
public void onComplete(Map<TopicPartition, OffsetAndMetadata> offsets, Exception exception) {
if (null != exception) {
log.warn("KafkaMetaStore: Commit offset for group[" + group + "] topicPartition[" + topicPartition.toString() + "] " +
value.toString() + " failed cause " + exception.getMessage(), exception);
ret.completeExceptionally(exception);
} else {
log.debug("KafkaMetaStore:Commit offset success for group[{}] topicPartition [{}] {}", group, topicPartition, value);
ret.complete(value);
}
}
});
} else {
log.warn("KafkaMetaStore: kafka consumer not set, ignore report");
ret.complete(value);
}
return ret;
}
@Override
public Checkpoint deserializeFrom(TopicPartition topicPartition, String group) {
if (null != kafkaConsumer) {
OffsetAndMetadata offsetAndMetadata = kafkaConsumer.committed(topicPartition);
if (null != offsetAndMetadata) {
return new Checkpoint(topicPartition, Long.valueOf(offsetAndMetadata.metadata()), offsetAndMetadata.offset(), offsetAndMetadata.metadata());
} else {
return null;
}
} else {
log.warn("KafkaMetaStore: kafka consumer not set, ignore fetch offset");
throw new KafkaException("KafkaMetaStore: kafka consumer not set, ignore fetch offset for group[" + group + "] and tp [" + topicPartition + "]");
}
}
}
package com.alibaba.dts.metastore;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.apache.kafka.common.TopicPartition;
import org.apache.kafka.common.internals.KafkaFutureImpl;
import com.alibaba.dts.common.Checkpoint;
import com.alibaba.dts.common.AtomicFileStore;
import java.util.*;
import java.util.concurrent.Future;
public class LocalFileMetaStore implements MetaStore<Checkpoint> {
private static final String GROUP_ID_NAME = "groupID";
private static final String STREAM_CHECKPOINT_NAME = "streamCheckpoint";
private static final String TOPIC_NAME = "topic";
private static final String PARTITION_NAME = "partition";
private static final String OFFSET_NAME = "offset";
private static final String TIMESTAMP_NAME = "timestamp";
private static final String INFO_NAME = "info";
private static class StoreElement {
final String groupName;
final Map<TopicPartition, Checkpoint> streamCheckpoint;
private StoreElement(String groupName, Map<TopicPartition, Checkpoint> streamCheckpoint) {
this.groupName = groupName;
this.streamCheckpoint = streamCheckpoint;
}
}
private final AtomicFileStore fileStore;
private final Map<String, Map<TopicPartition, Checkpoint>> inMemStore = new HashMap<>();
public LocalFileMetaStore(String fileName) {
this.fileStore = new AtomicFileStore(fileName);
}
private String toJson(StoreElement storeElement) {
JSONObject jsonObject = new JSONObject();
jsonObject.put(GROUP_ID_NAME, storeElement.groupName);
JSONArray jsonArray = new JSONArray();
storeElement.streamCheckpoint.forEach((tp, checkpoint) -> {
JSONObject streamCheckpointJsonObject = new JSONObject();
streamCheckpointJsonObject.put(TOPIC_NAME, tp.topic());
streamCheckpointJsonObject.put(PARTITION_NAME, tp.partition());
streamCheckpointJsonObject.put(OFFSET_NAME, checkpoint.getOffset());
streamCheckpointJsonObject.put(TIMESTAMP_NAME, checkpoint.getTimeStamp());
streamCheckpointJsonObject.put(INFO_NAME, checkpoint.getInfo());
jsonArray.add(streamCheckpointJsonObject);
});
jsonObject.put(STREAM_CHECKPOINT_NAME, jsonArray);
return jsonObject.toJSONString();
}
private StoreElement fromString(String jsonString) {
JSONObject jsonObject = JSONObject.parseObject(jsonString);
String groupName = jsonObject.getString(GROUP_ID_NAME);
JSONArray streamCheckpointJsonObject = jsonObject.getJSONArray(STREAM_CHECKPOINT_NAME);
Map<TopicPartition, Checkpoint> checkpointInfo = new HashMap<>();
for (Object o : streamCheckpointJsonObject) {
JSONObject tpAndCheckpoint = (JSONObject) o;
String topic = tpAndCheckpoint.getString(TOPIC_NAME);
int partition = tpAndCheckpoint.getInteger(PARTITION_NAME);
long offset = tpAndCheckpoint.getLong(OFFSET_NAME);
long timestamp = tpAndCheckpoint.getLong(TIMESTAMP_NAME);
String info = tpAndCheckpoint.getString(INFO_NAME);
checkpointInfo.put(new TopicPartition(topic, partition), new Checkpoint(new TopicPartition(topic, partition), timestamp, offset, info));
}
return new StoreElement(groupName, checkpointInfo);
}
@Override
public Future<Checkpoint> serializeTo(TopicPartition topicPartition, String groupID, Checkpoint value) {
Map<TopicPartition, Checkpoint> topicPartitionCheckpoint = inMemStore.get(groupID);
if (null == topicPartitionCheckpoint) {
topicPartitionCheckpoint = new HashMap<>();
}
topicPartitionCheckpoint.put(topicPartition, value);
inMemStore.put(groupID, topicPartitionCheckpoint);
List<String> toSerialize = new LinkedList<>();
inMemStore.forEach((k, v) ->{
toSerialize.add(toJson(new StoreElement(k, v)));
});
fileStore.updateContent(toSerialize);
KafkaFutureImpl ret = new KafkaFutureImpl<>();
ret.complete(value);
return ret;
}
@Override
public Checkpoint deserializeFrom(TopicPartition topicPartition, String groupID) {
Map<TopicPartition, Checkpoint> tpAndCheckpointMap = inMemStore.get(groupID);
if (null != tpAndCheckpointMap) {
Checkpoint ret = tpAndCheckpointMap.get(topicPartition);
if (null != ret) {
return ret;
}
}
List<String> storedCheckpoint = fileStore.getContent();
for (String checkpoint : storedCheckpoint) {
StoreElement storeElement = fromString(checkpoint);
// add to cache
if (!inMemStore.containsKey(storeElement.groupName)) {
inMemStore.put(storeElement.groupName, storeElement.streamCheckpoint);
}
if (StringUtils.equals(storeElement.groupName, groupID)) {
return storeElement.streamCheckpoint.get(topicPartition);
}
}
return null;
}
}
package com.alibaba.dts.metastore;
import org.apache.kafka.common.TopicPartition;
import java.util.concurrent.Future;
public interface MetaStore<V> {
Future<V> serializeTo(TopicPartition topicPartition, String group, V value);
V deserializeFrom(TopicPartition topicPartition, String group);
}
package com.alibaba.dts.metastore;
import org.apache.kafka.common.TopicPartition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.dts.common.Checkpoint;
import java.util.HashMap;
import java.util.Map;
public class MetaStoreCenter {
private static final Logger log = LoggerFactory.getLogger(MetaStoreCenter.class);
private final Map<String, MetaStore<Checkpoint>> registeredStore = new HashMap<>();
public MetaStoreCenter() {
}
public void registerStore(String name, MetaStore metaStore) {
log.info("MetaStoreCenter: register metaStore {}", name);
registeredStore.put(name, metaStore);
}
public void store(TopicPartition topicPartition, String group, Checkpoint value) {
registeredStore.values().forEach(v -> {
v.serializeTo(topicPartition, group, value);
});
}
public Checkpoint seek(String storeName, TopicPartition tp, String group) {
MetaStore<Checkpoint> metaStore = registeredStore.get(storeName);
if (null != metaStore) {
return metaStore.deserializeFrom(tp, group);
} else {
return null;
}
}
}
package com.alibaba.dts.recordgenerator;
import org.apache.kafka.clients.consumer.ConsumerInterceptor;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.common.ClusterResource;
import org.apache.kafka.common.ClusterResourceListener;
import org.apache.kafka.common.KafkaException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Map;
/**
* We recommend user register this listener.
* Cause when origin cluster is unavailable and new cluster is created by HA(high available service).
* The cluster name is different. We want warn user that a new cluster is working.
* The more important thing is that we want user recreate KakfaConsumer and use timestamp to reseek offset.
* If user following this guid, less duplicated data will be pushed.
* Otherwise
*/
public class ClusterSwitchListener implements ClusterResourceListener, ConsumerInterceptor {
private final static Logger logger = LoggerFactory.getLogger(ClusterSwitchListener.class);
private ClusterResource originClusterResource = null;
public ConsumerRecords onConsume(ConsumerRecords records) {
return records;
}
public void close() {
}
public void onCommit(Map offsets) {
}
public void onUpdate(ClusterResource clusterResource) {
synchronized (this) {
if (null == originClusterResource) {
logger.info("Cluster updated to " + clusterResource.clusterId());
originClusterResource = clusterResource;
} else {
if (clusterResource.clusterId().equals(originClusterResource.clusterId())) {
logger.info("Cluster not changed on update:" + clusterResource.clusterId());
} else {
throw new ClusterSwitchException("Cluster changed from " + originClusterResource.clusterId() + " to " + clusterResource.clusterId()
+ ", consumer require restart");
}
}
}
}
public void configure(Map<String, ?> configs) {
}
public static class ClusterSwitchException extends KafkaException {
public ClusterSwitchException(String message, Throwable cause) {
super(message, cause);
}
public ClusterSwitchException(String message) {
super(message);
}
public ClusterSwitchException(Throwable cause) {
super(cause);
}
public ClusterSwitchException() {
super();
}
}
}
package com.alibaba.dts.recordgenerator;
import org.apache.commons.lang3.StringUtils;
import org.apache.kafka.clients.consumer.ConsumerRebalanceListener;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.apache.kafka.clients.consumer.OffsetAndTimestamp;
import org.apache.kafka.common.TopicPartition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.dts.common.Checkpoint;
import java.io.Closeable;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Supplier;
import static com.alibaba.dts.common.Util.mergeSourceKafkaProperties;
public abstract class ConsumerWrap implements Closeable {
private static final Logger log = LoggerFactory.getLogger(ConsumerWrap.class);
// directly set offset using the give offset, we don't check the offset is legal or not.
public abstract void setFetchOffsetByOffset(TopicPartition topicPartition, Checkpoint checkpoint);
public abstract void setFetchOffsetByTimestamp(TopicPartition topicPartition, Checkpoint checkpoint);
// assign topic is not use auto balance, which we recommend this way to consume record. and commit offset by user it self
public abstract void assignTopic(TopicPartition topicPartition, Checkpoint checkpoint);
// subscribe function use consumer group mode, which means multi consumer using the same groupid could build a high available consume system
// still we recommend shutdown auto commit mode, and user commit the offset manually.
// this can delay offset commit until the record is really consumed by business logic which can strongly defend the data loss.
public abstract void subscribeTopic(TopicPartition topicPartition, Supplier<Checkpoint> streamCheckpoint);
public abstract ConsumerRecords<byte[], byte[]> poll();
public abstract KafkaConsumer getRawConsumer();
public static class DefaultConsumerWrap extends ConsumerWrap {
private AtomicBoolean firstStart = new AtomicBoolean(true);
private KafkaConsumer<byte[], byte[]> consumer;
private final long poolTimeOut;
public DefaultConsumerWrap(Properties properties) {
Properties consumerConfig = new Properties();
mergeSourceKafkaProperties(properties, consumerConfig);
checkConfig(consumerConfig);
consumer = new KafkaConsumer<byte[], byte[]>(consumerConfig);
poolTimeOut = Long.valueOf(properties.getProperty(Names.POLL_TIME_OUT, "500"));
}
@Override
public void setFetchOffsetByOffset(TopicPartition topicPartition, Checkpoint checkpoint) {
consumer.seek(topicPartition, checkpoint.getOffset());
}
// recommended
@Override
public void setFetchOffsetByTimestamp(TopicPartition topicPartition, Checkpoint checkpoint) {
long timeStamp = checkpoint.getTimeStamp();
Map<TopicPartition, OffsetAndTimestamp> remoteOffset = consumer.offsetsForTimes(Collections.singletonMap(topicPartition, timeStamp));
OffsetAndTimestamp toSet = remoteOffset.get(topicPartition);
if (null == toSet) {
throw new RuntimeException("RecordGenerator:seek timestamp for topic [" + topicPartition + "] with timestamp [" + timeStamp + "] failed");
}
consumer.seek(topicPartition, toSet.offset());
}
@Override
public void assignTopic(TopicPartition topicPartition, Checkpoint checkpoint) {
consumer.assign(Arrays.asList(topicPartition));
log.info("RecordGenerator: assigned for {} with checkpoint {}", topicPartition, checkpoint);
setFetchOffsetByTimestamp(topicPartition, checkpoint);
}
//Not test, please not use this function
@Override
public void subscribeTopic(TopicPartition topicPartition, Supplier<Checkpoint> streamCheckpoint) {
consumer.subscribe(Arrays.asList(topicPartition.topic()), new ConsumerRebalanceListener() {
@Override
public void onPartitionsRevoked(Collection<TopicPartition> partitions) {
log.info("RecordGenerator: partition revoked for [{}]", StringUtils.join(partitions, ","));
}
@Override
public void onPartitionsAssigned(Collection<TopicPartition> partitions) {
log.info("RecordGenerator: partition assigned for [{}]", StringUtils.join(partitions, ","));
if (partitions.contains(topicPartition)) {
if (firstStart.compareAndSet(true, false)) {
Checkpoint toSet = streamCheckpoint.get();
setFetchOffsetByTimestamp(topicPartition, toSet);
log.info("RecordGenerator: subscribe for [{}] with checkpoint [{}] first start", topicPartition, toSet);
} else {
log.info("RecordGenerator: subscribe for [{}] reassign, do nothing", topicPartition);
}
}
}
});
}
public ConsumerRecords<byte[], byte[]> poll() {
return consumer.poll(poolTimeOut);
}
@Override
public KafkaConsumer getRawConsumer() {
return consumer;
}
public synchronized void close() {
if (null != consumer) {
consumer.close();
}
}
private void checkConfig(Properties properties) {
}
}
}
package com.alibaba.dts.recordgenerator;
import java.util.Properties;
public interface ConsumerWrapFactory {
public ConsumerWrap getConsumerWrap(Properties properties);
public static class KafkaConsumerWrapFactory implements ConsumerWrapFactory {
@Override
public ConsumerWrap getConsumerWrap(Properties properties) {
return new ConsumerWrap.DefaultConsumerWrap(properties);
}
}
}
package com.alibaba.dts.recordgenerator;
public class Names {
// detail control
public static final String TRY_TIME = "stream.tryTime";
public static final String TRY_BACK_TIME_MS = "stream.tryBackTimeMS";
public static final String RETRY_TIME_OUT = "stream.errorRetryTimeOut";
public static final String POLL_TIME_OUT = "stream.pool.timeout";
// general name
public static final String KAFKA_TOPIC = "kafkaTopic";
public static final String KAFKA_BROKER_URL_NAME = "broker";
public static final String GROUP_NAME = "group";
public static final String USE_CONFIG_CHECKPOINT_NAME = "useConfigCheckpoint";
public static final String SUBSCRIBE_MODE_NAME = "subscribeMode";
public static final String INITIAL_CHECKPOINT_NAME = "checkpoint";
public static final String USER_NAME = "user";
public static final String PASSWORD_NAME = "password";
public static final String SID_NAME = "sid";
public static final long MAX_TIMESTAMP_SECOND = 99999999999L;
}
package com.alibaba.dts.recordgenerator;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.common.TopicPartition;
public interface OffsetCommitCallBack {
void commit(TopicPartition tp, long timestamp, long offset, String metadata);
}
package com.alibaba.dts.recordgenerator;
import org.apache.commons.lang3.StringUtils;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.common.TopicPartition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.dts.recordprocessor.EtlRecordProcessor;
import com.alibaba.dts.metastore.LocalFileMetaStore;
import com.alibaba.dts.metastore.MetaStoreCenter;
import com.alibaba.dts.common.Checkpoint;
import com.alibaba.dts.common.Context;
import java.io.Closeable;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import static com.alibaba.dts.recordgenerator.Names.*;
import static com.alibaba.dts.common.Util.sleepMS;
import static com.alibaba.dts.common.Util.swallowErrorClose;
public class RecordGenerator implements Runnable, Closeable {
private static final Logger log = LoggerFactory.getLogger(RecordGenerator.class);
private static final String LOCAL_FILE_STORE_NAME = "localCheckpointStore";
private static final String KAFKA_STORE_NAME = "kafkaCheckpointStore";
private final Properties properties;
private final int tryTime;
private final Context context;
private final TopicPartition topicPartition;
private final String groupID;
private final ConsumerWrapFactory consumerWrapFactory;
private final Checkpoint initialCheckpoint;
private volatile Checkpoint toCommitCheckpoint = null;
private final MetaStoreCenter metaStoreCenter = new MetaStoreCenter();
private final AtomicBoolean useCheckpointConfig;
private final ConsumerSubscribeMode subscribeMode;
private final long tryBackTimeMS;
private volatile boolean existed;
public RecordGenerator(Properties properties, Context context, Checkpoint initialCheckpoint, ConsumerWrapFactory consumerWrapFactory) {
this.properties = properties;
this.tryTime = Integer.valueOf(properties.getProperty(TRY_TIME, "150"));
this.tryBackTimeMS = Long.valueOf(properties.getProperty(TRY_BACK_TIME_MS, "10000"));
this.context = context;
this.consumerWrapFactory = consumerWrapFactory;
this.initialCheckpoint = initialCheckpoint;
this.topicPartition = new TopicPartition(properties.getProperty(KAFKA_TOPIC), 0);
this.groupID = properties.getProperty(GROUP_NAME);
this.subscribeMode = parseConsumerSubscribeMode(properties.getProperty(SUBSCRIBE_MODE_NAME, "assign"));
this.useCheckpointConfig = new AtomicBoolean(StringUtils.equalsIgnoreCase(properties.getProperty(USE_CONFIG_CHECKPOINT_NAME), "true"));
existed = false;
metaStoreCenter.registerStore(LOCAL_FILE_STORE_NAME, new LocalFileMetaStore(LOCAL_FILE_STORE_NAME));
log.info("RecordGenerator: try time [" + tryTime + "], try backTimeMS [" + tryBackTimeMS + "]");
}
private ConsumerWrap getConsumerWrap() {
return consumerWrapFactory.getConsumerWrap(properties);
}
public void run() {
int haveTryTime = 0;
String message = "first start";
ConsumerWrap kafkaConsumerWrap = null;
while (!existed) {
EtlRecordProcessor recordProcessor = context.getRecordProcessor();
try {
kafkaConsumerWrap = getConsumerWrap(message);
while (!existed) {
// kafka consumer is not threadsafe, so if you want commit checkpoint to kafka, commit it in same thread
mayCommitCheckpoint();
ConsumerRecords<byte[], byte[]> records = kafkaConsumerWrap.poll();
for (ConsumerRecord<byte[], byte[]> record : records) {
int offerTryCount = 0;
if (record.value() == null || record.value().length <= 48) {
// dStore may generate special mock record to push up consumer offset for next fetchRequest if all data is filtered
continue;
} else {
log.debug("RecordGenerator: receive record, offset [" + record.offset() + "], value size [" + (record.value() == null ? 0 : record.value().length) + "]" );
}
while (!recordProcessor.offer(1000, TimeUnit.MILLISECONDS, record) && !existed) {
if (++offerTryCount % 10 == 0) {
log.info("RecordGenerator: offer record has failed for a period (10s) [ " + record + "]");
}
}
}
}
} catch (Throwable e) {
if (isErrorRecoverable(e) && haveTryTime++ < tryTime) {
log.warn("RecordGenerator: error meet cause " + e.getMessage() + ", recover time [" + haveTryTime + "]", e);
sleepMS(tryBackTimeMS);
message = "reconnect";
} else {
log.error("RecordGenerator: unrecoverable error " + e.getMessage() + ", have try time [" + haveTryTime + "]", e);
this.existed = true;
}
} finally {
swallowErrorClose(kafkaConsumerWrap);
}
}
}
private void mayCommitCheckpoint() {
if (null != toCommitCheckpoint) {
commitCheckpoint(toCommitCheckpoint.getTopicPartition(), toCommitCheckpoint);
toCommitCheckpoint = null;
}
}
public void setToCommitCheckpoint(Checkpoint committedCheckpoint) {
this.toCommitCheckpoint = committedCheckpoint;
}
private ConsumerWrap getConsumerWrap(String message) {
ConsumerWrap kafkaConsumerWrap = getConsumerWrap();
Checkpoint checkpoint = null;
// we encourage user impl their own checkpoint store, but plan b is also supported
// metaStoreCenter.registerStore(KAFKA_STORE_NAME, new KafkaMetaStore(kafkaConsumerWrap.getRawConsumer()));
if (useCheckpointConfig.compareAndSet(true, false)) {
log.info("RecordGenerator: force use initial checkpoint [{}] to start", checkpoint);
checkpoint = initialCheckpoint;
} else {
checkpoint = getCheckpoint();
if (null == checkpoint || Checkpoint.INVALID_STREAM_CHECKPOINT == checkpoint) {
checkpoint = initialCheckpoint;
log.info("RecordGenerator: use initial checkpoint [{}] to start", checkpoint);
} else {
log.info("RecordGenerator: load checkpoint from checkpoint store success, current checkpoint [{}]", checkpoint);
}
}
switch (subscribeMode) {
case SUBSCRIBE: {
kafkaConsumerWrap.subscribeTopic(topicPartition, () -> {
Checkpoint ret = metaStoreCenter.seek(KAFKA_STORE_NAME, topicPartition, groupID);
if (null == ret) {
ret = initialCheckpoint;
}
return ret;
});
break;
}
case ASSIGN:{
kafkaConsumerWrap.assignTopic(topicPartition, checkpoint);
break;
}
default: {
throw new RuntimeException("RecordGenerator: unknown mode not support");
}
}
log.info("RecordGenerator:" + message + ", checkpoint " + checkpoint);
return kafkaConsumerWrap;
}
private Checkpoint getCheckpoint() {
// use local checkpoint priority
Checkpoint checkpoint = metaStoreCenter.seek(LOCAL_FILE_STORE_NAME, topicPartition, groupID);
if (null == checkpoint) {
checkpoint = metaStoreCenter.seek(KAFKA_STORE_NAME, topicPartition, groupID);
}
return checkpoint;
}
public void commitCheckpoint(TopicPartition topicPartition, Checkpoint checkpoint) {
if (null != topicPartition && null != checkpoint) {
metaStoreCenter.store(topicPartition, groupID, checkpoint);
}
}
private boolean isErrorRecoverable(Throwable e) {
return true;
}
public Checkpoint getInitialCheckpoint() {
return initialCheckpoint;
}
public void close() {
existed = true;
}
private static enum ConsumerSubscribeMode {
ASSIGN,
SUBSCRIBE,
UNKNOWN;
}
private ConsumerSubscribeMode parseConsumerSubscribeMode(String value) {
if (StringUtils.equalsIgnoreCase("assign", value)) {
return ConsumerSubscribeMode.ASSIGN;
} else if (StringUtils.equalsIgnoreCase("subscribe", value)) {
return ConsumerSubscribeMode.SUBSCRIBE;
} else {
throw new RuntimeException("RecordGenerator: unknown subscribe mode [" + value + "]");
}
}
}
package com.alibaba.dts.recordprocessor;
import com.alibaba.dts.formats.avro.Record;
import org.apache.avro.io.Decoder;
import org.apache.avro.io.DecoderFactory;
import org.apache.avro.specific.SpecificDatumReader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class AvroDeserializer {
private static final Logger log = LoggerFactory.getLogger(AvroDeserializer.class);
private final SpecificDatumReader<Record> reader = new SpecificDatumReader<Record>(com.alibaba.dts.formats.avro.Record.class);
public AvroDeserializer() {
}
public com.alibaba.dts.formats.avro.Record deserialize(byte[] data) {
Decoder decoder = DecoderFactory.get().binaryDecoder(data, null);
Record payload = null;
try {
payload = reader.read(null, decoder);
return payload;
}catch (Throwable ex) {
log.error("AvroDeserializer: deserialize record failed cause " + ex.getMessage(), ex);
throw new RuntimeException(ex);
}
}
}
package com.alibaba.dts.recordprocessor;
import com.alibaba.dts.common.*;
import com.alibaba.dts.formats.avro.Record;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.common.TopicPartition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.dts.recordgenerator.OffsetCommitCallBack;
import java.io.Closeable;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import static com.alibaba.dts.common.Util.require;
import static com.alibaba.dts.common.Util.sleepMS;
/**
* This demo show how to resolve avro record deserialize from bytes
* We will show how to print a column from deserialize record
*/
public class EtlRecordProcessor implements Runnable, Closeable {
private static final Logger log = LoggerFactory.getLogger(EtlRecordProcessor.class);
private final OffsetCommitCallBack offsetCommitCallBack;
private volatile Checkpoint commitCheckpoint;
private WorkThread commitThread;
public boolean offer(long timeOut, TimeUnit timeUnit, ConsumerRecord record) {
try {
return toProcessRecord.offer(record, timeOut, timeUnit);
} catch (Exception e) {
log.error("EtlRecordProcessor: offer record failed, record[" + record + "], cause " + e.getMessage(), e);
return false;
}
}
private final LinkedBlockingQueue<ConsumerRecord> toProcessRecord;
private final AvroDeserializer fastDeserializer;
private final Context context;
private final Map<String, RecordListener> recordListeners = new HashMap<>();
private volatile boolean existed = false;
public EtlRecordProcessor(OffsetCommitCallBack offsetCommitCallBack, Context context) {
this.offsetCommitCallBack = offsetCommitCallBack;
this.toProcessRecord = new LinkedBlockingQueue<>(512);
fastDeserializer = new AvroDeserializer();
this.context = context;
commitCheckpoint = new Checkpoint(null, -1, -1, "-1");
commitThread = getCommitThread();
commitThread.start();
}
@Override
public void run() {
while (!existed) {
ConsumerRecord<byte[], byte[]> toProcess = null;
Record record = null;
int fetchFailedCount = 0;
try {
while (null == (toProcess = toProcessRecord.peek()) && !existed) {
sleepMS(5);
fetchFailedCount++;
if (fetchFailedCount % 1000 == 0) {
log.info("EtlRecordProcessor: haven't receive records from generator for 5s");
}
}
if (existed) {
return;
}
fetchFailedCount = 0;
final ConsumerRecord<byte[], byte[]> consumerRecord = toProcess;
// 48 means an no op bytes, we use this bytes to push up offset. user should ignore this record
if (consumerRecord.value().length == 48) {
continue;
}
record = fastDeserializer.deserialize(consumerRecord.value());
log.debug("EtlRecordProcessor: meet [{}] record type", record.getOperation());
for (RecordListener recordListener : recordListeners.values()) {
recordListener.consume(new UserRecord(new TopicPartition(consumerRecord.topic(), consumerRecord.partition()), consumerRecord.offset(), record, new UserCommitCallBack() {
@Override
public void commit(TopicPartition tp, Record commitRecord, long offset, String metadata) {
commitCheckpoint = new Checkpoint(tp, commitRecord.getSourceTimestamp(), offset, metadata);
}
}));
}
toProcessRecord.poll();
} catch (Exception e) {
log.error("EtlRecordProcessor: process record failed, raw consumer record [" + toProcess + "], parsed record [" + record + "], cause " + e.getMessage(), e);
existed = true;
}
}
}
// user define how to commit
private void commit() {
if (null != offsetCommitCallBack) {
if (commitCheckpoint.getTopicPartition() != null && commitCheckpoint.getOffset() != -1) {
log.info("commit record with checkpoint {}", commitCheckpoint);
offsetCommitCallBack.commit(commitCheckpoint.getTopicPartition(), commitCheckpoint.getTimeStamp(),
commitCheckpoint.getOffset(), commitCheckpoint.getInfo());
}
}
}
public void registerRecordListener(String name, RecordListener recordListener) {
require(null != name && null != recordListener, "null value not accepted");
recordListeners.put(name, recordListener);
}
public void close() {
this.existed = true;
commitThread.stop();
}
private WorkThread getCommitThread() {
WorkThread workThread = new WorkThread(new Runnable() {
@Override
public void run() {
while (!existed) {
sleepMS(5000);
commit();
}
}
});
return workThread;
}
}
package com.alibaba.dts.recordprocessor;
import com.alibaba.dts.formats.avro.Field;
import org.apache.commons.lang3.StringUtils;
import com.alibaba.dts.recordprocessor.mysql.MysqlFieldConverter;
public interface FieldConverter {
FieldValue convert(Field field, Object o);
public static FieldConverter getConverter(String sourceName, String sourceVersion) {
if (StringUtils.endsWithIgnoreCase("mysql", sourceName)) {
return new MysqlFieldConverter();
} else {
throw new RuntimeException("FieldConverter: only mysql supported for now");
}
}
}
package com.alibaba.dts.recordprocessor;
import org.apache.commons.lang3.StringUtils;
import com.alibaba.dts.recordprocessor.mysql.JDKEncodingMapper;
import java.io.UnsupportedEncodingException;
public class FieldValue {
private String encoding;
private byte[] bytes;
public String getEncoding() {
return encoding;
}
public byte[] getValue() {
return bytes;
}
public void setEncoding(String encoding) {
this.encoding = encoding;
}
public void setValue(byte[] bytes) {
this.bytes = bytes;
}
@Override
public String toString() {
if (null == getValue()) {
return "null [binary]";
}
if (encoding==null) {
return super.toString();
}
try {
if(StringUtils.equals("utf8mb4", encoding)){
return new String(getValue(), "utf8");
}else{
return new String(getValue(), encoding);
}
} catch (UnsupportedEncodingException e) {
String realEncoding = JDKEncodingMapper.getJDKEncoding(encoding);
if (null == realEncoding) {
throw new RuntimeException("Unsupported encoding: " + encoding);
} else {
try {
return new String(getValue(), realEncoding);
} catch (UnsupportedEncodingException e1) {
throw new RuntimeException("Unsupported encoding: origin " + encoding + ", mapped " + realEncoding);
}
}
}
}
}
package com.alibaba.dts.recordprocessor.mysql;
import java.util.HashMap;
import java.util.Map;
public class JDKEncodingMapper {
private static final Map<String, String> MYSQL_JDK_ENCODINGS = new HashMap<String, String>();
static{
MYSQL_JDK_ENCODINGS.put("armscii8", "WINDOWS-1252");
MYSQL_JDK_ENCODINGS.put("ascii", "US-ASCII");
MYSQL_JDK_ENCODINGS.put("big5", "BIG5");
MYSQL_JDK_ENCODINGS.put("binary", "ISO-8859-1");
MYSQL_JDK_ENCODINGS.put("cp1250", "WINDOWS-1250");
MYSQL_JDK_ENCODINGS.put("cp1251", "WINDOWS-1251");
MYSQL_JDK_ENCODINGS.put("cp1256", "WINDOWS-1256");
MYSQL_JDK_ENCODINGS.put("cp1257", "WINDOWS-1257");
MYSQL_JDK_ENCODINGS.put("cp850", "IBM850");
MYSQL_JDK_ENCODINGS.put("cp852", "IBM852");
MYSQL_JDK_ENCODINGS.put("cp866", "IBM866");
MYSQL_JDK_ENCODINGS.put("cp932", "WINDOWS-31J");
MYSQL_JDK_ENCODINGS.put("dec8", "WINDOWS-1252");
MYSQL_JDK_ENCODINGS.put("eucjpms", "X-EUCJP-OPEN");
MYSQL_JDK_ENCODINGS.put("euckr", "EUC-KR");
MYSQL_JDK_ENCODINGS.put("gb2312", "GB2312");
MYSQL_JDK_ENCODINGS.put("gbk", "GBK");
MYSQL_JDK_ENCODINGS.put("geostd8", "WINDOWS-1252");
MYSQL_JDK_ENCODINGS.put("greek", "ISO-8859-7");
MYSQL_JDK_ENCODINGS.put("hebrew", "ISO-8859-8");
MYSQL_JDK_ENCODINGS.put("hp8", "WINDOWS-1252");
MYSQL_JDK_ENCODINGS.put("keybcs2", "IBM852");
MYSQL_JDK_ENCODINGS.put("koi8r", "KOI8-R");
MYSQL_JDK_ENCODINGS.put("koi8u", "KOI8-R");
MYSQL_JDK_ENCODINGS.put("latin1", "WINDOWS-1252");
MYSQL_JDK_ENCODINGS.put("latin2", "ISO-8859-2");
MYSQL_JDK_ENCODINGS.put("latin5", "ISO-8859-9");
MYSQL_JDK_ENCODINGS.put("latin7", "ISO-8859-13");
MYSQL_JDK_ENCODINGS.put("macce", "X-MACCENTRALEUROPE");
MYSQL_JDK_ENCODINGS.put("macroman", "X-MACROMAN");
MYSQL_JDK_ENCODINGS.put("sjis", "SHIFT_JIS");
MYSQL_JDK_ENCODINGS.put("swe7", "WINDOWS-1252");
MYSQL_JDK_ENCODINGS.put("tis620", "TIS-620");
MYSQL_JDK_ENCODINGS.put("ujis", "EUC-JP");
MYSQL_JDK_ENCODINGS.put("utf16", "UTF-16");
MYSQL_JDK_ENCODINGS.put("utf16le", "UTF-16LE");
MYSQL_JDK_ENCODINGS.put("utf32", "UTF-32");
MYSQL_JDK_ENCODINGS.put("utf8", "UTF-8");
MYSQL_JDK_ENCODINGS.put("utf8mb4", "UTF-8");
MYSQL_JDK_ENCODINGS.put("ucs2", "UTF-16");
}
public static String getJDKEncoding(String mysqlEncoding) {
return MYSQL_JDK_ENCODINGS.get(mysqlEncoding);
}
}
package com.alibaba.dts.recordprocessor.mysql;
import com.alibaba.dts.formats.avro.Field;
import com.alibaba.dts.recordprocessor.FieldConverter;
import com.alibaba.dts.recordprocessor.FieldValue;
import java.nio.ByteBuffer;
import static java.nio.charset.StandardCharsets.*;
public class MysqlFieldConverter implements FieldConverter {
@Override
public FieldValue convert(Field field, Object o) {
return DATA_ADAPTER[field.getDataTypeNumber()].getFieldValue(o);
}
static DataAdapter[] DATA_ADAPTER = new DataAdapter[256];
static {
DATA_ADAPTER[0] = new DecimalStringAdapter(); //Type.DECIMAL
DATA_ADAPTER[1] = new NumberStringAdapter(); //Type.INT8;
DATA_ADAPTER[2] = new NumberStringAdapter(); //Type.INT16;
DATA_ADAPTER[3] = new NumberStringAdapter(); //Type.INT32;
DATA_ADAPTER[4] = new DoubleStringAdapter(); //Type.FLOAT
DATA_ADAPTER[5] = new DoubleStringAdapter(); //Type.DOUBLE
DATA_ADAPTER[6] = new UTF8StringEncodeAdapter(); //Type.NULL
DATA_ADAPTER[7] = new TimestampStringAdapter(); //Type.TIMESTAMP
DATA_ADAPTER[8] = new NumberStringAdapter(); //Type.INT64
DATA_ADAPTER[9] = new NumberStringAdapter(); //Type.INT24
DATA_ADAPTER[10] = new DateAdapter(); //Type.DATE
DATA_ADAPTER[11] = new TimeAdapter(); //Type.TIME
DATA_ADAPTER[12] = new DateTimeAdapter(); //Type.DATETIME
DATA_ADAPTER[13] = new YearAdapter(); //Type.YEAR
DATA_ADAPTER[14] = new DateTimeAdapter(); //Type.DATETIME
DATA_ADAPTER[15] = new CharacterAdapter(); //Type.STRING
DATA_ADAPTER[16] = new NumberStringAdapter(); //Type.BIT
DATA_ADAPTER[255] = new GeometryAdapter(); //Type.GEOMETRY;
DATA_ADAPTER[254] = new CharacterAdapter(); //Type.STRING;
DATA_ADAPTER[253] = new CharacterAdapter(); //Type.STRING;
DATA_ADAPTER[252] = new BinaryAdapter(); //Type.BLOB;
DATA_ADAPTER[251] = new BinaryAdapter(); //Type.BLOB;
DATA_ADAPTER[250] = new BinaryAdapter(); //Type.BLOB;
DATA_ADAPTER[249] = new BinaryAdapter(); //Type.BLOB;
DATA_ADAPTER[246] = new DecimalStringAdapter(); //Type.DECIMAL;
DATA_ADAPTER[248] = new TextObjectAdapter(); //Type.SET;
DATA_ADAPTER[247] = new TextObjectAdapter(); //Type.ENUM;
DATA_ADAPTER[245] = new TextObjectAdapter(); //Type.JSON;
}
static interface DataAdapter {
FieldValue getFieldValue(Object data);
}
static class UTF8StringEncodeAdapter implements DataAdapter {
public FieldValue getFieldValue(Object data) {
FieldValue fieldValue = new FieldValue();
if (null != data) {
byte[] bytes = ((String) data).getBytes(UTF_8);
fieldValue.setValue(bytes);
}
fieldValue.setEncoding("UTF8");
return fieldValue;
}
}
static class NumberStringAdapter implements DataAdapter {
public FieldValue getFieldValue(Object data) {
FieldValue fieldValue = new FieldValue();
if (null != data) {
com.alibaba.dts.formats.avro.Integer integer = (com.alibaba.dts.formats.avro.Integer) data;
fieldValue.setValue(integer.getValue().getBytes(US_ASCII));
}
fieldValue.setEncoding("ASCII");
return fieldValue;
}
}
static class DecimalStringAdapter implements DataAdapter {
public FieldValue getFieldValue(Object data) {
FieldValue fieldValue = new FieldValue();
if (null != data) {
com.alibaba.dts.formats.avro.Decimal decimal = (com.alibaba.dts.formats.avro.Decimal) data;
fieldValue.setValue(decimal.getValue().getBytes(US_ASCII));
}
fieldValue.setEncoding("ASCII");
return fieldValue;
}
}
static class DoubleStringAdapter implements DataAdapter {
public FieldValue getFieldValue(Object data) {
FieldValue fieldValue = new FieldValue();
if (null != data) {
com.alibaba.dts.formats.avro.Float aFloat = (com.alibaba.dts.formats.avro.Float) data;
fieldValue.setValue(Double.toString(aFloat.getValue()).getBytes(US_ASCII));
}
fieldValue.setEncoding("ASCII");
return fieldValue;
}
}
static class TimestampStringAdapter implements DataAdapter {
static String[] MILLIS_PREFIX = new String[]{"","0","00","000","0000","00000","000000"};
public FieldValue getFieldValue(Object data) {
FieldValue fieldValue = new FieldValue();
if (null != data) {
StringBuilder timestampBuilder = new StringBuilder(64);
com.alibaba.dts.formats.avro.Timestamp timestamp = (com.alibaba.dts.formats.avro.Timestamp) data;
timestampBuilder.append(timestamp.getTimestamp());
if (null != timestamp.getMillis()) {
timestampBuilder.append('.');
String millis = Integer.toString(timestamp.getMillis());
timestampBuilder.append(MILLIS_PREFIX[6 - millis.length()]).append(millis);
}
fieldValue.setValue(timestampBuilder.toString().getBytes(US_ASCII));
}
fieldValue.setEncoding("ASCII");
return fieldValue;
}
}
static abstract class AbstractDateTimeAdapter implements DataAdapter {
void encodeDate(com.alibaba.dts.formats.avro.DateTime dateTime, byte[] out, int position) {
if (null != dateTime && null != out) {
out[position] = (byte) ('0' + (dateTime.getYear() / 1000));
out[position + 1] = (byte) ('0' + (dateTime.getYear() % 1000 / 100));
out[position + 2] = (byte) ('0' + (dateTime.getYear() % 100 / 10));
out[position + 3] = (byte) ('0' + (dateTime.getYear() % 10));
out[position + 4] = '-';
out[position + 5] = (byte) ('0' + (dateTime.getMonth() / 10));
out[position + 6] = (byte) ('0' + (dateTime.getMonth() % 10));
out[position + 7] = '-';
out[position + 8] = (byte) ('0' + (dateTime.getDay() / 10));
out[position + 9] = (byte) ('0' + (dateTime.getDay() % 10));
}
}
void encodeTime(com.alibaba.dts.formats.avro.DateTime dateTime, byte[] out, int position) {
if (null != dateTime && null != out) {
out[position + 0] = (byte) ('0' + (dateTime.getHour() / 10));
out[position + 1] = (byte) ('0' + (dateTime.getHour() % 10));
out[position + 2] = ':';
out[position + 3] = (byte) ('0' + (dateTime.getMinute() / 10));
out[position + 4] = (byte) ('0' + (dateTime.getMinute() % 10));
out[position + 5] = ':';
out[position + 6] = (byte) ('0' + (dateTime.getSecond() / 10));
out[position + 7] = (byte) ('0' + (dateTime.getSecond() % 10));
}
}
void encodeTimeMillis(com.alibaba.dts.formats.avro.DateTime dateTime, byte[] out, int position) {
if (null != dateTime.getMillis() && 0 != dateTime.getMillis()) {
int mills = dateTime.getMillis();
out[position] = '.';
out[position + 1] = (byte) ('0' + (mills / 100000));
mills %= 100000;
out[position + 2] = (byte) ('0' + (mills / 10000));
mills %= 10000;
out[position + 3] = (byte) ('0' + (mills / 1000));
mills %= 1000;
out[position + 4] = (byte) ('0' + (mills / 100));
mills %= 100;
out[position + 5] = (byte) ('0' + (mills / 10));
out[position + 6] = (byte) ('0' + (mills % 10));
}
}
}
static class DateAdapter extends AbstractDateTimeAdapter {
public FieldValue getFieldValue(Object data) {
FieldValue fieldValue = new FieldValue();
if (null != data) {
com.alibaba.dts.formats.avro.DateTime dateTime = (com.alibaba.dts.formats.avro.DateTime) data;
byte[] date = new byte[10];
encodeDate(dateTime, date, 0);
fieldValue.setValue(date);
}
fieldValue.setEncoding("ASCII");
return fieldValue;
}
}
static class TimeAdapter extends AbstractDateTimeAdapter {
public FieldValue getFieldValue(Object data) {
FieldValue fieldValue = new FieldValue();
if (null != data) {
com.alibaba.dts.formats.avro.DateTime dateTime = (com.alibaba.dts.formats.avro.DateTime)data;
// 判断是否是负数
int head = 0;
if (dateTime.getHour() <= -100) {
head = 2;
} else if ((dateTime.getHour() >= 100)
|| (dateTime.getHour() < 0)
|| (dateTime.getMinute() < 0)
|| (dateTime.getSecond() < 0)
|| ((null != dateTime.getMillis()) && (dateTime.getMillis() < 0))) {
head = 1;
}
byte[] time;
// 毫秒位0忽略
if (null == dateTime.getMillis() || 0 == dateTime.getMillis()) {
time = new byte[8 + head];
} else {
time = new byte[15 + head];
}
int index = 0;
if (head > 0 && dateTime.getHour() <= 0) {
dateTime.setHour(-dateTime.getHour());
dateTime.setMinute(-dateTime.getMinute());
dateTime.setSecond(-dateTime.getSecond());
if (null != dateTime.getMillis()) {
dateTime.setMillis(-dateTime.getMillis());
}
time[index++] = '-';
}
if (dateTime.getHour() >= 100) {
time[index++] = (byte) ('0' + (dateTime.getHour() / 100));
dateTime.setHour(dateTime.getHour() % 100);
}
encodeTime(dateTime, time, index);
encodeTimeMillis(dateTime, time, index + 8);
fieldValue.setValue(time);
}
fieldValue.setEncoding("ASCII");
return fieldValue;
}
}
static class DateTimeAdapter extends AbstractDateTimeAdapter {
public FieldValue getFieldValue(Object data) {
FieldValue fieldValue = new FieldValue();
if (null != data) {
com.alibaba.dts.formats.avro.DateTime dateTime = (com.alibaba.dts.formats.avro.DateTime) data;
byte[] time = null;
//忽略毫秒位值是0
if (null == dateTime.getMillis() || 0 == dateTime.getMillis()) {
time = new byte[19];
} else {
time = new byte[26];
}
encodeDate(dateTime, time, 0);
time[10] = ' ';
encodeTime(dateTime, time, 11);
encodeTimeMillis(dateTime, time, 19);
fieldValue.setValue(time);
}
fieldValue.setEncoding("ASCII");
return fieldValue;
}
}
static class YearAdapter implements DataAdapter {
public FieldValue getFieldValue(Object data) {
FieldValue fieldValue = new FieldValue();
if (null != data) {
com.alibaba.dts.formats.avro.DateTime dateTime = (com.alibaba.dts.formats.avro.DateTime) data;
fieldValue.setValue(Integer.toString(dateTime.getYear()).getBytes(US_ASCII));
}
fieldValue.setEncoding("ASCII");
return fieldValue;
}
}
static class CharacterAdapter implements DataAdapter {
public FieldValue getFieldValue(Object data) {
FieldValue fieldValue = new FieldValue();
if (null != data) {
com.alibaba.dts.formats.avro.Character character = (com.alibaba.dts.formats.avro.Character) data;
fieldValue.setValue(getBytes(character.getValue()));
fieldValue.setEncoding(character.getCharset());
} else {
fieldValue.setEncoding("ASCII");
}
return fieldValue;
}
}
static class GeometryAdapter implements DataAdapter {
public FieldValue getFieldValue(Object data) {
FieldValue fieldValue = new FieldValue();
if (null != data) {
com.alibaba.dts.formats.avro.BinaryGeometry geometry = (com.alibaba.dts.formats.avro.BinaryGeometry) data;
fieldValue.setValue(getBytes(geometry.getValue()));
}
return fieldValue;
}
}
static class BinaryAdapter implements DataAdapter {
public FieldValue getFieldValue(Object data) {
FieldValue fieldValue = new FieldValue();
if (null != data) {
com.alibaba.dts.formats.avro.BinaryObject binaryObject = (com.alibaba.dts.formats.avro.BinaryObject) data;
fieldValue.setValue(getBytes(binaryObject.getValue()));
}
return fieldValue;
}
}
static class TextObjectAdapter implements DataAdapter {
public FieldValue getFieldValue(Object data) {
FieldValue fieldValue = new FieldValue();
if (null != data) {
com.alibaba.dts.formats.avro.TextObject textObject = (com.alibaba.dts.formats.avro.TextObject) data;
byte[] bytes = textObject.getValue().getBytes(UTF_8);
fieldValue.setValue(bytes);
}
fieldValue.setEncoding("UTF8");
return fieldValue;
}
}
static byte[] getBytes(ByteBuffer origin) {
byte[] ret = new byte[origin.remaining()];
origin.get(ret);
return ret;
}
}
# 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.
log4j.rootLogger=INFO,logAppender,stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%d] %p %m (%c)%n
log4j.logger.com.alibaba=INFO
log4j.logger.com.taobao=INFO
package store;
import com.alibaba.dts.metastore.KafkaMetaStore;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.apache.kafka.common.TopicPartition;
import org.junit.Test;
import com.alibaba.dts.common.Checkpoint;
import java.util.Arrays;
import java.util.Properties;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
public class KafkaMetaStoreTest {
public KafkaConsumer getTestKafkaConsumer(String groupID) {
Properties props = new Properties();
props.put("bootstrap.servers", "10.101.175.161:8085");
//props.put("auto.commit.interval.ms", "1000");
// props.put("auto.offset.reset", "earliest");
props.put("session.timeout.ms", "30000");
props.put("key.deserializer", "org.apache.kafka.common.serialization.ByteArrayDeserializer");
props.put("value.deserializer", "org.apache.kafka.common.serialization.ByteArrayDeserializer");
props.put("enable.auto.commit", "false");
props.put("group.id", groupID);
return new KafkaConsumer(props);
}
@Test
public void testKafkaStore() throws ExecutionException, InterruptedException {
String groupID = "xxxxx";
TopicPartition tp = new TopicPartition("dts_kafka_topic03", 0);
KafkaConsumer kafkaConsumer = getTestKafkaConsumer(groupID);
kafkaConsumer.assign(Arrays.asList(tp));
KafkaMetaStore kafkaStore = new KafkaMetaStore(kafkaConsumer);
Future f = kafkaStore.serializeTo(tp, groupID, new Checkpoint(tp, 2048, 2048, ""));
//
kafkaConsumer.poll(1000);
f.get();
// sleepMS(10000);
Checkpoint checkpoint = kafkaStore.deserializeFrom(tp, groupID);
System.out.println(checkpoint);
}
}
package store;
import com.alibaba.dts.metastore.LocalFileMetaStore;
import org.apache.kafka.common.TopicPartition;
import org.junit.Test;
import com.alibaba.dts.common.Checkpoint;
import com.alibaba.dts.common.Util;
import static org.junit.Assert.assertTrue;
public class LocalFileMetaStoreTest {
@Test
public void testLocalFileStore() {
String fileName = "fileStore";
String desc = "";
Util.deleteFile(fileName);
LocalFileMetaStore localFileStore = new LocalFileMetaStore(fileName);
assertTrue(null == localFileStore.deserializeFrom(new TopicPartition("t1", 0), "xxx"));
localFileStore.serializeTo(new TopicPartition("t1", 0), "aa", new Checkpoint(new TopicPartition("t1", 0), 11, 11, ""));
localFileStore.serializeTo(new TopicPartition("t2", 0), "bb", new Checkpoint(new TopicPartition("t1", 0), 22, 22, ""));
localFileStore.serializeTo(new TopicPartition("t2", 1), "bb", new Checkpoint(new TopicPartition("t1", 0), 44, 44, ""));
localFileStore.serializeTo(new TopicPartition("t1", 0), "aa", new Checkpoint(new TopicPartition("t1", 0), 33, 33, ""));
assertTrue(null == localFileStore.deserializeFrom(new TopicPartition("t1", 0), "xxx"));
Checkpoint aaCheckpoint = localFileStore.deserializeFrom(new TopicPartition("t1", 0), "aa");
assertTrue(null != aaCheckpoint && aaCheckpoint.getOffset() == 33 && aaCheckpoint.getTimeStamp() == 33);
Checkpoint bbCheckpoint = localFileStore.deserializeFrom(new TopicPartition("t2", 0), "bb");
assertTrue(null != bbCheckpoint && bbCheckpoint.getOffset() == 22 && bbCheckpoint.getTimeStamp() == 22);
// init another store
LocalFileMetaStore anotherStore = new LocalFileMetaStore(fileName);
assertTrue(null == anotherStore.deserializeFrom(new TopicPartition("t1", 0), "xxx"));
aaCheckpoint = anotherStore.deserializeFrom(new TopicPartition("t1", 0), "aa");
assertTrue(null != aaCheckpoint && aaCheckpoint.getOffset() == 33 && aaCheckpoint.getTimeStamp() == 33);
bbCheckpoint = anotherStore.deserializeFrom(new TopicPartition("t2", 0), "bb");
assertTrue(null != bbCheckpoint && bbCheckpoint.getOffset() == 22 && bbCheckpoint.getTimeStamp() == 22);
Checkpoint ccCheckpoint = anotherStore.deserializeFrom(new TopicPartition("t2", 1), "bb");
assertTrue(null != ccCheckpoint && ccCheckpoint.getOffset() == 44 && ccCheckpoint.getTimeStamp() == 44);
Util.deleteFile(fileName);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment