Skip to content

Commit

Permalink
Fix a bug in TableBuilder.
Browse files Browse the repository at this point in the history
Signed-off-by: Liangcai Li <[email protected]>
  • Loading branch information
firestarman committed Jan 18, 2021
1 parent 58c07f0 commit 3095ce0
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions java/src/main/java/ai/rapids/cudf/Table.java
Original file line number Diff line number Diff line change
Expand Up @@ -2690,11 +2690,15 @@ private static ColumnVector from(DType type, Object dataArray) {
}

@SuppressWarnings("unchecked")
private static <T> ColumnVector fromLists(DataType dataType, Object[][] dataArray) {
private static <T> ColumnVector fromLists(DataType dataType, Object[] dataArray) {
List[] dataLists = new List[dataArray.length];
for (int i = 0; i < dataLists.length; ++i) {
Object[] dataList = dataArray[i];
dataLists[i] = dataList != null ? Arrays.asList(dataList) : null;
// The element in dataArray can be an array or list, because the below overloaded
// version accepts a List of Array as rows.
// `public TestBuilder column(ListType dataType, List<?>... values)`
Object dataList = dataArray[i];
dataLists[i] = dataList == null ? null :
(dataList instanceof List ? (List)dataList : Arrays.asList((Object[])dataList));
}
return ColumnVector.fromLists(dataType, dataLists);
}
Expand All @@ -2712,7 +2716,7 @@ public Table build() {
Object dataArray = typeErasedData.get(i);
if (dtype.isNestedType()) {
if (dtype.equals(DType.LIST)) {
columns.add(fromLists(dataType, (Object[][]) dataArray));
columns.add(fromLists(dataType, (Object[]) dataArray));
} else if (dtype.equals(DType.STRUCT)) {
columns.add(fromStructs(dataType, (StructData[]) dataArray));
} else {
Expand Down

0 comments on commit 3095ce0

Please sign in to comment.