[Java] Improve VectorSchemaRoot.getVector(String name) lookup performance
- Dominant language
- Java
- Stars
- 94
- Forks
- 152
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 11
Description
### Describe the enhancement requested
The Java `VectorSchemaRoot.getVector(String name)` can be quite slow if a schema has many vectors. The code currently loops over all the field vectors until it finds the string match. [Link to code](https://github.com/apache/arrow-java/blob/3bc34b041761081ac32a7cd3b167f9ab8b628677/vector/src/main/java/org/apache/arrow/vector/VectorSchemaRoot.java#L175).
Could we stroe a hash map of the `FieldVector` String name to the actual `FieldVector`? Basically the same thing as the `fieldVectorsMap` that maps the `Field` to `FieldVector`. For really wide datasets the trade off of a bit more memory for faster vector lookups would be really nice to have!
Happy to open up a PR with the improvement, thanks!
Contributor guide
Research direction
Start in vector/src/main/java/org/apache/arrow/vector/VectorSchemaRoot.java at getVector(String name), then inspect the existing fieldVectorsMap and the construction paths for field vectors. Confirm the name-based lookup preserves current behavior and compare it on a schema with many vectors; done means repeated name lookups no longer scan every field vector.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- data, performance
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100