Skip to content

Commit

Permalink
fix: Use input directly in createLongDecimalVector if aligned (facebo…
Browse files Browse the repository at this point in the history
…okincubator#11648)

Summary:
In 'createLongDecimalVector', uses the input directly if it is already 16-byte
aligned.
Follow-up for: facebookincubator#11404.

Pull Request resolved: facebookincubator#11648

Reviewed By: amitkdutta, gggrace14

Differential Revision: D66690732

Pulled By: xiaoxmeng

fbshipit-source-id: 6ce325a81a885c3c3dc70e32ad004a37610d6940
  • Loading branch information
rui-mo authored and facebook-github-bot committed Dec 3, 2024
1 parent db0c3e6 commit 46fd360
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions velox/vector/arrow/Bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1875,7 +1875,19 @@ VectorPtr createLongDecimalVector(
BufferPtr nulls,
const int128_t* input,
size_t length,
int64_t nullCount) {
int64_t nullCount,
WrapInBufferViewFunc wrapInBufferView) {
if ((reinterpret_cast<uintptr_t>(input) & 0xf) == 0) {
// If the input is already 16-byte aligned, copy is not needed.
return createFlatVector<TypeKind::HUGEINT>(
pool,
type,
nulls,
length,
wrapInBufferView(input, length * type->cppSizeInBytes()),
nullCount);
}

auto values = AlignedBuffer::allocate<int128_t>(length, pool);
auto rawValues = values->asMutable<int128_t>();
memcpy(rawValues, input, length * sizeof(int128_t));
Expand Down Expand Up @@ -1985,7 +1997,8 @@ VectorPtr importFromArrowImpl(
nulls,
static_cast<const int128_t*>(arrowArray.buffers[1]),
arrowArray.length,
arrowArray.null_count);
arrowArray.null_count,
wrapInBufferView);
} else if (type->isRow()) {
// Row/structs.
return createRowVector(
Expand Down

0 comments on commit 46fd360

Please sign in to comment.