缺少在 Java 中创建结构向量的助手

Missing helpers to create vector of structs in Java

让我们假设以下 FlatBuffer 模式为例:

struct Ipv6 {
    b0: byte;
    b1: byte;
    b2: byte;
    b3: byte;
    b4: byte;
    b5: byte;
    b6: byte;
    b7: byte;
    b8: byte;
    b9: byte;
    b10: byte;
    b11: byte;
    b12: byte;
    b13: byte;
    b14: byte;
    b15: byte;
}

table Ipv6List {
    entries: [Ipv6];
}

root_type Ipv6List;

我遇到的问题是创建一个包含 Ipv6 结构的向量。 Flatbuffer 1.11.0 生成的 Java class Ipv6List 不包括通常的 create 帮助程序。阅读文档似乎是一种通过防止创建临时对象来提高性能的设计选择。

查看其他方法,有一个 Ipv6List#startEntriesVector 静态函数,但没有关联的 addXendX 函数。这是我正在尝试做的事情:

FlatBufferBuilder builder = new FlatBufferBuilder();

final byte[] inetAddressBytes =
        Inet6Address.getByName("2a01:e35:2e7a:490:6193:c54c:f740:f907").getAddress();

int ipv6Offset = Ipv6.createIpv6(builder,
        inetAddressBytes[0], inetAddressBytes[1], inetAddressBytes[2], inetAddressBytes[3],
        inetAddressBytes[4], inetAddressBytes[5], inetAddressBytes[6], inetAddressBytes[7],
        inetAddressBytes[8], inetAddressBytes[9], inetAddressBytes[10], inetAddressBytes[11],
        inetAddressBytes[12], inetAddressBytes[13], inetAddressBytes[14], inetAddressBytes[15]
);

Ipv6List.startEntriesVector(builder, 1);

// how to add the IP to the vector ?
// how to end the association and get the vector offset ?
// int ipsVectorOffset = ?;

int ipListOffset = Ipv6List.createIpv6List(builder, ipsVectorOffset);
builder.finish(ipListOffset);
ByteBuffer byteBuffer = builder.dataBuffer();

知道如何创建 Ipv6 结构向量并将其与列表相关联吗?

结构总是需要内联创建,所以操作顺序应该是:

Ipv6List.startEntriesVector(builder, 1);
Ipv6.createIpv6(builder,..);
o = builder.endVector();
Ipv6List.createIpv6List(builder, o);