[Java] MapVector written data does not meet expectations

Open
#40 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
java
Domain
data

Research direction

Reproduce the provided Java snippet with MapVector and UnionMapWriter, then inspect the MapVector and UnionMapWriter write path for handling different key and value types. Compare the available ListVector documentation example and define completion as either successful mixed-type MapVector writes or a documented working MapVector example, backed by a regression test.

Written by the indexing model from the issue text.

Description

Component: Documentation
What would you like help with?
    RootAllocator allocator = new RootAllocator(Long.MAX_VALUE);
    Map<String, String> 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 are available in the documentation on the official website ,Please provide an example of writing data to MapVector.

image

Dominant language
Java
Stars
95
Forks
154
Avg merge
2d 10h
Merged PRs (30d)
11

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/arrow-java

All issues in apache/arrow-java

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.