Skip to content

Commit 651ff81

Browse files
zuochunweizuochunwei
authored andcommitted
ld (#317)
Co-authored-by: zuochunwei <zuochunwei@meituan.com>
1 parent c860dfa commit 651ff81

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

velox/vector/arrow/Bridge.cpp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,7 @@ VectorPtr importFromArrowImpl(
985985
memory::MemoryPool* pool,
986986
bool isViewer);
987987

988+
template <typename T>
988989
VectorPtr createDecimalVector(
989990
memory::MemoryPool* pool,
990991
const TypePtr& type,
@@ -1000,13 +1001,13 @@ VectorPtr createDecimalVector(
10001001
VectorPtr base = BaseVector::create(type, arrowArray.length, pool);
10011002
base->setNulls(nulls);
10021003

1003-
auto flatVector = std::dynamic_pointer_cast<FlatVector<int64_t>>(base);
1004+
auto flatVector = std::dynamic_pointer_cast<FlatVector<T>>(base);
10041005

10051006
for (int i = 0; i < arrowArray.length; i++) {
10061007
if (!base->isNullAt(i)) {
10071008
int128_t result;
10081009
memcpy(&result, src + i * sizeof(int128_t), sizeof(int128_t));
1009-
flatVector->set(i, static_cast<int64_t>(result));
1010+
flatVector->set(i, T(result));
10101011
}
10111012
}
10121013

@@ -1222,30 +1223,27 @@ VectorPtr importFromArrowImpl(
12221223
static_cast<const char*>(arrowArray.buffers[2]), // values
12231224
arrowArray.null_count,
12241225
wrapInBufferView);
1225-
}
1226-
// Row/structs.
1227-
if (type->isRow()) {
1226+
} else if (type->isRow()) { // Row/structs.
12281227
return createRowVector(
12291228
pool,
12301229
std::dynamic_pointer_cast<const RowType>(type),
12311230
nulls,
12321231
arrowSchema,
12331232
arrowArray,
12341233
isViewer);
1235-
}
1236-
if (type->isArray()) {
1234+
} else if (type->isArray()) {
12371235
return createArrayVector(
12381236
pool, type, nulls, arrowSchema, arrowArray, isViewer, wrapInBufferView);
1239-
}
1240-
if (type->isMap()) {
1237+
} else if (type->isMap()) {
12411238
return createMapVector(
12421239
pool, type, nulls, arrowSchema, arrowArray, isViewer, wrapInBufferView);
1243-
}
1244-
if (type->isShortDecimal()) {
1245-
return createDecimalVector(
1240+
} else if (type->isShortDecimal()) {
1241+
return createDecimalVector<int64_t>(
12461242
pool, type, nulls, arrowSchema, arrowArray, wrapInBufferView);
1247-
}
1248-
if (type->kind() == TypeKind::TIMESTAMP) {
1243+
} else if (type->isLongDecimal()) {
1244+
return createDecimalVector<int128_t>(
1245+
pool, type, nulls, arrowSchema, arrowArray, wrapInBufferView);
1246+
} else if (type->kind() == TypeKind::TIMESTAMP) {
12491247
return createTimestampVector(
12501248
pool, type, nulls, arrowSchema, arrowArray, wrapInBufferView);
12511249
}

0 commit comments

Comments
 (0)