DenseUnionVector is not transferred correctly
- Vorherrschende Sprache
- Java
- Sterne
- 94
- Forks
- 152
- Ø Merge
- 3 T. 16 Std.
- Gemergte PRs (30 T.)
- 11
Beschreibung
### 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
Beitragsleitfaden
Rechercherichtung
Beginnen Sie in java/vector/src/main/codegen/templates/DenseUnionVector.java, insbesondere bei TransferImpl.transfer und der Schleife, die nextTypeId verwendet. Reproduzieren Sie die Konvertierung von Table zu VectorSchemaRoot und überprüfen Sie, dass ein übertragenes DenseUnionVector seine Wertanzahl und seinen Typzustand beibehält, sodass eine nachfolgende Übertragung nicht leer ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- java
- Bereich
- data
- Issue-Typ
- Bug
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 50/100