[JAVA] Leak in JdbcToArrowUtils
- 主要语言
- Java
- 星标
- 94
- 派生
- 152
- 平均合并
- 3 天 16 小时
- 30 天内合并 PR
- 11
描述
`JdbcToArrowUtils::updateVector(VarCharVector, String, boolean, int)` does not release the memory that it allocates for the `NullableVarCharHolder`. This can be verified by changing the first lines of `JdbcToArrowTest::testJdbcToArrowValues()` to the following:
```java
RootAllocator allocator = new RootAllocator(Integer.MAX_VALUE);
VectorSchemaRoot root = JdbcToArrow.sqlToArrow(conn, table.getQuery(), allocator, Calendar.getInstance());
testDataSets(root);
root.close();
assertEquals(allocator.getAllocatedMemory(), 0);
```
The leak can be fixed by closing the buffer in `updateVector`. However, I would propose to not use the `NullableVarCharHolder` in the first place because it creates an unnecessary copy of the string. Instead, I would use `BaseVariableWidthVector::setSafe(int index, byte[] value)` and `BaseVariableWidthVector::setNull(int index)` directly.
In addition, I would propose to check for leaks in JdbcToArrowTest.
I am willing to create a patch, so please let me know what approach is preferred.
**Reporter**: [Johannes Luong](https://issues.apache.org/jira/browse/ARROW-5536) / @jmaschad
**Note**: *This issue was originally created as [ARROW-5536](https://issues.apache.org/jira/browse/ARROW-5536). Please see the [migration documentation](https://github.com/apache/arrow/issues/14542) for further details.*
贡献指南
调研方向
从 JdbcToArrowUtils::updateVector(VarCharVector, String, boolean, int) 开始,检查 NullableVarCharHolder 如何分配其缓冲区。检查 JdbcToArrowTest::testJdbcToArrowValues() 并添加 issue 中所示的 allocator 内存断言;在关闭 root 后测试以分配内存为零的状态通过时,工作即完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- java
- 领域
- databases
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100