Title: [Java] VectorSchemaRoot#addVector() cannot add a vector to the end of the current vector collection · Issue #301 · apache/arrow-java · GitHub
Open Graph Title: [Java] VectorSchemaRoot#addVector() cannot add a vector to the end of the current vector collection · Issue #301 · apache/arrow-java
X Title: [Java] VectorSchemaRoot#addVector() cannot add a vector to the end of the current vector collection · Issue #301 · apache/arrow-java
Description: The current implementation of Java VectorSchemaRoot cannot add a vector at the end of the current list (which is the generally understood meaning of "add"). The Precondition check in the method's second line prevents providing an appropr...
Open Graph Description: The current implementation of Java VectorSchemaRoot cannot add a vector at the end of the current list (which is the generally understood meaning of "add"). The Precondition check in the method's s...
X Description: The current implementation of Java VectorSchemaRoot cannot add a vector at the end of the current list (which is the generally understood meaning of "add"). The Precondition check in the ...
Opengraph URL: https://github.com/apache/arrow-java/issues/301
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Java] VectorSchemaRoot#addVector() cannot add a vector to the end of the current vector collection","articleBody":"The current implementation of Java VectorSchemaRoot cannot add a vector at the end of the current list (which is the generally understood meaning of \"add\").\r\n\r\nThe Precondition check in the method's second line prevents providing an appropriate index for adding at the end:\r\n```java\n\r\npublic VectorSchemaRoot addVector(int index, FieldVector vector) {\r\n Preconditions.checkNotNull(vector);\r\n Preconditions.checkArgument(index \u003e= 0 \u0026\u0026 index \u003c fieldVectors.size());\r\n List\u003cFieldVector\u003e newVectors = new ArrayList\u003c\u003e();\r\n for (int i = 0; i \u003c fieldVectors.size(); i++) {\r\n if (i == index) {\r\n newVectors.add(vector);\r\n }\r\n newVectors.add(fieldVectors.get(i));\r\n }\r\n return new VectorSchemaRoot(newVectors);\r\n}\r\n \n```\r\nOne possible implementation resolving the issue is shown below.\r\n```java\n\r\npublic VectorSchemaRoot addVector(int index, FieldVector vector) {\r\n Preconditions.checkNotNull(vector);\r\n Preconditions.checkArgument(index \u003e= 0 \u0026\u0026 index \u003c= fieldVectors.size());\r\n List\u003cFieldVector\u003e newVectors = new ArrayList\u003c\u003e();\r\n if (index == fieldVectors.size()) {\r\n newVectors.addAll(fieldVectors);\r\n newVectors.add(vector); \r\n } else {\r\n for (int i = 0; i \u003c fieldVectors.size(); i++) {\r\n if (i == index) {\r\n newVectors.add(vector);\r\n }\r\n newVectors.add(fieldVectors.get(i));\r\n }\r\n }\r\n return new VectorSchemaRoot(newVectors);\r\n}\r\n```\r\n \r\n\r\n \r\n\r\n \r\n\r\n \r\n\r\n \n\n**Reporter**: [Larry White](https://issues.apache.org/jira/browse/ARROW-17530) / @lwhite1\n\n\u003csub\u003e**Note**: *This issue was originally created as [ARROW-17530](https://issues.apache.org/jira/browse/ARROW-17530). Please see the [migration documentation](https://github.com/apache/arrow/issues/14542) for further details.*\u003c/sub\u003e","author":{"url":"https://github.com/asfimport","@type":"Person","name":"asfimport"},"datePublished":"2022-08-25T18:16:24.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/301/arrow-java/issues/301"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:6a20e54e-8e0a-4e41-bb9b-57d32bca50ce |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E89C:281D19:15367F2:1B4D730:6991A17F |
| html-safe-nonce | 1e6e38f2a3bcf487aec2f965a3ce43a4859ac0928767ae909a442eb4b00262a0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFODlDOjI4MUQxOToxNTM2N0YyOjFCNEQ3MzA6Njk5MUExN0YiLCJ2aXNpdG9yX2lkIjoiODAyNTkxMjU2MDY3ODE4MzI5NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | c7e711b71674a1e48dd366f448ba319719ebc04333cbcdcf48e30f5b5f0bb68c |
| hovercard-subject-tag | issue:2695890288 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/apache/arrow-java/301/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8c005d7bc8f4374214505b67e43ca50a56bc3c2d8df810569571f58f832efa16/apache/arrow-java/issues/301 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8c005d7bc8f4374214505b67e43ca50a56bc3c2d8df810569571f58f832efa16/apache/arrow-java/issues/301 |
| og:image:alt | The current implementation of Java VectorSchemaRoot cannot add a vector at the end of the current list (which is the generally understood meaning of "add"). The Precondition check in the method's s... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | asfimport |
| hostname | github.com |
| expected-hostname | github.com |
| None | 42c603b9d642c4a9065a51770f75e5e27132fef0e858607f5c9cb7e422831a7b |
| turbo-cache-control | no-preview |
| go-import | github.com/apache/arrow-java git https://github.com/apache/arrow-java.git |
| octolytics-dimension-user_id | 47359 |
| octolytics-dimension-user_login | apache |
| octolytics-dimension-repository_id | 893682219 |
| octolytics-dimension-repository_nwo | apache/arrow-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 893682219 |
| octolytics-dimension-repository_network_root_nwo | apache/arrow-java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 848bc6032dcc93a9a7301dcc3f379a72ba13b96e |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width