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 摘要。