shardulm94 commented on a change in pull request #625: Support reading Avro
enums as strings
URL: https://github.com/apache/incubator-iceberg/pull/625#discussion_r344417359
##########
File path:
spark/src/main/java/org/apache/iceberg/spark/data/SparkValueReaders.java
##########
@@ -96,6 +101,24 @@ public UTF8String read(Decoder decoder, Object reuse)
throws IOException {
}
}
+ private static class EnumReader implements ValueReader<UTF8String> {
+ private final byte[][] symbols;
+
+ private EnumReader(List<String> symbols) {
+ this.symbols = new byte[symbols.size()][];
+ for (int i = 0; i < this.symbols.length; i += 1) {
+ this.symbols[i] = symbols.get(i).getBytes(StandardCharsets.UTF_8);
+ }
+ }
+
+ @Override
+ public UTF8String read(Decoder decoder, Object ignore) throws IOException {
+ int index = decoder.readEnum();
+ return UTF8String.fromBytes(symbols[index], 0, symbols[index].length);
Review comment:
I don't know why I did this. Maybe I just overlooked this part. Fixed
----------------------------------------------------------------
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]