首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Neo4j:未能实例化BatchInserter

Neo4j:未能实例化BatchInserter
EN

Stack Overflow用户
提问于 2015-09-18 18:44:48
回答 3查看 235关注 0票数 2

当我试图创建一个org.neo4j.unsafe.batchinsert.BatchInserter时,我遇到了以下错误

代码语言:javascript
运行
复制
Caused by: java.lang.IllegalStateException: Misaligned file size 68 for DynamicArrayStore[fileName:neostore.nodestore.db.labels, blockSize:60], expected version length 25
    at org.neo4j.kernel.impl.store.AbstractDynamicStore.verifyFileSizeAndTruncate(AbstractDynamicStore.java:265)
    at org.neo4j.kernel.impl.store.CommonAbstractStore.loadStorage(CommonAbstractStore.java:230)
    at org.neo4j.kernel.impl.store.CommonAbstractStore.<init>(CommonAbstractStore.java:118)
    at org.neo4j.kernel.impl.store.AbstractDynamicStore.<init>(AbstractDynamicStore.java:92)
    at org.neo4j.kernel.impl.store.DynamicArrayStore.<init>(DynamicArrayStore.java:64)
    at org.neo4j.kernel.impl.store.StoreFactory.newNodeStore(StoreFactory.java:328)
    at org.neo4j.kernel.impl.store.StoreFactory.newNodeStore(StoreFactory.java:317)
    at org.neo4j.kernel.impl.store.StoreFactory.newNeoStore(StoreFactory.java:161)
    at org.neo4j.unsafe.batchinsert.BatchInserterImpl.<init>(BatchInserterImpl.java:262)
    at org.neo4j.unsafe.batchinsert.BatchInserters.inserter(BatchInserters.java:87)
    at org.neo4j.unsafe.batchinsert.BatchInserters.inserter(BatchInserters.java:81)
    at org.neo4j.unsafe.batchinsert.BatchInserters.inserter(BatchInserters.java:56)
    at nl.aegon.maintenance.config.MainConfiguration.getBatchInserter(MainConfiguration.java:137)
    at nl.aegon.maintenance.config.MainConfiguration$$EnhancerBySpringCGLIB$$a40c43d.CGLIB$getBatchInserter$6(<generated>)
    at nl.aegon.maintenance.config.MainConfiguration$$EnhancerBySpringCGLIB$$a40c43d$$FastClassBySpringCGLIB$$1b2b386e.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:309)
    at nl.aegon.maintenance.config.MainConfiguration$$EnhancerBySpringCGLIB$$a40c43d.getBatchInserter(<generated>)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
    ... 62 more

下面可以找到我的Java配置类的片段

代码语言:javascript
运行
复制
private static class configurationSettings extends HashMap<String, String> {
    {
      put("dump_configuration", "false");
      put("cache_type", "none");
      put("use_memory_mapped_buffers", "true");
      put("neostore.propertystore.db.index.keys.mapped_memory", "5M");
      put("neostore.propertystore.db.index.mapped_memory", "5M");
      put("neostore.nodestore.db.mapped_memory", "200M");
      put("neostore.relationshipstore.db.mapped_memory", "500M");
      put("neostore.propertystore.db.mapped_memory", "200M");
      put("neostore.propertystore.db.strings.mapped_memory", "200M");
    }
  }

@Bean
  public BatchInserter getBatchInserter() {
    LOG.debug("Initialising a batch inserter with store directory: {}", databaseConnectionProperties.getStoreDirectory());
    return BatchInserters.inserter(databaseConnectionProperties.getStoreDirectory(), new configurationSettings());
  }

应该有哪些正确的配置属性来克服此错误?我正在尝试并行地进行批量导入,每个文件有3个64 MB

我在git集线器https://github.com/jexp/batch-import/blob/2.2/sample/batch.properties中引用了以下内容

下面是Neo4j抛出异常的相关方法

代码语言:javascript
运行
复制
/**
     * Note: This method runs before the file has been mapped by the page cache, and therefore needs to
     * operate on the store files directly. This method is called by constructors.
     */
@Override
    protected void verifyFileSizeAndTruncate() throws IOException
    {
        int expectedVersionLength = UTF8.encode( buildTypeDescriptorAndVersion( getTypeDescriptor() ) ).length;
        long fileSize = getFileChannel().size();
        if ( (fileSize - expectedVersionLength) % blockSize != 0 )
        {
            setStoreNotOk( new IllegalStateException(
                    "Misaligned file size " + fileSize + " for " + this + ", expected version length " +
                    expectedVersionLength ) );
        }
        if ( getStoreOk() )
        {
            getFileChannel().truncate( fileSize - expectedVersionLength );
        }
    }

我在OSX上使用了java 8、SDN4和neo4j 2.2.5。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2015-09-20 18:29:52

配置选项已经过时,

对于mmio,只使用dbms.pagecache.memory=1500M

批插入器是单线程的,您不能在多线程环境中使用它.

要插入多少数据?

您看过新4j-进口工具了吗?

高度并发的初始并行批处理插入器的底层API也可以直接使用,但并不容易使用。

如果你真的知道你在做什么,看看下面这个:https://github.com/jexp/neo4j-dataset-import

票数 1
EN

Stack Overflow用户

发布于 2015-09-21 20:07:39

问题可能是,您试图在现有商店上启动一个BatchInserter,而该商店并没有完全关闭。是这样吗?

票数 1
EN

Stack Overflow用户

发布于 2016-04-06 15:38:55

我发现,启动,然后关闭,一个正常的neo4j服务器与storeDir修复了这个问题。

我认为这是由于在上一次运行时未能调用BatchInserter.shutdown()造成的。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32658993

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档