From 952233b4d4de3850d8ce10e0c059fe4935f66fe1 Mon Sep 17 00:00:00 2001 From: y00456271 Date: Tue, 22 Nov 2022 22:52:15 +0800 Subject: [PATCH] add flink-parse-avro demo --- .../flink-parse-avro/pom.xml | 117 +++ .../bigdata/flink/avro/parser/Avro2Json.java | 230 ++++ .../CustomizedDeSerializationSchema.java | 47 + .../parser/CustomizedSerializationSchema.java | 27 + .../hwclouds/drs/avro/BinaryObject.java | 308 ++++++ .../com/huawei/hwclouds/drs/avro/Bit.java | 307 ++++++ .../huawei/hwclouds/drs/avro/Character.java | 308 ++++++ .../com/huawei/hwclouds/drs/avro/Date.java | 245 +++++ .../com/huawei/hwclouds/drs/avro/Decimal.java | 376 +++++++ .../com/huawei/hwclouds/drs/avro/Field.java | 314 ++++++ .../com/huawei/hwclouds/drs/avro/Float.java | 375 +++++++ .../com/huawei/hwclouds/drs/avro/Integer.java | 307 ++++++ .../com/huawei/hwclouds/drs/avro/Record.java | 983 ++++++++++++++++++ .../huawei/hwclouds/drs/avro/Timestamp.java | 306 ++++++ 14 files changed, 4250 insertions(+) create mode 100644 src/flink-examples/flink-examples-security/flink-parse-avro/pom.xml create mode 100644 src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/bigdata/flink/avro/parser/Avro2Json.java create mode 100644 src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/bigdata/flink/avro/parser/CustomizedDeSerializationSchema.java create mode 100644 src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/bigdata/flink/avro/parser/CustomizedSerializationSchema.java create mode 100644 src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/hwclouds/drs/avro/BinaryObject.java create mode 100644 src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/hwclouds/drs/avro/Bit.java create mode 100644 src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/hwclouds/drs/avro/Character.java create mode 100644 src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/hwclouds/drs/avro/Date.java create mode 100644 src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/hwclouds/drs/avro/Decimal.java create mode 100644 src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/hwclouds/drs/avro/Field.java create mode 100644 src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/hwclouds/drs/avro/Float.java create mode 100644 src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/hwclouds/drs/avro/Integer.java create mode 100644 src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/hwclouds/drs/avro/Record.java create mode 100644 src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/hwclouds/drs/avro/Timestamp.java diff --git a/src/flink-examples/flink-examples-security/flink-parse-avro/pom.xml b/src/flink-examples/flink-examples-security/flink-parse-avro/pom.xml new file mode 100644 index 00000000..070a7884 --- /dev/null +++ b/src/flink-examples/flink-examples-security/flink-parse-avro/pom.xml @@ -0,0 +1,117 @@ + + + 4.0.0 + + com.huawei.mrs + FlinkKafkaAvroParser + 1.0 + + + 1.12.2-hw-ei-312005 + + + + + org.apache.flink + flink-core + ${flink.version} + + + org.apache.flink + flink-shaded-hadoop-2 + + + org.apache.flink + flink-shaded-zookeeper-3 + + + + + org.apache.flink + flink-java + ${flink.version} + + + org.apache.flink + flink-shaded-hadoop-2 + + + org.apache.flink + flink-shaded-zookeeper-3 + + + + + org.apache.flink + flink-streaming-java_2.11 + ${flink.version} + + + org.apache.flink + flink-shaded-hadoop-2 + + + org.apache.flink + flink-shaded-zookeeper-3 + + + + + org.apache.flink + flink-connector-kafka_2.11 + ${flink.version} + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + true + + lib/ + + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy + compile + + + copy-dependencies + + + + + ${project.build.directory}/lib + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + + + + \ No newline at end of file diff --git a/src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/bigdata/flink/avro/parser/Avro2Json.java b/src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/bigdata/flink/avro/parser/Avro2Json.java new file mode 100644 index 00000000..a7f50f00 --- /dev/null +++ b/src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/bigdata/flink/avro/parser/Avro2Json.java @@ -0,0 +1,230 @@ +package com.huawei.bigdata.flink.avro.parser; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.huawei.hwclouds.drs.avro.Record; +import org.apache.commons.lang.StringUtils; +import org.apache.flink.api.common.functions.MapFunction; +import org.apache.flink.api.common.typeinfo.TypeHint; +import org.apache.flink.api.common.typeinfo.TypeInformation; +import org.apache.flink.api.java.utils.ParameterTool; +import org.apache.flink.streaming.api.datastream.DataStream; +import org.apache.flink.streaming.api.datastream.DataStreamSource; +import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment; +import org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumer; +import org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer; +import org.apache.flink.streaming.connectors.kafka.KafkaDeserializationSchema; +import org.apache.flink.streaming.connectors.kafka.KafkaSerializationSchema; +import org.apache.flink.streaming.util.serialization.SimpleStringSchema; +import org.apache.kafka.clients.consumer.ConsumerRecord; +import org.apache.kafka.clients.producer.ProducerRecord; + +import javax.annotation.Nullable; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Properties; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +public class Avro2Json { + public static final String TOPIC = "topic"; + + public static final String DRS_VERSION = "version"; + public static final String DRS_SEQ_NO = "seqno"; + public static final String DRS_SHARD_ID = "shardId"; + public static final String DRS_EVENT_ID = "eventid"; + public static final String DRS_UPDATE_TIMESTAMP = "updateTimestamp"; + public static final String DRS_TABLE_NAME = "tableName"; + public static final String DRS_OPERATION = "operation"; + public static final String DRS_COLUMN_COUNT = "columnCount"; + public static final String DRS_FIELDS = "fields"; + public static final String DRS_BEFORE_IMAGES = "beforeImages"; + public static final String DRS_AFTER_IMAGES = "afterImages"; + + public static final String DEBEZIUM_TS_MS = "ts_ms"; + public static final String DEBEZIUM_OP = "op"; + public static final String DEBEZIUM_SOURCE = "source"; + public static final String DEBEZIUM_BEFORE = "before"; + public static final String DEBEZIUM_AFTER = "after"; + public static final ObjectMapper JSON_MAPPER = new ObjectMapper(); + + public static void main(String[] args) throws Exception { + + ParameterTool paraTool = ParameterTool.fromArgs(args); + Properties props = paraTool.getProperties(); + String avroTopic = props.getProperty("avro_topic", "default_avro_topic"); + String jsonTopic = props.getProperty("json_topic", "default_json_topic"); + int parallelism = Integer.parseInt(props.getProperty("partition_num", "1")); + + StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); + env.setParallelism(parallelism); + + DataStream messageStream = + env.addSource( + new FlinkKafkaConsumer<>( + avroTopic, new KafkaDeserializationSchema() { + @Override + public boolean isEndOfStream(String s) { + return false; + } + + @Override + public String deserialize(ConsumerRecord consumerRecord) { + String str = ""; + try { + if (consumerRecord != null && consumerRecord.key() != null && consumerRecord.value() != null) { + Object rec = Record.getDecoder().decode(consumerRecord.value()); + str = rec.toString(); + } + } catch (IOException exception) { + exception.printStackTrace(); + } + return str; + } + + @Override + public TypeInformation getProducedType() { + return TypeInformation.of(new TypeHint(){}); + } + }, props)); + +// messageStream.filter(s -> !s.isEmpty()).map(new MapFunction>() { +// @Override +// public Map map(String jsonStr) throws Exception { +// Map map = new HashMap<>(); +// Map mapAll = mapper.readValue(jsonStr, new TypeReference>() { +// }); +// map.put(TABLE_NAME, StringUtils.remove((String) mapAll.get(TABLE_NAME), '\"')); +// map.put(UPDATE_TIMESTAMP, mapAll.get(UPDATE_TIMESTAMP)); +// map.put(OPERATION, mapAll.get(OPERATION)); +// map.put(COLUMN_NAMES, mapAll.get(FIELDS)); +// List list = (List) mapAll.get(AFTER_IMAGES); +// List newList = list.stream().map(obj -> { +// if (obj == null) { +// return new HashMap() {{ +// put("value", null); +// }}; +// } else { +// return obj; +// } +// }).collect(Collectors.toList()); +// map.put(COLUMN_VALUES, newList); + + messageStream.filter(str -> !str.isEmpty()).map(new MapFunction>() { + @Override + public Map map(String jsonStr) throws Exception { + Map drsJsonMap = JSON_MAPPER.readValue(jsonStr, HashMap.class); + String version = String.valueOf(drsJsonMap.get(DRS_VERSION)); + String seqno = String.valueOf(drsJsonMap.get(DRS_SEQ_NO)); + String shardId = String.valueOf(drsJsonMap.get(DRS_SHARD_ID)); + String eventId = String.valueOf(drsJsonMap.get(DRS_EVENT_ID)); + String updateTimestamp = String.valueOf(drsJsonMap.get(DRS_UPDATE_TIMESTAMP)); + String tableName = StringUtils.remove(String.valueOf(drsJsonMap.get(DRS_TABLE_NAME)), '\"'); + String operation = String.valueOf(drsJsonMap.get(DRS_OPERATION)); + String columnCount = String.valueOf(drsJsonMap.get(DRS_COLUMN_COUNT)); + List fields = drsJsonMap.get(DRS_FIELDS) != null ? (List) drsJsonMap.get(DRS_FIELDS) : null; + List beforeImages = drsJsonMap.get(DRS_BEFORE_IMAGES) != null ? (List) drsJsonMap.get(DRS_BEFORE_IMAGES) : null; + List afterImages = drsJsonMap.get(DRS_AFTER_IMAGES) != null ? (List) drsJsonMap.get(DRS_AFTER_IMAGES) : null; + + if (fields == null) { + return null; + } + + String op = null; + if (operation.equalsIgnoreCase("INSERT")) { + op = "c"; + } + if (operation.equalsIgnoreCase("UPDATE")) { + op = "u"; + } + if (operation.equalsIgnoreCase("DELETE")) { + op = "d"; + } + if (op == null) { + return null; + } + + Map debeziumJsonMap = new HashMap<>(); + debeziumJsonMap.put(DEBEZIUM_OP, op); + debeziumJsonMap.put(DEBEZIUM_TS_MS, Long.parseLong(updateTimestamp)); + + Map debeziumSourceJsonMap = new HashMap<>(); + debeziumSourceJsonMap.put(DRS_VERSION, version); + debeziumSourceJsonMap.put(DRS_SEQ_NO, seqno); + debeziumSourceJsonMap.put(DRS_SHARD_ID, shardId); + debeziumSourceJsonMap.put(DRS_EVENT_ID, eventId); + debeziumSourceJsonMap.put(DRS_UPDATE_TIMESTAMP, updateTimestamp); + debeziumSourceJsonMap.put(DRS_OPERATION, op); + debeziumSourceJsonMap.put(DRS_TABLE_NAME, tableName); + debeziumSourceJsonMap.put(DRS_COLUMN_COUNT, columnCount); + debeziumJsonMap.put(DEBEZIUM_SOURCE, debeziumSourceJsonMap); + + List fieldStrList = fields.stream() + .map(field -> ((Map) field).get("name")).collect(Collectors.toList()); + + if (beforeImages == null) { + debeziumJsonMap.put(DEBEZIUM_BEFORE, null); + } else { + List beforeStrList = beforeImages.stream() + .map(before -> { + if (before == null) { + return null; + } + return ((Map) before).get("value"); + }).collect(Collectors.toList()); + Map debeziumBeforeJsonMap = new HashMap<>(); + for (int i = 0; i < Integer.parseInt(columnCount); i++) { + debeziumBeforeJsonMap.put(fieldStrList.get(i), beforeStrList.get(i)); + } + debeziumJsonMap.put(DEBEZIUM_BEFORE, debeziumBeforeJsonMap); + } + + if (afterImages == null) { + debeziumJsonMap.put(DEBEZIUM_AFTER, null); + } else { + List afterStrList = afterImages.stream() + .map(after -> { + if (after == null) { + return null; + } + return ((Map) after).get("value"); + }).collect(Collectors.toList()); + Map debeziumAfterJsonMap = new HashMap<>(); + for (int i = 0; i < Integer.parseInt(columnCount); i++) { + debeziumAfterJsonMap.put(fieldStrList.get(i), afterStrList.get(i)); + } + debeziumJsonMap.put(DEBEZIUM_AFTER, debeziumAfterJsonMap); + } + + return debeziumJsonMap; + } + }).filter(Objects::nonNull).setParallelism(parallelism) + .addSink(new FlinkKafkaProducer<>(jsonTopic, (KafkaSerializationSchema>) (jsonMap, aLong) -> { + byte[] key = null; + byte[] value = null; + try { + key = ((Map) jsonMap.get(DEBEZIUM_SOURCE)).get(DRS_TABLE_NAME).getBytes(); + value = JSON_MAPPER.writeValueAsBytes(jsonMap); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + return new ProducerRecord<>(jsonTopic, key, value); + }, props, FlinkKafkaProducer.Semantic.EXACTLY_ONCE)); + env.execute(); + +// DataStreamSource> messageStream = +// env.addSource( +// new FlinkKafkaConsumer<>( +// avroTopic, new CustomizedDeSerializationSchema(), props)); +// messageStream.filter(map -> !map.isEmpty()) +// .addSink(new FlinkKafkaProducer<>(jsonTopic, new CustomizedSerializationSchema(), props, FlinkKafkaProducer.Semantic.EXACTLY_ONCE)); +// env.execute(); + + + } +} diff --git a/src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/bigdata/flink/avro/parser/CustomizedDeSerializationSchema.java b/src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/bigdata/flink/avro/parser/CustomizedDeSerializationSchema.java new file mode 100644 index 00000000..2bd6f064 --- /dev/null +++ b/src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/bigdata/flink/avro/parser/CustomizedDeSerializationSchema.java @@ -0,0 +1,47 @@ +package com.huawei.bigdata.flink.avro.parser; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.huawei.hwclouds.drs.avro.Record; +import org.apache.flink.api.common.typeinfo.TypeHint; +import org.apache.flink.api.common.typeinfo.TypeInformation; +import org.apache.flink.streaming.connectors.kafka.KafkaDeserializationSchema; +import org.apache.kafka.clients.consumer.ConsumerRecord; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +public class CustomizedDeSerializationSchema implements KafkaDeserializationSchema> { + + @Override + public boolean isEndOfStream(Map map) { + return false; + } + + @Override + public Map deserialize(ConsumerRecord consumerRecord) { + ObjectMapper mapper = new ObjectMapper(); + Map map = new HashMap<>(); + if (consumerRecord != null && consumerRecord.key() != null && consumerRecord.value() != null) { + try { + Object rec = Record.getDecoder().decode(consumerRecord.value()); + Map mapAll = mapper.readValue(rec.toString(), new TypeReference>(){}); + map.put(Avro2Json.TOPIC, consumerRecord.topic()); + map.put(Avro2Json.DRS_TABLE_NAME, mapAll.get(Avro2Json.DRS_TABLE_NAME)); + map.put(Avro2Json.DRS_UPDATE_TIMESTAMP, mapAll.get(Avro2Json.DRS_UPDATE_TIMESTAMP)); + map.put(Avro2Json.DRS_OPERATION, mapAll.get(Avro2Json.DRS_OPERATION)); + map.put("columnNames", mapAll.get(Avro2Json.DRS_FIELDS)); + map.put("columnValues", mapAll.get(Avro2Json.DRS_AFTER_IMAGES)); + } catch (IOException exception) { + exception.printStackTrace(); + } + } + return map; + } + + @Override + public TypeInformation> getProducedType() { + return TypeInformation.of(new TypeHint>(){}); + } +} diff --git a/src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/bigdata/flink/avro/parser/CustomizedSerializationSchema.java b/src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/bigdata/flink/avro/parser/CustomizedSerializationSchema.java new file mode 100644 index 00000000..7c313465 --- /dev/null +++ b/src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/bigdata/flink/avro/parser/CustomizedSerializationSchema.java @@ -0,0 +1,27 @@ +package com.huawei.bigdata.flink.avro.parser; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.flink.streaming.connectors.kafka.KafkaSerializationSchema; +import org.apache.kafka.clients.producer.ProducerRecord; + +import javax.annotation.Nullable; +import java.util.Map; + +public class CustomizedSerializationSchema implements KafkaSerializationSchema> { + + @Override + public ProducerRecord serialize(Map map, @Nullable Long aLong) { + ProducerRecord producerRecord = null; + try { + ObjectMapper mapper = new ObjectMapper(); + String topic = (String) map.get(Avro2Json.TOPIC); + String tableName = (String) map.get(Avro2Json.DRS_TABLE_NAME); + String jsonStr = mapper.writeValueAsString(map); + producerRecord = new ProducerRecord<>(topic, tableName.getBytes(), jsonStr.getBytes()); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + return producerRecord; + } +} diff --git a/src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/hwclouds/drs/avro/BinaryObject.java b/src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/hwclouds/drs/avro/BinaryObject.java new file mode 100644 index 00000000..e1c067ef --- /dev/null +++ b/src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/hwclouds/drs/avro/BinaryObject.java @@ -0,0 +1,308 @@ +/** + * Autogenerated by Avro + * + * DO NOT EDIT DIRECTLY + */ +package com.huawei.hwclouds.drs.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 = -1488248334912497566L; + public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"BinaryObject\",\"namespace\":\"com.huawei.hwclouds.drs.avro\",\"fields\":[{\"name\":\"type\",\"type\":\"string\"},{\"name\":\"value\",\"type\":\"bytes\"}]}"); + public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } + + private static SpecificData MODEL$ = new SpecificData(); + + private static final BinaryMessageEncoder ENCODER = + new BinaryMessageEncoder(MODEL$, SCHEMA$); + + private static final BinaryMessageDecoder DECODER = + new BinaryMessageDecoder(MODEL$, SCHEMA$); + + /** + * Return the BinaryMessageDecoder instance used by this class. + */ + public static BinaryMessageDecoder 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 createDecoder(SchemaStore resolver) { + return new BinaryMessageDecoder(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.CharSequence 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 newBuilder(). + */ + public BinaryObject() {} + + /** + * All-args constructor. + * @param type The new value for type + * @param value The new value for value + */ + public BinaryObject(java.lang.CharSequence 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.CharSequence)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.CharSequence getType() { + return type; + } + + /** + * Sets the value of the 'type' field. + * @param value the value to set. + */ + public void setType(java.lang.CharSequence 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.huawei.hwclouds.drs.avro.BinaryObject.Builder newBuilder() { + return new com.huawei.hwclouds.drs.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.huawei.hwclouds.drs.avro.BinaryObject.Builder newBuilder(com.huawei.hwclouds.drs.avro.BinaryObject.Builder other) { + return new com.huawei.hwclouds.drs.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.huawei.hwclouds.drs.avro.BinaryObject.Builder newBuilder(com.huawei.hwclouds.drs.avro.BinaryObject other) { + return new com.huawei.hwclouds.drs.avro.BinaryObject.Builder(other); + } + + /** + * RecordBuilder for BinaryObject instances. + */ + public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase + implements org.apache.avro.data.RecordBuilder { + + private java.lang.CharSequence 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.huawei.hwclouds.drs.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.huawei.hwclouds.drs.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.CharSequence getType() { + return type; + } + + /** + * Sets the value of the 'type' field. + * @param value The value of 'type'. + * @return This builder. + */ + public com.huawei.hwclouds.drs.avro.BinaryObject.Builder setType(java.lang.CharSequence 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.huawei.hwclouds.drs.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.huawei.hwclouds.drs.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.huawei.hwclouds.drs.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.CharSequence) 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 + WRITER$ = (org.apache.avro.io.DatumWriter)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 + READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); + + @Override public void readExternal(java.io.ObjectInput in) + throws java.io.IOException { + READER$.read(this, SpecificData.getDecoder(in)); + } + +} diff --git a/src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/hwclouds/drs/avro/Bit.java b/src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/hwclouds/drs/avro/Bit.java new file mode 100644 index 00000000..3f60e247 --- /dev/null +++ b/src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/hwclouds/drs/avro/Bit.java @@ -0,0 +1,307 @@ +/** + * Autogenerated by Avro + * + * DO NOT EDIT DIRECTLY + */ +package com.huawei.hwclouds.drs.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 Bit extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { + private static final long serialVersionUID = 6977607147739631720L; + public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Bit\",\"namespace\":\"com.huawei.hwclouds.drs.avro\",\"fields\":[{\"name\":\"precision\",\"type\":\"int\"},{\"name\":\"value\",\"type\":\"string\"}]}"); + public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } + + private static SpecificData MODEL$ = new SpecificData(); + + private static final BinaryMessageEncoder ENCODER = + new BinaryMessageEncoder(MODEL$, SCHEMA$); + + private static final BinaryMessageDecoder DECODER = + new BinaryMessageDecoder(MODEL$, SCHEMA$); + + /** + * Return the BinaryMessageDecoder instance used by this class. + */ + public static BinaryMessageDecoder 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 createDecoder(SchemaStore resolver) { + return new BinaryMessageDecoder(MODEL$, SCHEMA$, resolver); + } + + /** Serializes this Bit to a ByteBuffer. */ + public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { + return ENCODER.encode(this); + } + + /** Deserializes a Bit from a ByteBuffer. */ + public static Bit fromByteBuffer( + java.nio.ByteBuffer b) throws java.io.IOException { + return DECODER.decode(b); + } + + @Deprecated public int precision; + @Deprecated public java.lang.CharSequence 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 newBuilder(). + */ + public Bit() {} + + /** + * All-args constructor. + * @param precision The new value for precision + * @param value The new value for value + */ + public Bit(java.lang.Integer precision, java.lang.CharSequence 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.CharSequence)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.CharSequence getValue() { + return value; + } + + /** + * Sets the value of the 'value' field. + * @param value the value to set. + */ + public void setValue(java.lang.CharSequence value) { + this.value = value; + } + + /** + * Creates a new Bit RecordBuilder. + * @return A new Bit RecordBuilder + */ + public static com.huawei.hwclouds.drs.avro.Bit.Builder newBuilder() { + return new com.huawei.hwclouds.drs.avro.Bit.Builder(); + } + + /** + * Creates a new Bit RecordBuilder by copying an existing Builder. + * @param other The existing builder to copy. + * @return A new Bit RecordBuilder + */ + public static com.huawei.hwclouds.drs.avro.Bit.Builder newBuilder(com.huawei.hwclouds.drs.avro.Bit.Builder other) { + return new com.huawei.hwclouds.drs.avro.Bit.Builder(other); + } + + /** + * Creates a new Bit RecordBuilder by copying an existing Bit instance. + * @param other The existing instance to copy. + * @return A new Bit RecordBuilder + */ + public static com.huawei.hwclouds.drs.avro.Bit.Builder newBuilder(com.huawei.hwclouds.drs.avro.Bit other) { + return new com.huawei.hwclouds.drs.avro.Bit.Builder(other); + } + + /** + * RecordBuilder for Bit instances. + */ + public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase + implements org.apache.avro.data.RecordBuilder { + + private int precision; + private java.lang.CharSequence 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.huawei.hwclouds.drs.avro.Bit.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 Bit instance + * @param other The existing instance to copy. + */ + private Builder(com.huawei.hwclouds.drs.avro.Bit 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.huawei.hwclouds.drs.avro.Bit.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.huawei.hwclouds.drs.avro.Bit.Builder clearPrecision() { + fieldSetFlags()[0] = false; + return this; + } + + /** + * Gets the value of the 'value' field. + * @return The value. + */ + public java.lang.CharSequence getValue() { + return value; + } + + /** + * Sets the value of the 'value' field. + * @param value The value of 'value'. + * @return This builder. + */ + public com.huawei.hwclouds.drs.avro.Bit.Builder setValue(java.lang.CharSequence 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.huawei.hwclouds.drs.avro.Bit.Builder clearValue() { + value = null; + fieldSetFlags()[1] = false; + return this; + } + + @Override + @SuppressWarnings("unchecked") + public Bit build() { + try { + Bit record = new Bit(); + record.precision = fieldSetFlags()[0] ? this.precision : (java.lang.Integer) defaultValue(fields()[0]); + record.value = fieldSetFlags()[1] ? this.value : (java.lang.CharSequence) 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 + WRITER$ = (org.apache.avro.io.DatumWriter)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 + READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); + + @Override public void readExternal(java.io.ObjectInput in) + throws java.io.IOException { + READER$.read(this, SpecificData.getDecoder(in)); + } + +} diff --git a/src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/hwclouds/drs/avro/Character.java b/src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/hwclouds/drs/avro/Character.java new file mode 100644 index 00000000..bbd3bbc8 --- /dev/null +++ b/src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/hwclouds/drs/avro/Character.java @@ -0,0 +1,308 @@ +/** + * Autogenerated by Avro + * + * DO NOT EDIT DIRECTLY + */ +package com.huawei.hwclouds.drs.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 = 8228315679191500556L; + public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Character\",\"namespace\":\"com.huawei.hwclouds.drs.avro\",\"fields\":[{\"name\":\"charset\",\"type\":\"string\"},{\"name\":\"value\",\"type\":\"bytes\"}]}"); + public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } + + private static SpecificData MODEL$ = new SpecificData(); + + private static final BinaryMessageEncoder ENCODER = + new BinaryMessageEncoder(MODEL$, SCHEMA$); + + private static final BinaryMessageDecoder DECODER = + new BinaryMessageDecoder(MODEL$, SCHEMA$); + + /** + * Return the BinaryMessageDecoder instance used by this class. + */ + public static BinaryMessageDecoder 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 createDecoder(SchemaStore resolver) { + return new BinaryMessageDecoder(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.CharSequence 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 newBuilder(). + */ + public Character() {} + + /** + * All-args constructor. + * @param charset The new value for charset + * @param value The new value for value + */ + public Character(java.lang.CharSequence 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.CharSequence)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.CharSequence getCharset() { + return charset; + } + + /** + * Sets the value of the 'charset' field. + * @param value the value to set. + */ + public void setCharset(java.lang.CharSequence 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.huawei.hwclouds.drs.avro.Character.Builder newBuilder() { + return new com.huawei.hwclouds.drs.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.huawei.hwclouds.drs.avro.Character.Builder newBuilder(com.huawei.hwclouds.drs.avro.Character.Builder other) { + return new com.huawei.hwclouds.drs.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.huawei.hwclouds.drs.avro.Character.Builder newBuilder(com.huawei.hwclouds.drs.avro.Character other) { + return new com.huawei.hwclouds.drs.avro.Character.Builder(other); + } + + /** + * RecordBuilder for Character instances. + */ + public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase + implements org.apache.avro.data.RecordBuilder { + + private java.lang.CharSequence 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.huawei.hwclouds.drs.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.huawei.hwclouds.drs.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.CharSequence getCharset() { + return charset; + } + + /** + * Sets the value of the 'charset' field. + * @param value The value of 'charset'. + * @return This builder. + */ + public com.huawei.hwclouds.drs.avro.Character.Builder setCharset(java.lang.CharSequence 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.huawei.hwclouds.drs.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.huawei.hwclouds.drs.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.huawei.hwclouds.drs.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.CharSequence) 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 + WRITER$ = (org.apache.avro.io.DatumWriter)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 + READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); + + @Override public void readExternal(java.io.ObjectInput in) + throws java.io.IOException { + READER$.read(this, SpecificData.getDecoder(in)); + } + +} diff --git a/src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/hwclouds/drs/avro/Date.java b/src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/hwclouds/drs/avro/Date.java new file mode 100644 index 00000000..44624fae --- /dev/null +++ b/src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/hwclouds/drs/avro/Date.java @@ -0,0 +1,245 @@ +/** + * Autogenerated by Avro + * + * DO NOT EDIT DIRECTLY + */ +package com.huawei.hwclouds.drs.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 Date extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { + private static final long serialVersionUID = 5099846483595947937L; + public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Date\",\"namespace\":\"com.huawei.hwclouds.drs.avro\",\"fields\":[{\"name\":\"value\",\"type\":\"string\",\"doc\":\"Field.dataTypeNumber = 94(DateTime) format:YYYY-MM-DD HH:MM:SS\"}]}"); + public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } + + private static SpecificData MODEL$ = new SpecificData(); + + private static final BinaryMessageEncoder ENCODER = + new BinaryMessageEncoder(MODEL$, SCHEMA$); + + private static final BinaryMessageDecoder DECODER = + new BinaryMessageDecoder(MODEL$, SCHEMA$); + + /** + * Return the BinaryMessageDecoder instance used by this class. + */ + public static BinaryMessageDecoder 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 createDecoder(SchemaStore resolver) { + return new BinaryMessageDecoder(MODEL$, SCHEMA$, resolver); + } + + /** Serializes this Date to a ByteBuffer. */ + public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { + return ENCODER.encode(this); + } + + /** Deserializes a Date from a ByteBuffer. */ + public static Date fromByteBuffer( + java.nio.ByteBuffer b) throws java.io.IOException { + return DECODER.decode(b); + } + + /** Field.dataTypeNumber = 94(DateTime) format:YYYY-MM-DD HH:MM:SS */ + @Deprecated public java.lang.CharSequence 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 newBuilder(). + */ + public Date() {} + + /** + * All-args constructor. + * @param value Field.dataTypeNumber = 94(DateTime) format:YYYY-MM-DD HH:MM:SS + */ + public Date(java.lang.CharSequence value) { + 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 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: value = (java.lang.CharSequence)value$; break; + default: throw new org.apache.avro.AvroRuntimeException("Bad index"); + } + } + + /** + * Gets the value of the 'value' field. + * @return Field.dataTypeNumber = 94(DateTime) format:YYYY-MM-DD HH:MM:SS + */ + public java.lang.CharSequence getValue() { + return value; + } + + /** + * Sets the value of the 'value' field. + * Field.dataTypeNumber = 94(DateTime) format:YYYY-MM-DD HH:MM:SS + * @param value the value to set. + */ + public void setValue(java.lang.CharSequence value) { + this.value = value; + } + + /** + * Creates a new Date RecordBuilder. + * @return A new Date RecordBuilder + */ + public static com.huawei.hwclouds.drs.avro.Date.Builder newBuilder() { + return new com.huawei.hwclouds.drs.avro.Date.Builder(); + } + + /** + * Creates a new Date RecordBuilder by copying an existing Builder. + * @param other The existing builder to copy. + * @return A new Date RecordBuilder + */ + public static com.huawei.hwclouds.drs.avro.Date.Builder newBuilder(com.huawei.hwclouds.drs.avro.Date.Builder other) { + return new com.huawei.hwclouds.drs.avro.Date.Builder(other); + } + + /** + * Creates a new Date RecordBuilder by copying an existing Date instance. + * @param other The existing instance to copy. + * @return A new Date RecordBuilder + */ + public static com.huawei.hwclouds.drs.avro.Date.Builder newBuilder(com.huawei.hwclouds.drs.avro.Date other) { + return new com.huawei.hwclouds.drs.avro.Date.Builder(other); + } + + /** + * RecordBuilder for Date instances. + */ + public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase + implements org.apache.avro.data.RecordBuilder { + + /** Field.dataTypeNumber = 94(DateTime) format:YYYY-MM-DD HH:MM:SS */ + private java.lang.CharSequence 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.huawei.hwclouds.drs.avro.Date.Builder other) { + super(other); + if (isValidValue(fields()[0], other.value)) { + this.value = data().deepCopy(fields()[0].schema(), other.value); + fieldSetFlags()[0] = true; + } + } + + /** + * Creates a Builder by copying an existing Date instance + * @param other The existing instance to copy. + */ + private Builder(com.huawei.hwclouds.drs.avro.Date other) { + super(SCHEMA$); + if (isValidValue(fields()[0], other.value)) { + this.value = data().deepCopy(fields()[0].schema(), other.value); + fieldSetFlags()[0] = true; + } + } + + /** + * Gets the value of the 'value' field. + * Field.dataTypeNumber = 94(DateTime) format:YYYY-MM-DD HH:MM:SS + * @return The value. + */ + public java.lang.CharSequence getValue() { + return value; + } + + /** + * Sets the value of the 'value' field. + * Field.dataTypeNumber = 94(DateTime) format:YYYY-MM-DD HH:MM:SS + * @param value The value of 'value'. + * @return This builder. + */ + public com.huawei.hwclouds.drs.avro.Date.Builder setValue(java.lang.CharSequence value) { + validate(fields()[0], value); + this.value = value; + fieldSetFlags()[0] = true; + return this; + } + + /** + * Checks whether the 'value' field has been set. + * Field.dataTypeNumber = 94(DateTime) format:YYYY-MM-DD HH:MM:SS + * @return True if the 'value' field has been set, false otherwise. + */ + public boolean hasValue() { + return fieldSetFlags()[0]; + } + + + /** + * Clears the value of the 'value' field. + * Field.dataTypeNumber = 94(DateTime) format:YYYY-MM-DD HH:MM:SS + * @return This builder. + */ + public com.huawei.hwclouds.drs.avro.Date.Builder clearValue() { + value = null; + fieldSetFlags()[0] = false; + return this; + } + + @Override + @SuppressWarnings("unchecked") + public Date build() { + try { + Date record = new Date(); + record.value = fieldSetFlags()[0] ? this.value : (java.lang.CharSequence) defaultValue(fields()[0]); + return record; + } catch (java.lang.Exception e) { + throw new org.apache.avro.AvroRuntimeException(e); + } + } + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumWriter + WRITER$ = (org.apache.avro.io.DatumWriter)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 + READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); + + @Override public void readExternal(java.io.ObjectInput in) + throws java.io.IOException { + READER$.read(this, SpecificData.getDecoder(in)); + } + +} diff --git a/src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/hwclouds/drs/avro/Decimal.java b/src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/hwclouds/drs/avro/Decimal.java new file mode 100644 index 00000000..232211c3 --- /dev/null +++ b/src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/hwclouds/drs/avro/Decimal.java @@ -0,0 +1,376 @@ +/** + * Autogenerated by Avro + * + * DO NOT EDIT DIRECTLY + */ +package com.huawei.hwclouds.drs.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 = -2192635999292750318L; + public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Decimal\",\"namespace\":\"com.huawei.hwclouds.drs.avro\",\"fields\":[{\"name\":\"value\",\"type\":\"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 ENCODER = + new BinaryMessageEncoder(MODEL$, SCHEMA$); + + private static final BinaryMessageDecoder DECODER = + new BinaryMessageDecoder(MODEL$, SCHEMA$); + + /** + * Return the BinaryMessageDecoder instance used by this class. + */ + public static BinaryMessageDecoder 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 createDecoder(SchemaStore resolver) { + return new BinaryMessageDecoder(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.CharSequence 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 newBuilder(). + */ + 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.CharSequence 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.CharSequence)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.CharSequence getValue() { + return value; + } + + /** + * Sets the value of the 'value' field. + * @param value the value to set. + */ + public void setValue(java.lang.CharSequence 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.huawei.hwclouds.drs.avro.Decimal.Builder newBuilder() { + return new com.huawei.hwclouds.drs.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.huawei.hwclouds.drs.avro.Decimal.Builder newBuilder(com.huawei.hwclouds.drs.avro.Decimal.Builder other) { + return new com.huawei.hwclouds.drs.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.huawei.hwclouds.drs.avro.Decimal.Builder newBuilder(com.huawei.hwclouds.drs.avro.Decimal other) { + return new com.huawei.hwclouds.drs.avro.Decimal.Builder(other); + } + + /** + * RecordBuilder for Decimal instances. + */ + public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase + implements org.apache.avro.data.RecordBuilder { + + private java.lang.CharSequence 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.huawei.hwclouds.drs.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.huawei.hwclouds.drs.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.CharSequence getValue() { + return value; + } + + /** + * Sets the value of the 'value' field. + * @param value The value of 'value'. + * @return This builder. + */ + public com.huawei.hwclouds.drs.avro.Decimal.Builder setValue(java.lang.CharSequence 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.huawei.hwclouds.drs.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.huawei.hwclouds.drs.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.huawei.hwclouds.drs.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.huawei.hwclouds.drs.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.huawei.hwclouds.drs.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.CharSequence) 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 + WRITER$ = (org.apache.avro.io.DatumWriter)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 + READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); + + @Override public void readExternal(java.io.ObjectInput in) + throws java.io.IOException { + READER$.read(this, SpecificData.getDecoder(in)); + } + +} diff --git a/src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/hwclouds/drs/avro/Field.java b/src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/hwclouds/drs/avro/Field.java new file mode 100644 index 00000000..76036b93 --- /dev/null +++ b/src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/hwclouds/drs/avro/Field.java @@ -0,0 +1,314 @@ +/** + * Autogenerated by Avro + * + * DO NOT EDIT DIRECTLY + */ +package com.huawei.hwclouds.drs.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 = -7647907005166951319L; + public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Field\",\"namespace\":\"com.huawei.hwclouds.drs.avro\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"dataTypeNumber\",\"type\":\"int\",\"doc\":\"2004, BinaryObject\"}]}"); + public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } + + private static SpecificData MODEL$ = new SpecificData(); + + private static final BinaryMessageEncoder ENCODER = + new BinaryMessageEncoder(MODEL$, SCHEMA$); + + private static final BinaryMessageDecoder DECODER = + new BinaryMessageDecoder(MODEL$, SCHEMA$); + + /** + * Return the BinaryMessageDecoder instance used by this class. + */ + public static BinaryMessageDecoder 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 createDecoder(SchemaStore resolver) { + return new BinaryMessageDecoder(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.CharSequence name; + /** 2004, BinaryObject */ + @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 newBuilder(). + */ + public Field() {} + + /** + * All-args constructor. + * @param name The new value for name + * @param dataTypeNumber 2004, BinaryObject + */ + public Field(java.lang.CharSequence 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.CharSequence)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.CharSequence getName() { + return name; + } + + /** + * Sets the value of the 'name' field. + * @param value the value to set. + */ + public void setName(java.lang.CharSequence value) { + this.name = value; + } + + /** + * Gets the value of the 'dataTypeNumber' field. + * @return 2004, BinaryObject + */ + public java.lang.Integer getDataTypeNumber() { + return dataTypeNumber; + } + + /** + * Sets the value of the 'dataTypeNumber' field. + * 2004, BinaryObject + * @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.huawei.hwclouds.drs.avro.Field.Builder newBuilder() { + return new com.huawei.hwclouds.drs.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.huawei.hwclouds.drs.avro.Field.Builder newBuilder(com.huawei.hwclouds.drs.avro.Field.Builder other) { + return new com.huawei.hwclouds.drs.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.huawei.hwclouds.drs.avro.Field.Builder newBuilder(com.huawei.hwclouds.drs.avro.Field other) { + return new com.huawei.hwclouds.drs.avro.Field.Builder(other); + } + + /** + * RecordBuilder for Field instances. + */ + public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase + implements org.apache.avro.data.RecordBuilder { + + private java.lang.CharSequence name; + /** 2004, BinaryObject */ + 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.huawei.hwclouds.drs.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.huawei.hwclouds.drs.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.CharSequence getName() { + return name; + } + + /** + * Sets the value of the 'name' field. + * @param value The value of 'name'. + * @return This builder. + */ + public com.huawei.hwclouds.drs.avro.Field.Builder setName(java.lang.CharSequence 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.huawei.hwclouds.drs.avro.Field.Builder clearName() { + name = null; + fieldSetFlags()[0] = false; + return this; + } + + /** + * Gets the value of the 'dataTypeNumber' field. + * 2004, BinaryObject + * @return The value. + */ + public java.lang.Integer getDataTypeNumber() { + return dataTypeNumber; + } + + /** + * Sets the value of the 'dataTypeNumber' field. + * 2004, BinaryObject + * @param value The value of 'dataTypeNumber'. + * @return This builder. + */ + public com.huawei.hwclouds.drs.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. + * 2004, BinaryObject + * @return True if the 'dataTypeNumber' field has been set, false otherwise. + */ + public boolean hasDataTypeNumber() { + return fieldSetFlags()[1]; + } + + + /** + * Clears the value of the 'dataTypeNumber' field. + * 2004, BinaryObject + * @return This builder. + */ + public com.huawei.hwclouds.drs.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.CharSequence) 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 + WRITER$ = (org.apache.avro.io.DatumWriter)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 + READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); + + @Override public void readExternal(java.io.ObjectInput in) + throws java.io.IOException { + READER$.read(this, SpecificData.getDecoder(in)); + } + +} diff --git a/src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/hwclouds/drs/avro/Float.java b/src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/hwclouds/drs/avro/Float.java new file mode 100644 index 00000000..62251932 --- /dev/null +++ b/src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/hwclouds/drs/avro/Float.java @@ -0,0 +1,375 @@ +/** + * Autogenerated by Avro + * + * DO NOT EDIT DIRECTLY + */ +package com.huawei.hwclouds.drs.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 = -345095849001738989L; + public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Float\",\"namespace\":\"com.huawei.hwclouds.drs.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 ENCODER = + new BinaryMessageEncoder(MODEL$, SCHEMA$); + + private static final BinaryMessageDecoder DECODER = + new BinaryMessageDecoder(MODEL$, SCHEMA$); + + /** + * Return the BinaryMessageDecoder instance used by this class. + */ + public static BinaryMessageDecoder 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 createDecoder(SchemaStore resolver) { + return new BinaryMessageDecoder(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 newBuilder(). + */ + 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.huawei.hwclouds.drs.avro.Float.Builder newBuilder() { + return new com.huawei.hwclouds.drs.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.huawei.hwclouds.drs.avro.Float.Builder newBuilder(com.huawei.hwclouds.drs.avro.Float.Builder other) { + return new com.huawei.hwclouds.drs.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.huawei.hwclouds.drs.avro.Float.Builder newBuilder(com.huawei.hwclouds.drs.avro.Float other) { + return new com.huawei.hwclouds.drs.avro.Float.Builder(other); + } + + /** + * RecordBuilder for Float instances. + */ + public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase + implements org.apache.avro.data.RecordBuilder { + + 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.huawei.hwclouds.drs.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.huawei.hwclouds.drs.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.huawei.hwclouds.drs.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.huawei.hwclouds.drs.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.huawei.hwclouds.drs.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.huawei.hwclouds.drs.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.huawei.hwclouds.drs.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.huawei.hwclouds.drs.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 + WRITER$ = (org.apache.avro.io.DatumWriter)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 + READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); + + @Override public void readExternal(java.io.ObjectInput in) + throws java.io.IOException { + READER$.read(this, SpecificData.getDecoder(in)); + } + +} diff --git a/src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/hwclouds/drs/avro/Integer.java b/src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/hwclouds/drs/avro/Integer.java new file mode 100644 index 00000000..3e09cb1f --- /dev/null +++ b/src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/hwclouds/drs/avro/Integer.java @@ -0,0 +1,307 @@ +/** + * Autogenerated by Avro + * + * DO NOT EDIT DIRECTLY + */ +package com.huawei.hwclouds.drs.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 = -5960734445972534049L; + public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Integer\",\"namespace\":\"com.huawei.hwclouds.drs.avro\",\"fields\":[{\"name\":\"precision\",\"type\":\"int\"},{\"name\":\"value\",\"type\":\"string\"}]}"); + public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } + + private static SpecificData MODEL$ = new SpecificData(); + + private static final BinaryMessageEncoder ENCODER = + new BinaryMessageEncoder(MODEL$, SCHEMA$); + + private static final BinaryMessageDecoder DECODER = + new BinaryMessageDecoder(MODEL$, SCHEMA$); + + /** + * Return the BinaryMessageDecoder instance used by this class. + */ + public static BinaryMessageDecoder 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 createDecoder(SchemaStore resolver) { + return new BinaryMessageDecoder(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.CharSequence 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 newBuilder(). + */ + 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.CharSequence 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.CharSequence)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.CharSequence getValue() { + return value; + } + + /** + * Sets the value of the 'value' field. + * @param value the value to set. + */ + public void setValue(java.lang.CharSequence value) { + this.value = value; + } + + /** + * Creates a new Integer RecordBuilder. + * @return A new Integer RecordBuilder + */ + public static com.huawei.hwclouds.drs.avro.Integer.Builder newBuilder() { + return new com.huawei.hwclouds.drs.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.huawei.hwclouds.drs.avro.Integer.Builder newBuilder(com.huawei.hwclouds.drs.avro.Integer.Builder other) { + return new com.huawei.hwclouds.drs.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.huawei.hwclouds.drs.avro.Integer.Builder newBuilder(com.huawei.hwclouds.drs.avro.Integer other) { + return new com.huawei.hwclouds.drs.avro.Integer.Builder(other); + } + + /** + * RecordBuilder for Integer instances. + */ + public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase + implements org.apache.avro.data.RecordBuilder { + + private int precision; + private java.lang.CharSequence 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.huawei.hwclouds.drs.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.huawei.hwclouds.drs.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.huawei.hwclouds.drs.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.huawei.hwclouds.drs.avro.Integer.Builder clearPrecision() { + fieldSetFlags()[0] = false; + return this; + } + + /** + * Gets the value of the 'value' field. + * @return The value. + */ + public java.lang.CharSequence getValue() { + return value; + } + + /** + * Sets the value of the 'value' field. + * @param value The value of 'value'. + * @return This builder. + */ + public com.huawei.hwclouds.drs.avro.Integer.Builder setValue(java.lang.CharSequence 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.huawei.hwclouds.drs.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.CharSequence) 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 + WRITER$ = (org.apache.avro.io.DatumWriter)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 + READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); + + @Override public void readExternal(java.io.ObjectInput in) + throws java.io.IOException { + READER$.read(this, SpecificData.getDecoder(in)); + } + +} diff --git a/src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/hwclouds/drs/avro/Record.java b/src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/hwclouds/drs/avro/Record.java new file mode 100644 index 00000000..666f5487 --- /dev/null +++ b/src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/hwclouds/drs/avro/Record.java @@ -0,0 +1,983 @@ +/** + * Autogenerated by Avro + * + * DO NOT EDIT DIRECTLY + */ +package com.huawei.hwclouds.drs.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 = -3713028501727371698L; + public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Record\",\"namespace\":\"com.huawei.hwclouds.drs.avro\",\"fields\":[{\"name\":\"version\",\"type\":\"string\",\"doc\":\"version infomation\"},{\"name\":\"seqno\",\"type\":\"long\",\"doc\":\"seqno\"},{\"name\":\"shardId\",\"type\":\"long\",\"doc\":\"shardId\"},{\"name\":\"eventid\",\"type\":\"string\",\"doc\":\"eventid\"},{\"name\":\"updateTimestamp\",\"type\":\"long\",\"doc\":\"updateTimestamp\"},{\"name\":\"tableName\",\"type\":[\"null\",\"string\"],\"default\":null},{\"name\":\"operation\",\"type\":\"string\",\"doc\":\"INSERT,DELETE,UPDATE,DDL\"},{\"name\":\"columnCount\",\"type\":\"long\",\"doc\":\"field column count\"},{\"name\":\"fields\",\"type\":[\"null\",{\"type\":\"array\",\"items\":{\"type\":\"record\",\"name\":\"Field\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"dataTypeNumber\",\"type\":\"int\",\"doc\":\"2004, BinaryObject\"}]}}],\"default\":null},{\"name\":\"beforeImages\",\"type\":[\"null\",{\"type\":\"array\",\"items\":[\"null\",{\"type\":\"record\",\"name\":\"Integer\",\"fields\":[{\"name\":\"precision\",\"type\":\"int\"},{\"name\":\"value\",\"type\":\"string\"}]},{\"type\":\"record\",\"name\":\"Character\",\"fields\":[{\"name\":\"charset\",\"type\":\"string\"},{\"name\":\"value\",\"type\":\"bytes\"}]},{\"type\":\"record\",\"name\":\"Decimal\",\"fields\":[{\"name\":\"value\",\"type\":\"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\":\"Date\",\"fields\":[{\"name\":\"value\",\"type\":\"string\",\"doc\":\"Field.dataTypeNumber = 94(DateTime) format:YYYY-MM-DD HH:MM:SS\"}]},{\"type\":\"record\",\"name\":\"Bit\",\"fields\":[{\"name\":\"precision\",\"type\":\"int\"},{\"name\":\"value\",\"type\":\"string\"}]},{\"type\":\"record\",\"name\":\"BinaryObject\",\"fields\":[{\"name\":\"type\",\"type\":\"string\"},{\"name\":\"value\",\"type\":\"bytes\"}]}]}],\"default\":null},{\"name\":\"afterImages\",\"type\":[\"null\",{\"type\":\"array\",\"items\":[\"null\",\"Integer\",\"Character\",\"Decimal\",\"Float\",\"Timestamp\",\"Date\",\"Bit\",\"BinaryObject\"]}],\"default\":null}]}"); + public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } + + private static SpecificData MODEL$ = new SpecificData(); + + private static final BinaryMessageEncoder ENCODER = + new BinaryMessageEncoder(MODEL$, SCHEMA$); + + private static final BinaryMessageDecoder DECODER = + new BinaryMessageDecoder(MODEL$, SCHEMA$); + + /** + * Return the BinaryMessageDecoder instance used by this class. + */ + public static BinaryMessageDecoder 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 createDecoder(SchemaStore resolver) { + return new BinaryMessageDecoder(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 java.lang.CharSequence version; + /** seqno */ + @Deprecated public long seqno; + /** shardId */ + @Deprecated public long shardId; + /** eventid */ + @Deprecated public java.lang.CharSequence eventid; + /** updateTimestamp */ + @Deprecated public long updateTimestamp; + @Deprecated public java.lang.CharSequence tableName; + /** INSERT,DELETE,UPDATE,DDL */ + @Deprecated public java.lang.CharSequence operation; + /** field column count */ + @Deprecated public long columnCount; + @Deprecated public java.util.List fields; + @Deprecated public java.util.List beforeImages; + @Deprecated public java.util.List afterImages; + + /** + * Default constructor. Note that this does not initialize fields + * to their default values from the schema. If that is desired then + * one should use newBuilder(). + */ + public Record() {} + + /** + * All-args constructor. + * @param version version infomation + * @param seqno seqno + * @param shardId shardId + * @param eventid eventid + * @param updateTimestamp updateTimestamp + * @param tableName The new value for tableName + * @param operation INSERT,DELETE,UPDATE,DDL + * @param columnCount field column count + * @param fields The new value for fields + * @param beforeImages The new value for beforeImages + * @param afterImages The new value for afterImages + */ + public Record(java.lang.CharSequence version, java.lang.Long seqno, java.lang.Long shardId, java.lang.CharSequence eventid, java.lang.Long updateTimestamp, java.lang.CharSequence tableName, java.lang.CharSequence operation, java.lang.Long columnCount, java.util.List fields, java.util.List beforeImages, java.util.List afterImages) { + this.version = version; + this.seqno = seqno; + this.shardId = shardId; + this.eventid = eventid; + this.updateTimestamp = updateTimestamp; + this.tableName = tableName; + this.operation = operation; + this.columnCount = columnCount; + this.fields = fields; + this.beforeImages = beforeImages; + this.afterImages = afterImages; + } + + 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 seqno; + case 2: return shardId; + case 3: return eventid; + case 4: return updateTimestamp; + case 5: return tableName; + case 6: return operation; + case 7: return columnCount; + case 8: return fields; + case 9: return beforeImages; + case 10: return afterImages; + 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.CharSequence)value$; break; + case 1: seqno = (java.lang.Long)value$; break; + case 2: shardId = (java.lang.Long)value$; break; + case 3: eventid = (java.lang.CharSequence)value$; break; + case 4: updateTimestamp = (java.lang.Long)value$; break; + case 5: tableName = (java.lang.CharSequence)value$; break; + case 6: operation = (java.lang.CharSequence)value$; break; + case 7: columnCount = (java.lang.Long)value$; break; + case 8: fields = (java.util.List)value$; break; + case 9: beforeImages = (java.util.List)value$; break; + case 10: afterImages = (java.util.List)value$; break; + default: throw new org.apache.avro.AvroRuntimeException("Bad index"); + } + } + + /** + * Gets the value of the 'version' field. + * @return version infomation + */ + public java.lang.CharSequence getVersion() { + return version; + } + + /** + * Sets the value of the 'version' field. + * version infomation + * @param value the value to set. + */ + public void setVersion(java.lang.CharSequence value) { + this.version = value; + } + + /** + * Gets the value of the 'seqno' field. + * @return seqno + */ + public java.lang.Long getSeqno() { + return seqno; + } + + /** + * Sets the value of the 'seqno' field. + * seqno + * @param value the value to set. + */ + public void setSeqno(java.lang.Long value) { + this.seqno = value; + } + + /** + * Gets the value of the 'shardId' field. + * @return shardId + */ + public java.lang.Long getShardId() { + return shardId; + } + + /** + * Sets the value of the 'shardId' field. + * shardId + * @param value the value to set. + */ + public void setShardId(java.lang.Long value) { + this.shardId = value; + } + + /** + * Gets the value of the 'eventid' field. + * @return eventid + */ + public java.lang.CharSequence getEventid() { + return eventid; + } + + /** + * Sets the value of the 'eventid' field. + * eventid + * @param value the value to set. + */ + public void setEventid(java.lang.CharSequence value) { + this.eventid = value; + } + + /** + * Gets the value of the 'updateTimestamp' field. + * @return updateTimestamp + */ + public java.lang.Long getUpdateTimestamp() { + return updateTimestamp; + } + + /** + * Sets the value of the 'updateTimestamp' field. + * updateTimestamp + * @param value the value to set. + */ + public void setUpdateTimestamp(java.lang.Long value) { + this.updateTimestamp = value; + } + + /** + * Gets the value of the 'tableName' field. + * @return The value of the 'tableName' field. + */ + public java.lang.CharSequence getTableName() { + return tableName; + } + + /** + * Sets the value of the 'tableName' field. + * @param value the value to set. + */ + public void setTableName(java.lang.CharSequence value) { + this.tableName = value; + } + + /** + * Gets the value of the 'operation' field. + * @return INSERT,DELETE,UPDATE,DDL + */ + public java.lang.CharSequence getOperation() { + return operation; + } + + /** + * Sets the value of the 'operation' field. + * INSERT,DELETE,UPDATE,DDL + * @param value the value to set. + */ + public void setOperation(java.lang.CharSequence value) { + this.operation = value; + } + + /** + * Gets the value of the 'columnCount' field. + * @return field column count + */ + public java.lang.Long getColumnCount() { + return columnCount; + } + + /** + * Sets the value of the 'columnCount' field. + * field column count + * @param value the value to set. + */ + public void setColumnCount(java.lang.Long value) { + this.columnCount = value; + } + + /** + * Gets the value of the 'fields' field. + * @return The value of the 'fields' field. + */ + public java.util.List getFields() { + return fields; + } + + /** + * Sets the value of the 'fields' field. + * @param value the value to set. + */ + public void setFields(java.util.List value) { + this.fields = value; + } + + /** + * Gets the value of the 'beforeImages' field. + * @return The value of the 'beforeImages' field. + */ + public java.util.List getBeforeImages() { + return beforeImages; + } + + /** + * Sets the value of the 'beforeImages' field. + * @param value the value to set. + */ + public void setBeforeImages(java.util.List value) { + this.beforeImages = value; + } + + /** + * Gets the value of the 'afterImages' field. + * @return The value of the 'afterImages' field. + */ + public java.util.List getAfterImages() { + return afterImages; + } + + /** + * Sets the value of the 'afterImages' field. + * @param value the value to set. + */ + public void setAfterImages(java.util.List value) { + this.afterImages = value; + } + + /** + * Creates a new Record RecordBuilder. + * @return A new Record RecordBuilder + */ + public static com.huawei.hwclouds.drs.avro.Record.Builder newBuilder() { + return new com.huawei.hwclouds.drs.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.huawei.hwclouds.drs.avro.Record.Builder newBuilder(com.huawei.hwclouds.drs.avro.Record.Builder other) { + return new com.huawei.hwclouds.drs.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.huawei.hwclouds.drs.avro.Record.Builder newBuilder(com.huawei.hwclouds.drs.avro.Record other) { + return new com.huawei.hwclouds.drs.avro.Record.Builder(other); + } + + /** + * RecordBuilder for Record instances. + */ + public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase + implements org.apache.avro.data.RecordBuilder { + + /** version infomation */ + private java.lang.CharSequence version; + /** seqno */ + private long seqno; + /** shardId */ + private long shardId; + /** eventid */ + private java.lang.CharSequence eventid; + /** updateTimestamp */ + private long updateTimestamp; + private java.lang.CharSequence tableName; + /** INSERT,DELETE,UPDATE,DDL */ + private java.lang.CharSequence operation; + /** field column count */ + private long columnCount; + private java.util.List fields; + private java.util.List beforeImages; + private java.util.List afterImages; + + /** 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.huawei.hwclouds.drs.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.seqno)) { + this.seqno = data().deepCopy(fields()[1].schema(), other.seqno); + fieldSetFlags()[1] = true; + } + if (isValidValue(fields()[2], other.shardId)) { + this.shardId = data().deepCopy(fields()[2].schema(), other.shardId); + fieldSetFlags()[2] = true; + } + if (isValidValue(fields()[3], other.eventid)) { + this.eventid = data().deepCopy(fields()[3].schema(), other.eventid); + fieldSetFlags()[3] = true; + } + if (isValidValue(fields()[4], other.updateTimestamp)) { + this.updateTimestamp = data().deepCopy(fields()[4].schema(), other.updateTimestamp); + fieldSetFlags()[4] = true; + } + if (isValidValue(fields()[5], other.tableName)) { + this.tableName = data().deepCopy(fields()[5].schema(), other.tableName); + fieldSetFlags()[5] = true; + } + if (isValidValue(fields()[6], other.operation)) { + this.operation = data().deepCopy(fields()[6].schema(), other.operation); + fieldSetFlags()[6] = true; + } + if (isValidValue(fields()[7], other.columnCount)) { + this.columnCount = data().deepCopy(fields()[7].schema(), other.columnCount); + fieldSetFlags()[7] = true; + } + if (isValidValue(fields()[8], other.fields)) { + this.fields = data().deepCopy(fields()[8].schema(), other.fields); + fieldSetFlags()[8] = true; + } + if (isValidValue(fields()[9], other.beforeImages)) { + this.beforeImages = data().deepCopy(fields()[9].schema(), other.beforeImages); + fieldSetFlags()[9] = true; + } + if (isValidValue(fields()[10], other.afterImages)) { + this.afterImages = data().deepCopy(fields()[10].schema(), other.afterImages); + fieldSetFlags()[10] = true; + } + } + + /** + * Creates a Builder by copying an existing Record instance + * @param other The existing instance to copy. + */ + private Builder(com.huawei.hwclouds.drs.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.seqno)) { + this.seqno = data().deepCopy(fields()[1].schema(), other.seqno); + fieldSetFlags()[1] = true; + } + if (isValidValue(fields()[2], other.shardId)) { + this.shardId = data().deepCopy(fields()[2].schema(), other.shardId); + fieldSetFlags()[2] = true; + } + if (isValidValue(fields()[3], other.eventid)) { + this.eventid = data().deepCopy(fields()[3].schema(), other.eventid); + fieldSetFlags()[3] = true; + } + if (isValidValue(fields()[4], other.updateTimestamp)) { + this.updateTimestamp = data().deepCopy(fields()[4].schema(), other.updateTimestamp); + fieldSetFlags()[4] = true; + } + if (isValidValue(fields()[5], other.tableName)) { + this.tableName = data().deepCopy(fields()[5].schema(), other.tableName); + fieldSetFlags()[5] = true; + } + if (isValidValue(fields()[6], other.operation)) { + this.operation = data().deepCopy(fields()[6].schema(), other.operation); + fieldSetFlags()[6] = true; + } + if (isValidValue(fields()[7], other.columnCount)) { + this.columnCount = data().deepCopy(fields()[7].schema(), other.columnCount); + fieldSetFlags()[7] = true; + } + if (isValidValue(fields()[8], other.fields)) { + this.fields = data().deepCopy(fields()[8].schema(), other.fields); + fieldSetFlags()[8] = true; + } + if (isValidValue(fields()[9], other.beforeImages)) { + this.beforeImages = data().deepCopy(fields()[9].schema(), other.beforeImages); + fieldSetFlags()[9] = true; + } + if (isValidValue(fields()[10], other.afterImages)) { + this.afterImages = data().deepCopy(fields()[10].schema(), other.afterImages); + fieldSetFlags()[10] = true; + } + } + + /** + * Gets the value of the 'version' field. + * version infomation + * @return The value. + */ + public java.lang.CharSequence getVersion() { + return version; + } + + /** + * Sets the value of the 'version' field. + * version infomation + * @param value The value of 'version'. + * @return This builder. + */ + public com.huawei.hwclouds.drs.avro.Record.Builder setVersion(java.lang.CharSequence 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.huawei.hwclouds.drs.avro.Record.Builder clearVersion() { + version = null; + fieldSetFlags()[0] = false; + return this; + } + + /** + * Gets the value of the 'seqno' field. + * seqno + * @return The value. + */ + public java.lang.Long getSeqno() { + return seqno; + } + + /** + * Sets the value of the 'seqno' field. + * seqno + * @param value The value of 'seqno'. + * @return This builder. + */ + public com.huawei.hwclouds.drs.avro.Record.Builder setSeqno(long value) { + validate(fields()[1], value); + this.seqno = value; + fieldSetFlags()[1] = true; + return this; + } + + /** + * Checks whether the 'seqno' field has been set. + * seqno + * @return True if the 'seqno' field has been set, false otherwise. + */ + public boolean hasSeqno() { + return fieldSetFlags()[1]; + } + + + /** + * Clears the value of the 'seqno' field. + * seqno + * @return This builder. + */ + public com.huawei.hwclouds.drs.avro.Record.Builder clearSeqno() { + fieldSetFlags()[1] = false; + return this; + } + + /** + * Gets the value of the 'shardId' field. + * shardId + * @return The value. + */ + public java.lang.Long getShardId() { + return shardId; + } + + /** + * Sets the value of the 'shardId' field. + * shardId + * @param value The value of 'shardId'. + * @return This builder. + */ + public com.huawei.hwclouds.drs.avro.Record.Builder setShardId(long value) { + validate(fields()[2], value); + this.shardId = value; + fieldSetFlags()[2] = true; + return this; + } + + /** + * Checks whether the 'shardId' field has been set. + * shardId + * @return True if the 'shardId' field has been set, false otherwise. + */ + public boolean hasShardId() { + return fieldSetFlags()[2]; + } + + + /** + * Clears the value of the 'shardId' field. + * shardId + * @return This builder. + */ + public com.huawei.hwclouds.drs.avro.Record.Builder clearShardId() { + fieldSetFlags()[2] = false; + return this; + } + + /** + * Gets the value of the 'eventid' field. + * eventid + * @return The value. + */ + public java.lang.CharSequence getEventid() { + return eventid; + } + + /** + * Sets the value of the 'eventid' field. + * eventid + * @param value The value of 'eventid'. + * @return This builder. + */ + public com.huawei.hwclouds.drs.avro.Record.Builder setEventid(java.lang.CharSequence value) { + validate(fields()[3], value); + this.eventid = value; + fieldSetFlags()[3] = true; + return this; + } + + /** + * Checks whether the 'eventid' field has been set. + * eventid + * @return True if the 'eventid' field has been set, false otherwise. + */ + public boolean hasEventid() { + return fieldSetFlags()[3]; + } + + + /** + * Clears the value of the 'eventid' field. + * eventid + * @return This builder. + */ + public com.huawei.hwclouds.drs.avro.Record.Builder clearEventid() { + eventid = null; + fieldSetFlags()[3] = false; + return this; + } + + /** + * Gets the value of the 'updateTimestamp' field. + * updateTimestamp + * @return The value. + */ + public java.lang.Long getUpdateTimestamp() { + return updateTimestamp; + } + + /** + * Sets the value of the 'updateTimestamp' field. + * updateTimestamp + * @param value The value of 'updateTimestamp'. + * @return This builder. + */ + public com.huawei.hwclouds.drs.avro.Record.Builder setUpdateTimestamp(long value) { + validate(fields()[4], value); + this.updateTimestamp = value; + fieldSetFlags()[4] = true; + return this; + } + + /** + * Checks whether the 'updateTimestamp' field has been set. + * updateTimestamp + * @return True if the 'updateTimestamp' field has been set, false otherwise. + */ + public boolean hasUpdateTimestamp() { + return fieldSetFlags()[4]; + } + + + /** + * Clears the value of the 'updateTimestamp' field. + * updateTimestamp + * @return This builder. + */ + public com.huawei.hwclouds.drs.avro.Record.Builder clearUpdateTimestamp() { + fieldSetFlags()[4] = false; + return this; + } + + /** + * Gets the value of the 'tableName' field. + * @return The value. + */ + public java.lang.CharSequence getTableName() { + return tableName; + } + + /** + * Sets the value of the 'tableName' field. + * @param value The value of 'tableName'. + * @return This builder. + */ + public com.huawei.hwclouds.drs.avro.Record.Builder setTableName(java.lang.CharSequence value) { + validate(fields()[5], value); + this.tableName = value; + fieldSetFlags()[5] = true; + return this; + } + + /** + * Checks whether the 'tableName' field has been set. + * @return True if the 'tableName' field has been set, false otherwise. + */ + public boolean hasTableName() { + return fieldSetFlags()[5]; + } + + + /** + * Clears the value of the 'tableName' field. + * @return This builder. + */ + public com.huawei.hwclouds.drs.avro.Record.Builder clearTableName() { + tableName = null; + fieldSetFlags()[5] = false; + return this; + } + + /** + * Gets the value of the 'operation' field. + * INSERT,DELETE,UPDATE,DDL + * @return The value. + */ + public java.lang.CharSequence getOperation() { + return operation; + } + + /** + * Sets the value of the 'operation' field. + * INSERT,DELETE,UPDATE,DDL + * @param value The value of 'operation'. + * @return This builder. + */ + public com.huawei.hwclouds.drs.avro.Record.Builder setOperation(java.lang.CharSequence value) { + validate(fields()[6], value); + this.operation = value; + fieldSetFlags()[6] = true; + return this; + } + + /** + * Checks whether the 'operation' field has been set. + * INSERT,DELETE,UPDATE,DDL + * @return True if the 'operation' field has been set, false otherwise. + */ + public boolean hasOperation() { + return fieldSetFlags()[6]; + } + + + /** + * Clears the value of the 'operation' field. + * INSERT,DELETE,UPDATE,DDL + * @return This builder. + */ + public com.huawei.hwclouds.drs.avro.Record.Builder clearOperation() { + operation = null; + fieldSetFlags()[6] = false; + return this; + } + + /** + * Gets the value of the 'columnCount' field. + * field column count + * @return The value. + */ + public java.lang.Long getColumnCount() { + return columnCount; + } + + /** + * Sets the value of the 'columnCount' field. + * field column count + * @param value The value of 'columnCount'. + * @return This builder. + */ + public com.huawei.hwclouds.drs.avro.Record.Builder setColumnCount(long value) { + validate(fields()[7], value); + this.columnCount = value; + fieldSetFlags()[7] = true; + return this; + } + + /** + * Checks whether the 'columnCount' field has been set. + * field column count + * @return True if the 'columnCount' field has been set, false otherwise. + */ + public boolean hasColumnCount() { + return fieldSetFlags()[7]; + } + + + /** + * Clears the value of the 'columnCount' field. + * field column count + * @return This builder. + */ + public com.huawei.hwclouds.drs.avro.Record.Builder clearColumnCount() { + fieldSetFlags()[7] = false; + return this; + } + + /** + * Gets the value of the 'fields' field. + * @return The value. + */ + public java.util.List getFields() { + return fields; + } + + /** + * Sets the value of the 'fields' field. + * @param value The value of 'fields'. + * @return This builder. + */ + public com.huawei.hwclouds.drs.avro.Record.Builder setFields(java.util.List value) { + validate(fields()[8], value); + this.fields = value; + fieldSetFlags()[8] = 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()[8]; + } + + + /** + * Clears the value of the 'fields' field. + * @return This builder. + */ + public com.huawei.hwclouds.drs.avro.Record.Builder clearFields() { + fields = null; + fieldSetFlags()[8] = false; + return this; + } + + /** + * Gets the value of the 'beforeImages' field. + * @return The value. + */ + public java.util.List getBeforeImages() { + return beforeImages; + } + + /** + * Sets the value of the 'beforeImages' field. + * @param value The value of 'beforeImages'. + * @return This builder. + */ + public com.huawei.hwclouds.drs.avro.Record.Builder setBeforeImages(java.util.List value) { + validate(fields()[9], value); + this.beforeImages = value; + fieldSetFlags()[9] = 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()[9]; + } + + + /** + * Clears the value of the 'beforeImages' field. + * @return This builder. + */ + public com.huawei.hwclouds.drs.avro.Record.Builder clearBeforeImages() { + beforeImages = null; + fieldSetFlags()[9] = false; + return this; + } + + /** + * Gets the value of the 'afterImages' field. + * @return The value. + */ + public java.util.List getAfterImages() { + return afterImages; + } + + /** + * Sets the value of the 'afterImages' field. + * @param value The value of 'afterImages'. + * @return This builder. + */ + public com.huawei.hwclouds.drs.avro.Record.Builder setAfterImages(java.util.List value) { + validate(fields()[10], value); + this.afterImages = value; + fieldSetFlags()[10] = 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()[10]; + } + + + /** + * Clears the value of the 'afterImages' field. + * @return This builder. + */ + public com.huawei.hwclouds.drs.avro.Record.Builder clearAfterImages() { + afterImages = null; + fieldSetFlags()[10] = false; + return this; + } + + @Override + @SuppressWarnings("unchecked") + public Record build() { + try { + Record record = new Record(); + record.version = fieldSetFlags()[0] ? this.version : (java.lang.CharSequence) defaultValue(fields()[0]); + record.seqno = fieldSetFlags()[1] ? this.seqno : (java.lang.Long) defaultValue(fields()[1]); + record.shardId = fieldSetFlags()[2] ? this.shardId : (java.lang.Long) defaultValue(fields()[2]); + record.eventid = fieldSetFlags()[3] ? this.eventid : (java.lang.CharSequence) defaultValue(fields()[3]); + record.updateTimestamp = fieldSetFlags()[4] ? this.updateTimestamp : (java.lang.Long) defaultValue(fields()[4]); + record.tableName = fieldSetFlags()[5] ? this.tableName : (java.lang.CharSequence) defaultValue(fields()[5]); + record.operation = fieldSetFlags()[6] ? this.operation : (java.lang.CharSequence) defaultValue(fields()[6]); + record.columnCount = fieldSetFlags()[7] ? this.columnCount : (java.lang.Long) defaultValue(fields()[7]); + record.fields = fieldSetFlags()[8] ? this.fields : (java.util.List) defaultValue(fields()[8]); + record.beforeImages = fieldSetFlags()[9] ? this.beforeImages : (java.util.List) defaultValue(fields()[9]); + record.afterImages = fieldSetFlags()[10] ? this.afterImages : (java.util.List) defaultValue(fields()[10]); + return record; + } catch (java.lang.Exception e) { + throw new org.apache.avro.AvroRuntimeException(e); + } + } + } + + @SuppressWarnings("unchecked") + private static final org.apache.avro.io.DatumWriter + WRITER$ = (org.apache.avro.io.DatumWriter)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 + READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); + + @Override public void readExternal(java.io.ObjectInput in) + throws java.io.IOException { + READER$.read(this, SpecificData.getDecoder(in)); + } + +} diff --git a/src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/hwclouds/drs/avro/Timestamp.java b/src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/hwclouds/drs/avro/Timestamp.java new file mode 100644 index 00000000..8ca1f47b --- /dev/null +++ b/src/flink-examples/flink-examples-security/flink-parse-avro/src/main/java/com/huawei/hwclouds/drs/avro/Timestamp.java @@ -0,0 +1,306 @@ +/** + * Autogenerated by Avro + * + * DO NOT EDIT DIRECTLY + */ +package com.huawei.hwclouds.drs.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 = 4308662166148827007L; + public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Timestamp\",\"namespace\":\"com.huawei.hwclouds.drs.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 ENCODER = + new BinaryMessageEncoder(MODEL$, SCHEMA$); + + private static final BinaryMessageDecoder DECODER = + new BinaryMessageDecoder(MODEL$, SCHEMA$); + + /** + * Return the BinaryMessageDecoder instance used by this class. + */ + public static BinaryMessageDecoder 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 createDecoder(SchemaStore resolver) { + return new BinaryMessageDecoder(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 newBuilder(). + */ + 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.huawei.hwclouds.drs.avro.Timestamp.Builder newBuilder() { + return new com.huawei.hwclouds.drs.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.huawei.hwclouds.drs.avro.Timestamp.Builder newBuilder(com.huawei.hwclouds.drs.avro.Timestamp.Builder other) { + return new com.huawei.hwclouds.drs.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.huawei.hwclouds.drs.avro.Timestamp.Builder newBuilder(com.huawei.hwclouds.drs.avro.Timestamp other) { + return new com.huawei.hwclouds.drs.avro.Timestamp.Builder(other); + } + + /** + * RecordBuilder for Timestamp instances. + */ + public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase + implements org.apache.avro.data.RecordBuilder { + + 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.huawei.hwclouds.drs.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.huawei.hwclouds.drs.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.huawei.hwclouds.drs.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.huawei.hwclouds.drs.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.huawei.hwclouds.drs.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.huawei.hwclouds.drs.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 + WRITER$ = (org.apache.avro.io.DatumWriter)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 + READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); + + @Override public void readExternal(java.io.ObjectInput in) + throws java.io.IOException { + READER$.read(this, SpecificData.getDecoder(in)); + } + +}