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 位置实现,然后确定重置后的预期结果,并为所演示的序列添加覆盖,以明确该行为。

由索引模型根据 Issue 内容生成。

评估

技术栈
java
领域
data
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。