apache / apache/arrow-java

[Java] Should ListVector.reset() reset the position(index)?

未關閉
#205 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
Type: bug
主要語言
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

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。