Skip to content

Commit

Permalink
[FLINK-36084] Optimize parquet binary getBytes with getBytesUnsafe to…
Browse files Browse the repository at this point in the history
… avoid copy cost (apache#25213)
  • Loading branch information
xuzifu666 authored Aug 19, 2024
1 parent 5f6200c commit adb8368
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public double decodeToDouble(int id) {

@Override
public byte[] decodeToBinary(int id) {
return dictionary.decodeToBinary(id).getBytes();
return dictionary.decodeToBinary(id).getBytesUnsafe();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected void readBatchFromDictionaryIds(
int rowId, int num, WritableBytesVector column, WritableIntVector dictionaryIds) {
for (int i = rowId; i < rowId + num; ++i) {
if (!column.isNullAt(i)) {
byte[] bytes = dictionary.decodeToBinary(dictionaryIds.getInt(i)).getBytes();
byte[] bytes = dictionary.decodeToBinary(dictionaryIds.getInt(i)).getBytesUnsafe();
column.appendBytes(i, bytes, 0, bytes.length);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ protected void readBatchFromDictionaryIds(
WritableBytesVector bytesVector = (WritableBytesVector) column;
for (int i = rowId; i < rowId + num; ++i) {
if (!bytesVector.isNullAt(i)) {
byte[] v = dictionary.decodeToBinary(dictionaryIds.getInt(i)).getBytes();
byte[] v = dictionary.decodeToBinary(dictionaryIds.getInt(i)).getBytesUnsafe();
bytesVector.appendBytes(i, v, 0, v.length);
}
}
Expand Down

0 comments on commit adb8368

Please sign in to comment.