在Windows中运行Apache Arrow Java代码时遇到问题?

waxmsbnn  于 2023-10-22  发布在  Windows
关注(0)|答案(1)|浏览(177)

我是Apache Arrow的新手,我试图在Java中运行示例代码,我使用Windows操作系统进行开发。下面是我的代码。

public class App {
public static void main(String[] args) {
    System.out.println("Hello World!");
    try(
            BufferAllocator allocator = new RootAllocator();
            ListVector listVector = ListVector.empty("listVector", allocator);
            UnionListWriter listWriter = listVector.getWriter()
        ) {
            int[] data = new int[] { 1, 2, 3, 10, 20, 30, 100, 200, 300, 1000, 2000, 3000 };
            int tmp_index = 0;
            for(int i = 0; i < 4; i++) {
                listWriter.setPosition(i);
                listWriter.startList();
                for(int j = 0; j < 3; j++) {
                    listWriter.writeInt(data[tmp_index]);
                    tmp_index = tmp_index + 1;
                }
                listWriter.setValueCount(3);
                listWriter.endList();
            }
            listVector.setValueCount(4);

            System.out.print(listVector);
        } catch (Exception e) {
            e.printStackTrace();
        }
}

我得到这个错误

Exception in thread "main" java.lang.ExceptionInInitializerError
at org.apache.arrow.memory.ArrowBuf.setZero(ArrowBuf.java:1161)
at org.apache.arrow.vector.complex.BaseRepeatedValueVector.reallocOffsetBuffer(BaseRepeatedValueVector.java:135)
at org.apache.arrow.vector.complex.ListVector.reallocValidityAndOffsetBuffers(ListVector.java:300)
at org.apache.arrow.vector.complex.ListVector.startNewValue(ListVector.java:808)
at org.apache.arrow.vector.complex.impl.UnionListWriter.startList(UnionListWriter.java:517)
at arrow_pro.check.App.main(App.java:24)
Suppressed: java.lang.NullPointerException: Cannot invoke "org.apache.arrow.vector.complex.writer.FieldWriter.close()" because the return value of "org.apache.arrow.vector.complex.impl.PromotableWriter.getWriter()" is null
    at org.apache.arrow.vector.complex.impl.PromotableWriter.close(PromotableWriter.java:396)
    at org.apache.arrow.vector.complex.impl.UnionListWriter.close(UnionListWriter.java:121)
    at arrow_pro.check.App.main(App.java:35)
Suppressed: java.lang.IllegalStateException: Memory was leaked by query. Memory leaked: (16384) Allocator(ROOT) 0/16384/16384/9223372036854775807 (res/actual/peak/limit)

    at org.apache.arrow.memory.BaseAllocator.close(BaseAllocator.java:437)
    at org.apache.arrow.memory.RootAllocator.close(RootAllocator.java:29)
    at arrow_pro.check.App.main(App.java:35)Caused by: java.lang.RuntimeException: Failed to initialize MemoryUtil.
at org.apache.arrow.memory.util.MemoryUtil.<clinit>(MemoryUtil.java:136)
... 6 more

原因:java.lang.reflect.InaccessibleObjectException:无法使字段长java.nio.Buffer.address可访问:模块java.base不会“打开java.nio”到未命名的模块@6895a785,位于java.base/java.lang.reflect. field. setsensible(field.java:178),位于java.base/java.lang.reflect. field. setsensible(field.java:172),位于java.base/java.lang.reflect.Field. setsensible(field.java:172),位于java. base/java.lang. reflect. setsensible(field.java:172),位于java.base/java.lang.reflect. setsensibleObject. checkCanSetsensible(field.java:354),位于java.base/java. lang. reflect. setsensibleObject. checkCanSetsensible(field.java:297),位于org.apache.arrow.memory.util. 6更多
我正在使用这些依赖项

<dependency>
        <groupId>org.apache.arrow</groupId>
        <artifactId>arrow-vector</artifactId>
        <version>${arrow.version}</version>
    </dependency>

    <dependency>
        <groupId>org.apache.arrow</groupId>
        <artifactId>arrow-memory-netty</artifactId>
        <version>${arrow.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.arrow</groupId>
        <artifactId>arrow-memory-core</artifactId>
        <version>${arrow.version}</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>${slf4j.version}</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>${slf4j.version}</version>
    </dependency>
pb3skfrl

pb3skfrl1#

我在Java 8中遇到了同样的问题。
我在eclipse的VM参数中添加了**--add-opens=java.base/java.nio=ALL-UNNAMED**,它解决了我的问题。

相关问题