Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Java] MapVector written data does not meet expectations #40

Open
hawk9821 opened this issue Nov 6, 2024 · 4 comments
Open

[Java] MapVector written data does not meet expectations #40

hawk9821 opened this issue Nov 6, 2024 · 4 comments
Labels
Component: Documentation Improvements or additions to documentation

Comments

@hawk9821
Copy link

hawk9821 commented Nov 6, 2024

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

@hawk9821 hawk9821 changed the title [Java] MapVector write demo [Java] MapVector written data does not meet expectations Nov 6, 2024
@lidavidm
Copy link
Member

lidavidm commented Nov 6, 2024

I think this belongs on apache/arrow and not apache/arrow-adbc?

@lidavidm lidavidm transferred this issue from apache/arrow-adbc Nov 6, 2024
@hawk9821
Copy link
Author

hawk9821 commented Nov 7, 2024

I think this belongs on apache/arrow and not apache/arrow-adbc?

yes , here are the dependencies , version is 15.0.1

        <dependency>
            <groupId>org.apache.arrow</groupId>
            <artifactId>arrow-vector</artifactId>
            <version>${arrow.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.arrow</groupId>
            <artifactId>arrow-memory-netty</artifactId>
            <version>${arrow.version}</version>
        </dependency>

@hawk9821
Copy link
Author

hawk9821 commented Nov 12, 2024

@lidavidm hi, whether the community has a plan to provide the correct MapVector example

@lidavidm
Copy link
Member

@hawk9821 sorry for the delay, if I can find some time I will try to add a Cookbook example

@assignUser assignUser transferred this issue from apache/arrow Nov 26, 2024
@assignUser assignUser added the Component: Documentation Improvements or additions to documentation label Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants