apache / apache/arrow-java

[Java] Write list of maps with the vector API

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

描述

### Describe the usage question you have. Please include as many useful details as possible.

I'd like to store list of maps. Not sure if I am doing it wrong or there is a bug in the implementation.
Here is my example:
```java
try (ListVector listVector = ListVector.empty("sourceVector", allocator)) {

UnionListWriter listWriter = listVector.getWriter();

listWriter.allocate();

/*
* [{"one" -> 1, "two" -> 2}, {"three" -> 3}, null, {"four" -> null, "five" -> 5}]
*/

listWriter.setPosition(0);
listWriter.startList();

listWriter.map().startMap(); // <-- exception is thrown from here
listWriter.map().startEntry();
listWriter.map().key().varChar().writeVarChar("one");
listWriter.map().key().integer().writeInt(1);
listWriter.map().endEntry();
listWriter.map().startEntry();
listWriter.map().key().varChar().writeVarChar("two");
listWriter.map().key().integer().writeInt(2);
listWriter.map().endEntry();
listWriter.map().endMap();

listWriter.map().startMap();
listWriter.map().startEntry();
listWriter.map().key().varChar().writeVarChar("three");
listWriter.map().key().integer().writeInt(3);
listWriter.map().endEntry();
listWriter.map().endMap();

listWriter.writeNull();

listWriter.map().startMap();
listWriter.map().startEntry();
listWriter.map().key().varChar().writeVarChar("four");
listWriter.map().key().integer().writeNull();
listWriter.map().endEntry();
listWriter.map().startEntry();
listWriter.map().key().varChar().writeVarChar("five");
listWriter.map().key().integer().writeInt(5);
listWriter.map().endEntry();
listWriter.map().endMap();

listWriter.endList();
```

When I execute this I'm getting the following exception:
```
java.lang.UnsupportedOperationException: Cannot get simple type for type MAP
at org.apache.arrow.vector/org.apache.arrow.vector.types.Types$MinorType.getType(Types.java:807)
at org.apache.arrow.vector/org.apache.arrow.vector.complex.impl.PromotableWriter.getWriter(PromotableWriter.java:275)
at org.apache.arrow.vector/org.apache.arrow.vector.complex.impl.AbstractPromotableFieldWriter.getWriter(AbstractPromotableFieldWriter.java:80)
at org.apache.arrow.vector/org.apache.arrow.vector.complex.impl.AbstractPromotableFieldWriter.startMap(AbstractPromotableFieldWriter.java:114)
at org.apache.arrow.vector/org.apache.arrow.vector.complex.impl.PromotableWriter.startMap(PromotableWriter.java:53)
```

### Component(s)

Java

贡献指南

打开贡献指南

调研方向

使用 ListVector、UnionListWriter 和写入 map 的调用重现 Java 示例,然后检查 startMap() 失败处的 PromotableWriter 堆栈跟踪。确定 vector API 是否应支持这种 list-of-maps 用法;完成的标准是示例能够写入所述的 map、null list 条目和 null map 值,且不会出现所报告的异常。

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

评估

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

把新 issue 发到你的邮箱

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