Arrow Java ListVector writeBatch and read 获取空列表

Arrow Java ListVector writeBatch and read get empty list

我在 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 很复杂 类,根据我的测试,与仅使用基本 类 相比,它们不会带来速度或内存优势。而且复杂类的文档很少

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