rdblue commented on a change in pull request #1334:
URL: https://github.com/apache/iceberg/pull/1334#discussion_r473126801
##########
File path: pig/src/main/java/org/apache/iceberg/pig/IcebergPigInputFormat.java
##########
@@ -245,8 +245,14 @@ private boolean advance() throws IOException {
private Object convertPartitionValue(Type type, Object value) {
if (type.typeId() == Types.BinaryType.get().typeId()) {
- ByteBuffer buffer = (ByteBuffer) value;
- return new DataByteArray(buffer.get(new
byte[buffer.remaining()]).array());
+ ByteBuffer dupe = ((ByteBuffer) value).duplicate();
+ if (dupe.hasArray()) {
+ return new DataByteArray(dupe.array());
Review comment:
I don't think that we need to check `hasArray` here. I think the reason
why this didn't previously check `hasArray` is that the array passed to
`DataByteArray` must start at offset 0 and be valid through the array length,
so a copy was needed in almost every case.
It may be simpler to change this to use `ByteBuffers.toByteArray` and pass
the result to create `DataByteArray`.
----------------------------------------------------------------
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]