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 摘要。