Graphson 3.0 Edge file not loading

40 views
Skip to first unread message

Mozart Brocchini

unread,
Apr 29, 2022, 3:18:10 AM4/29/22
to Gremlin-users
Hi everyone,

I am trying to load a file with edges in graphson format, after I have successfully loaded 2 files with just the vertices that will later e connected once the edge file is loaded.

My vertices file look like these 2 lines:
{ "id": "01CD9NS9EGEX9VBRB8REKHDEZC", "label":"Logistic Request", "display_id": "2-118", "name": "Rig", "lr_id":{"@type":"g:Int64","@value":2}, "shipper_gid": "01DSDWQT0S6MA29CZ0ZQ5S931H", "shipper": "Thrymr ", "origin_city": "Foegloe", "origin_country": "Aland Islands", "destination_city": "El Tarter", "destination_country": "Andorra"}
{ "id": "01D70HPGQYCQ844P6SQDNXH7ED", "label":"Logistic Request", "display_id": "653-2019", "name": "sdw213", "lr_id":{"@type":"g:Int64","@value":653}, "shipper_gid": "01DSDWQT0X362Z30A66GG0B04K", "shipper": "testing company", "origin_city": "Australian Capital Territory", "origin_country": "Australia", "destination_city": "El Tarter", "destination_country": "Andorra"}

 My edges file looks like this:
{ "@type":"g:Edge", "id": "01G1NFY49GQAEFRNCSTX1GZTQ1", "label":"generated", "inV":"01F744XWS0APQT0H8BWN72T1M0", "outV":"01F744N5ATGZMAGQR50J5NRG1J"}
{ "@type":"g:Edge", "id": "01G1NFY49GQFW5WEY4SA7AAND1", "label":"generated", "inV":"01F7S1084GQ2HCTR8Z0GRXEQSJ", "outV":"01F7S0HF5MKETMC865PWEMSWCF"}

My java code that loads the files is this:


public void load(String filePath){
    log.debug("Loading graph data from {}", filePath);
    val graphsonReader = GraphSONReader.build()
                        .batchSize(1000)
                        .create();

      try (val is = new FileInputStream(filePath)) {
         graphsonReader.readGraph(is, graph);
         val t = graph.traversal();
          log.info("Vertex count is {}", t.V().count().next());
          log.info("Edge count is {}", t.E().count().next());
       } catch (IOException ioException) {
           log.error("Failed to load graph data from {}", filePath, ioException);
       }
}

Any idea why when I run to load the edges file I get the error below?
java.util.concurrent.CompletionException: java.lang.RuntimeException: org.apache.tinkerpop.shaded.jackson.databind.JsonMappingException: Could not deserialize the JSON value as required. Nested exception: java.lang.InstantiationException: Cannot deserialize the value with the detected type contained in the JSON ('g:Edge') to the type specified in parameter to the object mapper (class java.util.LinkedHashMap). Those types are incompatible.
at [Source: (ByteArrayInputStream); line: 1, column: 30]
at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:314) ~[na:na]
at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319) ~[na:na]
at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1739) ~[na:na]
at java.base/java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1728) ~[na:na]
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290) ~[na:na]
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020) ~[na:na]
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656) ~[na:na]
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594) ~[na:na]
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177) ~[na:na]
Caused by: java.lang.RuntimeException: org.apache.tinkerpop.shaded.jackson.databind.JsonMappingException: Could not deserialize the JSON value as required. Nested exception: java.lang.InstantiationException: Cannot deserialize the value with the detected type contained in the JSON ('g:Edge') to the type specified in parameter to the object mapper (class java.util.LinkedHashMap). Those types are incompatible.
at [Source: (ByteArrayInputStream); line: 1, column: 30]
at org.apache.tinkerpop.gremlin.util.function.FunctionUtils.lambda$wrapFunction$0(FunctionUtils.java:40) ~[gremlin-driver-3.5.2-shaded.jar:3.5.2]
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195) ~[na:na]
at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133) ~[na:na]
at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801) ~[na:na]
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) ~[na:na]
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[na:na]
at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) ~[na:na]
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) ~[na:na]
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497) ~[na:na]
at org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONReader.readGraph(GraphSONReader.java:106) ~[gremlin-driver-3.5.2-shaded.jar:3.5.2]
at e2log.link.util.GraphsonLoader.load(GraphsonLoader.java:36) ~[classes/:na]
at e2log.link.actuator.LoadGraphsonDataEndpoint.lambda$invoke$0(LoadGraphsonDataEndpoint.java:35) ~[classes/:na]
at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1736) ~[na:na]
... 6 common frames omitted
Reply all
Reply to author
Forward
0 new messages