1

REST API (Java バインディング ライブラリを使用) を使用していくつかのサイファー クエリをまとめてバッチ処理しようとしています。しかし、クライアント側でのバッチ処理を尊重していないようで、次のエラーが発生します。

java.lang.RuntimeException: Error reading as JSON ''
    at org.neo4j.rest.graphdb.util.JsonHelper.readJson(JsonHelper.java:57)
    at org.neo4j.rest.graphdb.util.JsonHelper.jsonToSingleValue(JsonHelper.java:62)
    at org.neo4j.rest.graphdb.RequestResult.toEntity(RequestResult.java:114)
    at org.neo4j.rest.graphdb.RequestResult.toMap(RequestResult.java:123)
    at org.neo4j.rest.graphdb.batch.RecordingRestRequest.toMap(RecordingRestRequest.java:138)
    at org.neo4j.rest.graphdb.ExecutingRestAPI.query(ExecutingRestAPI.java:489)
    at org.neo4j.rest.graphdb.ExecutingRestAPI.query(ExecutingRestAPI.java:509)
    at org.neo4j.rest.graphdb.RestAPIFacade.query(RestAPIFacade.java:233)
    at org.neo4j.rest.graphdb.query.RestCypherQueryEngine.query(RestCypherQueryEngine.java:50)
    ...
Caused by: java.io.EOFException: No content to map to Object due to end of input
    at org.codehaus.jackson.map.ObjectMapper._initForReading(ObjectMapper.java:2766)
    at org.codehaus.jackson.map.ObjectMapper._readMapAndClose(ObjectMapper.java:2709)
    at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1854)
    at org.neo4j.rest.graphdb.util.JsonHelper.readJson(JsonHelper.java:55)
    ... 41 more

これは私がそれらをバッチ処理しようとしている方法です:

graphDatabaseService.getRestAPI().executeBatch(new BatchCallback<Void>() {
            @Override
            public Void recordBatch(RestAPI batchRestApi) {
                String query =  "CREATE accounts=({userId:{userId}})-[r:OWNS]->({facebookId:{facebookId}})";
                graphDatabaseService.getQueryEngine().query(query, map("userId", 1, "facebookId", "1"));
                graphDatabaseService.getQueryEngine().query(query, map("userId", 2, "facebookId", "2"));
                graphDatabaseService.getQueryEngine().query(query, map("userId", 3, "facebookId", "3"));


                return null;
            }
        });

noe4j バージョン 1.9 と対応するクライアント ライブラリを使用しています。これは可能でしょうか?

4

1 に答える 1

0

これは、バッチで機能する JUnit サンプル コードです。ここでは、文字列テンプレートは使用されていませんが、RestAPI オブジェクトのネイティブ メソッドが使用されています。

public static final DynamicRelationshipType OWNS = DynamicRelationshipType.withName("OWNS");

@Autowired
private SpringRestGraphDatabase             graphDatabaseService;

@Test
public void batchTest()
    {

    Assert.assertNotNull(this.graphDatabaseService);

    this.graphDatabaseService.getRestAPI().executeBatch(new BatchCallback<Void>()
        {
            @Override
            public Void recordBatch(RestAPI batchRestApi)
                {
                for (int counter = 1; counter <= 3; counter++)
                    {
                    RestNode userId = batchRestApi.createNode(map("userId", Integer.valueOf(counter)));
                    RestNode facebookId = batchRestApi.createNode(map("facebookId", Integer.valueOf(counter).toString()));
                    batchRestApi.createRelationship(userId, facebookId, OWNS, map());
                    }
                return null;
                }
        });

    }
于 2013-08-22T14:21:41.250 に答える