Search before asking
Paimon version
master, 9c7deebbd (2.1-SNAPSHOT)
Compute Engine
Java API. DataOutputSerializer implements DataOutputView, which extends java.io.DataOutput.
Minimal reproduce step
writeBytes(String) writes each byte through writeByte, which goes to write(int):
public void write(int b) throws IOException {
if (this.position >= this.buffer.length) {
resize(1);
}
this.buffer[this.position++] = (byte) (b & 0xff);
}
so the position is already advanced per byte. The method then advanced it again by the string length:
for (int i = 0; i < sLen; i++) {
writeByte(s.charAt(i));
}
this.position += sLen;
DataOutputSerializer out = new DataOutputSerializer(16);
out.writeBytes("abc");
out.length(); // 6, should be 3
out.writeInt(42);
out.length(); // 10, and bytes 3..5 were never written
What doesn't meet your expectations?
After writeBytes, length() reports twice the bytes written and every later write lands past a gap of untouched buffer, so the serialized output is longer than the data and carries whatever was in the array. The sibling writeChars(String) has the same shape, a resize followed by a loop of writeChar, and never had the extra advance, which is the intended form.
Nothing in the repository calls this overload, so no Paimon code path is affected today. It is reachable for anyone holding a DataOutputView or DataOutput, which is the contract the class implements.
Anything else?
I audited the rest of the class: write(byte[], int, int), write(MemorySegment, int, int), writeChar, writeShort, writeInt, writeLong, writeUTF, skipBytesToWrite and write(DataInputView, int) all advance the position by exactly the bytes they wrote. writeBytes is the only one that does not.
Are you willing to submit a PR?
Search before asking
Paimon version
master,
9c7deebbd(2.1-SNAPSHOT)Compute Engine
Java API.
DataOutputSerializerimplementsDataOutputView, which extendsjava.io.DataOutput.Minimal reproduce step
writeBytes(String)writes each byte throughwriteByte, which goes towrite(int):so the position is already advanced per byte. The method then advanced it again by the string length:
What doesn't meet your expectations?
After
writeBytes,length()reports twice the bytes written and every later write lands past a gap of untouched buffer, so the serialized output is longer than the data and carries whatever was in the array. The siblingwriteChars(String)has the same shape, aresizefollowed by a loop ofwriteChar, and never had the extra advance, which is the intended form.Nothing in the repository calls this overload, so no Paimon code path is affected today. It is reachable for anyone holding a
DataOutputVieworDataOutput, which is the contract the class implements.Anything else?
I audited the rest of the class:
write(byte[], int, int),write(MemorySegment, int, int),writeChar,writeShort,writeInt,writeLong,writeUTF,skipBytesToWriteandwrite(DataInputView, int)all advance the position by exactly the bytes they wrote.writeBytesis the only one that does not.Are you willing to submit a PR?