Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Co-authored-by: zuochunwei <zuochunwei@meituan.com>
  • Loading branch information
2 people authored and zhejiangxiaomai committed Jul 4, 2023
1 parent 1897e93 commit 91cbac2
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions velox/vector/arrow/Bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,7 @@ VectorPtr importFromArrowImpl(
memory::MemoryPool* pool,
bool isViewer);

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

auto flatVector = std::dynamic_pointer_cast<FlatVector<int64_t>>(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, static_cast<int64_t>(result));
flatVector->set(i, T(result));
}
}

Expand Down Expand Up @@ -1222,30 +1223,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<int64_t>(
pool, type, nulls, arrowSchema, arrowArray, wrapInBufferView);
}
if (type->kind() == TypeKind::TIMESTAMP) {
} else if (type->isLongDecimal()) {
return createDecimalVector<int128_t>(
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 91cbac2

Please sign in to comment.