[Java] Should ListVector.reset() reset the position(index)?
- 主要語言
- Java
- 星號
- 94
- 分支
- 152
- 平均合併
- 3 天 16 小時
- 30 天內合併 PR
- 11
描述
```java
RootAllocator rootAllocator = new RootAllocator();
ListVector identity = ListVector.empty("identity", rootAllocator);
VectorSchemaRoot root = new VectorSchemaRoot(List.of(identity));
root.allocateNew();
UnionListWriter writer = identity.getWriter();
byte[] bytes1 = "hello1".getBytes(StandardCharsets.UTF_8);
ArrowBuf buffer = rootAllocator.buffer(bytes1.length);
buffer.setBytes(0,bytes1);
writer.startList();
writer.varChar().writeVarChar(0,bytes1.length,buffer);
writer.endList();
root.setRowCount(1);
System.out.println(root.contentToTSVString());
root.getFieldVectors().forEach(ValueVector::reset); //reset fieldVector
byte[] bytes2 = "hello2".getBytes(StandardCharsets.UTF_8);
buffer.setBytes(0,bytes2);
writer.startList();
writer.varChar().writeVarChar(0,bytes2.length,buffer);
writer.endList();
root.setRowCount(1);
System.out.println(root.contentToTSVString());
```
the result is
```
identity
["hello1"]
identity
null
```
The above results are confusing。
The correct way is using the `writer.setPosition(index)`,
I don't know if it's a bug or other something.
### Component(s)
Java
貢獻指南
研究方向
先使用 ListVector、ValueVector.reset() 和 UnionListWriter.setPosition(index) 執行 Java 重現,以觀察位置行為。閱讀相關的 reset 和 writer 位置實作,接著確立重設後的預期結果,並為示範的序列新增 coverage,讓行為不再模稜兩可。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- java
- 領域
- data
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100