[Java] Write list of maps with the vector API
- Langage dominant
- Java
- Étoiles
- 94
- Forks
- 152
- Merge moyen
- 3 j 16 h
- PR mergées (30 j)
- 11
Description
### 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
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Reproduisez l’exemple Java à l’aide de ListVector, UnionListWriter et des appels d’écriture de maps, puis examinez la stack trace de PromotableWriter à l’endroit où startMap() échoue. Déterminez si la vector API doit prendre en charge cette utilisation de listes de maps ; le travail est terminé lorsque l’exemple écrit les maps indiquées, l’entrée de liste null et la valeur de map null sans l’exception signalée.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- java
- Domaine
- data
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- À clarifier
- Accessibilité débutants
- 35/100