apache / apache/arrow-java

[Java] UnionListWriter.writeVarChar get a empty string list

未关闭
#214 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
Type: usage
主要语言
Java
星标
94
派生
152
平均合并
3 天 16 小时
30 天内合并 PR
11

描述

```
def writeListVector(writer: UnionListWriter, arr: Array[_], pose: Int): Unit = {
writer.startList()
writer.setPosition(pose)
arr.foreach {
case e: Short => writer.smallInt().writeSmallInt(e)
case e: Int => writer.integer().writeInt(e)
case e: Byte => writer.writeTinyInt(e)
case e: String =>
val rootAllocator = new RootAllocator()
val tempBuf = rootAllocator.buffer(2048)
val bytes = e.getBytes(StandardCharsets.UTF_8)
tempBuf.setBytes(0, bytes, 0, bytes.length)
writer.varChar().writeVarChar(0, bytes.length, tempBuf)
}
writer.setValueCount(arr.length)
writer.endList()
}
````
I use a function like above to write an array to a list vector, everything is normal except case String. It just returns a empty string list,which every elements' length is correct, like:
`[["", ""], [""], ["", "", ""]]`
can somebody help me?

### Component(s)

Java

贡献指南

打开贡献指南

调研方向

首先复现 writeListVector 中的示例并跟踪 UnionListWriter.writeVarChar,重点关注为什么输出保留了元素数量和长度,却丢失了字符串内容。当通过 list vector 写入的字符串元素能够以其原始值而不是空字符串返回时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
java
领域
data
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。