You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Java] MapVector written data does not meet expectations #40
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.
I've opened PR #1475 with a MapVector usage example.
The example demonstrates creating a MapVector with BIGINT keys and INT values, writing multiple key-value entries using UnionMapWriter, and reading them back using UnionMapReader.
I hope this helps clarify the expected usage of MapVector. Feedback and suggestions are welcome. Thanks!
Activity
[-][Java] MapVector write demo[/-][+][Java] MapVector written data does not meet expectations[/+]lidavidm commentedon Nov 6, 2024
I think this belongs on apache/arrow and not apache/arrow-adbc?
hawk9821 commentedon Nov 7, 2024
yes , here are the dependencies , version is
15.0.1hawk9821 commentedon Nov 12, 2024
@lidavidm hi, whether the community has a plan to provide the correct MapVector example
lidavidm commentedon Nov 25, 2024
@hawk9821 sorry for the delay, if I can find some time I will try to add a Cookbook example
yashdotdev13 commentedon Nov 14, 2026
Hi @lidavidm,
I've opened PR #1475 with a MapVector usage example.
The example demonstrates creating a MapVector with BIGINT keys and INT values, writing multiple key-value entries using UnionMapWriter, and reading them back using UnionMapReader.
I hope this helps clarify the expected usage of MapVector. Feedback and suggestions are welcome. Thanks!