apache / apache/arrow-java

Java: What is the best way to concat two vectors?

未關閉
#196 2 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
Type: usage
主要語言
Java
星號
94
分支
152
平均合併
3 天 16 小時
30 天內合併 PR
11

描述

### Describe the usage question you have. Please include as many useful details as possible.

Given two `IntVector`s `one: {1, 2, 3}` and `another: {null, 5, 6}`,
how can I concat them into avector `result: {1, 2, 3, 4, 5, 6}`?

Should I copy element one by one using `copyFromSafe` or is there any convenient method to achieve the same result?

If I should copy element one by one, how can I calculate value count and null count of the result?

```scala
val one : IntVector = ??? // suppose {1, 2, 3,}
val another: IntVector = ??? // suppose {null, 5, 6}

val offset = one.getValueCount() +one.getNullCount() // 3
val len = another.getValueCount() + another.getNullCount() // 3
var i = 0
while i < len do
one.copyFromSafe(i, offset + i, another)
// can I detect whether copied value is null here so that I can respectively count non-null value and null value?
// for example
// val isNull = one.nullAwareCopyFromSafe(i, offset + i, another)
// if isNull then j += 1 else i += 1
i += 1
one.setValueCount(offset + i)
// offset + i is 6, but another may contain null, so value count could be different from actual value.
```

### Component(s)

Java

貢獻指南

開啟貢獻指南

研究方向

從 IntVector API 文件中關於 copyFromSafe、getValueCount、getNullCount 和 setValueCount 的部分開始。確定串接兩個向量的支援方式,以及 null 如何影響值計數和 null 計數,然後使用針對所回報輸入的修正範例記錄該方法。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
java
領域
data
Issue 類型
文件
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
需要釐清
新手友好度
25/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。