Arrow Java ListVector writeBatch和read get空列表



我在VectorSchemaRoot中有一个ListVector和值[[1,2,3,4,5]],我可以在IDEA中看到它的值。

我使用以下代码编写VectorSchemaRoot变量并获得字节数组

val out = new ByteArrayOutputStream()
val writer = new ArrowStreamWriter(vectorSchemaRoot, null, out)
writer.start()
writer.writeBatch()
writer.end()
out.close()
val byteArr = out.toByteArray

并读回

val allocator = new RootAllocator(Int.MaxValue)
val reader = new ArrowStreamReader(new ByteArrayInputStream(byteArr), allocator)
while (reader.loadNextBatch()) {
val schemaRoot = reader.getVectorSchemaRoot
schemaRoot
}

架构正确,但列表为空[]

然而,我使用其他类型的值,如char、bit,从byteArr读取的结果是正确的(非空(。

如何修复ListVector空的问题?

最后我只使用了基本类。

StructVector, ListVector是复杂的类,根据我的测试,与只使用基本类相比,它们并没有带来速度或内存优势。复杂类的文档很少。

因此,推荐使用基本类。只需使用字段列表来制作它们的模式,就可以获得结构化向量。

最新更新