davidov541 commented on a change in pull request #933: HIVE-21218: Adding
support for Confluent Kafka Avro message format
URL: https://github.com/apache/hive/pull/933#discussion_r388037768
##########
File path: kafka-handler/src/java/org/apache/hadoop/hive/kafka/KafkaSerDe.java
##########
@@ -369,6 +402,26 @@ private SubStructObjectInspector(StructObjectInspector
baseOI, int toIndex) {
}
}
+ /**
+ * The converter reads bytes from kafka message and skip first @skipBytes
from beginning.
+ *
+ * For example:
+ * The Confluent Avro serializer adds 5 magic bytes that represents
Schema ID as Integer to the message.
+ */
+ static class AvroSkipBytesConverter extends AvroBytesConverter {
+ private final int skipBytes;
+
+ AvroSkipBytesConverter(Schema schema, int skipBytes) {
+ super(schema);
+ this.skipBytes = skipBytes;
+ }
+
+ @Override
+ Decoder getDecoder(byte[] value) {
+ return DecoderFactory.get().binaryDecoder(value, this.skipBytes,
value.length - this.skipBytes, null);
Review comment:
BinaryDecoder already throws a nice ArrayIndexOutOfBoundsException in this
case, so I'm going to update to catch that, wrap in a SerDe exception, and keep
going.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]