Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Co-authored-by: zuochunwei <[email protected]>
  • Loading branch information
zuochunwei and zuochunwei authored Jun 19, 2023
1 parent 76ec50b commit 48ea6d4
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions velox/vector/arrow/Bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,7 @@ VectorPtr importFromArrowImpl(
memory::MemoryPool* pool,
bool isViewer);

template <typename T>
VectorPtr createDecimalVector(
memory::MemoryPool* pool,
const TypePtr& type,
Expand All @@ -1003,14 +1004,13 @@ VectorPtr createDecimalVector(
VectorPtr base = BaseVector::create(type, arrowArray.length, pool);
base->setNulls(nulls);

auto flatVector =
std::dynamic_pointer_cast<FlatVector<UnscaledShortDecimal>>(base);
auto flatVector = std::dynamic_pointer_cast<FlatVector<T>>(base);

for (int i = 0; i < arrowArray.length; i++) {
if (!base->isNullAt(i)) {
int128_t result;
memcpy(&result, src + i * sizeof(int128_t), sizeof(int128_t));
flatVector->set(i, UnscaledShortDecimal(static_cast<int64_t>(result)));
flatVector->set(i, T(result));
}
}

Expand Down Expand Up @@ -1226,30 +1226,27 @@ VectorPtr importFromArrowImpl(
static_cast<const char*>(arrowArray.buffers[2]), // values
arrowArray.null_count,
wrapInBufferView);
}
// Row/structs.
if (type->isRow()) {
} else if (type->isRow()) { // Row/structs.
return createRowVector(
pool,
std::dynamic_pointer_cast<const RowType>(type),
nulls,
arrowSchema,
arrowArray,
isViewer);
}
if (type->isArray()) {
} else if (type->isArray()) {
return createArrayVector(
pool, type, nulls, arrowSchema, arrowArray, isViewer, wrapInBufferView);
}
if (type->isMap()) {
} else if (type->isMap()) {
return createMapVector(
pool, type, nulls, arrowSchema, arrowArray, isViewer, wrapInBufferView);
}
if (type->isShortDecimal()) {
return createDecimalVector(
} else if (type->isShortDecimal()) {
return createDecimalVector<UnscaledShortDecimal>(
pool, type, nulls, arrowSchema, arrowArray, wrapInBufferView);
}
if (type->kind() == TypeKind::TIMESTAMP) {
} else if (type->isLongDecimal()) {
return createDecimalVector<UnscaledLongDecimal>(
pool, type, nulls, arrowSchema, arrowArray, wrapInBufferView);
} else if (type->kind() == TypeKind::TIMESTAMP) {
return createTimestampVector(
pool, type, nulls, arrowSchema, arrowArray, wrapInBufferView);
}
Expand Down

0 comments on commit 48ea6d4

Please sign in to comment.