[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 記憶體 assertion;關閉 root 後,測試在配置記憶體為零的情況下通過時,工作即完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- java
- 領域
- databases
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100