Skip to content

Commit 9fdf72e

Browse files
committed
Update DeltaByteArrayWriter.java
1 parent 60fe238 commit 9fdf72e

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

parquet-column/src/main/java/org/apache/parquet/column/values/deltastrings/DeltaByteArrayWriter.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public String memUsageString(String prefix) {
8989

9090
@Override
9191
public void writeBytes(Binary v) {
92-
byte[] vb = v.getBytesUnsafe();
92+
byte[] vb = v.isBackingBytesReused() ? v.getBytes() : v.getBytesUnsafe();
9393
int length = Math.min(previous.length, vb.length);
9494
// Find the number of matching prefix bytes between this value and the previous one.
9595
// Arrays.mismatch is intrinsified by the JVM to use SIMD instructions.
@@ -99,9 +99,6 @@ public void writeBytes(Binary v) {
9999
}
100100
prefixLengthWriter.writeInteger(i);
101101
suffixWriter.writeBytes(v.slice(i, vb.length - i));
102-
// Retain an owned copy for prefix comparison with the next value.
103-
// getBytesUnsafe() may return the backing array directly, so we must copy
104-
// if the Binary's backing bytes may be reused by the caller.
105-
previous = v.isBackingBytesReused() ? v.getBytes() : vb;
102+
previous = vb;
106103
}
107104
}

0 commit comments

Comments
 (0)