apache / apache/arrow-java

DenseUnionVector is not transferred correctly

Đang mở
#200 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Type: bug
Ngôn ngữ chính
Java
Star
94
Fork
152
Merge trung bình
3 ngày 16 giờ
Pull request đã merge (30 ngày)
11

Mô tả

### Describe the bug, including details regarding any error messages, version, and platform.

Hello,

I encountered a weird issue when converting a `Table` to a `VectorSchemaRoot`. All the `DenseUnionVector` were empty after the conversion.
From my understanding, it looks like there is a bug in the `TransferImpl.transfer` method of the `DenseUnionVector`.
After copying the `valueCount` value to the second vector [in this line](https://github.com/apache/arrow/blob/45918a90a6ca1cf3fd67c256a7d6a240249e555a/java/vector/src/main/codegen/templates/DenseUnionVector.java#L634), it should also set the `nextTypeId`.
After the transfer, `nextTypeId` is equals to `0`, so trying to transfer again would create an empty vector as [the for loop is done against the `nextTypeId`](https://github.com/apache/arrow/blob/45918a90a6ca1cf3fd67c256a7d6a240249e555a/java/vector/src/main/codegen/templates/DenseUnionVector.java#L628)

Proposed fix would be as simple as :

```java
@Override
public void transfer() {

...

for (int i = 0; i < nextTypeId; i++) {
if (internalTransferPairs[i] != null) {
internalTransferPairs[i].transfer();
to.childVectors[i] = internalTransferPairs[i].getTo();
}
}
to.valueCount = valueCount;
to.nextTypeId = nextTypeId;
clear();
}
```

I will raise a PR with the change.

### Component(s)

Java

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu trong java/vector/src/main/codegen/templates/DenseUnionVector.java, đặc biệt là TransferImpl.transfer và vòng lặp sử dụng nextTypeId. Tái hiện quá trình chuyển đổi từ Table sang VectorSchemaRoot và xác minh rằng một DenseUnionVector đã được chuyển vẫn giữ nguyên số lượng giá trị và trạng thái kiểu của nó, để một lần chuyển tiếp theo không bị rỗng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
java
Lĩnh vực
data
Loại issue
Lỗi
Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
50/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.