apache / apache/arrow-java

[Java] MapVector written data does not meet expectations

未关闭
#40 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
Component: Documentation
主要语言
Java
星标
94
派生
152
平均合并
3 天 16 小时
30 天内合并 PR
11

描述

### What would you like help with?

```
RootAllocator allocator = new RootAllocator(Long.MAX_VALUE);
Map metadata = new HashMap<>();
metadata.put("K1", "V1");
metadata.put("K2", "V2");
Field a = new Field("key", FieldType.notNullable(new ArrowType.Int(32, true)), null);
Field b = new Field("value", FieldType.nullable(new ArrowType.Int(32,true)), null);
Schema schema = new Schema(asList(a, b), metadata);
Field struct = new Field("struct", FieldType.notNullable(new ArrowType.Struct()), schema.getFields());
StructVector structVector = new StructVector(Field.nullable("struct", struct.getType()), allocator, null);
MapVector mapVector = new MapVector(Field.nullable("map", structVector.getField().getType()), allocator, null);
mapVector.initializeChildrenFromFields(Collections.singletonList(struct));
mapVector.allocateNew();

UnionMapWriter writer = mapVector.getWriter();
for (int i = 0; i < 10; i++) {
writer.startMap();
writer.setPosition(i);
writer.key().writeInt(i);
writer.value().writeInt(i * 10);
writer.endMap();
}
writer.setValueCount(10);
```
when the types of key and value are different, data cannot be written .
Only examples of [ListVector](https://arrow.apache.org/docs/java/vector.html#building-listvector) are available in the documentation on the official website ,Please provide an example of writing data to MapVector.

![image](https://github.com/user-attachments/assets/9d081d9a-6f0d-48c9-a4fd-a4ddaa26450b)

贡献指南

打开贡献指南

调研方向

使用 MapVector 和 UnionMapWriter 重现提供的 Java 代码片段,然后检查 MapVector 和 UnionMapWriter 的写入路径,了解其对不同键类型和值类型的处理。比较现有的 ListVector 文档示例,并将完成定义为以下任一项:成功写入具有混合类型的 MapVector,或提供一个有文档说明且可运行的 MapVector 示例,并由回归测试支持。

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

评估

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

把新 issue 发到你的邮箱

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