apache/incubator-hugegraph-toolchain

[Bug] When calling the 'kneigbor' interface and returning the result, scenarios where 'withPath' is' true 'and' false 'are incompatible

Opened this issue · 1 comments

Bug Type (问题类型)

rest-api (结果不合预期)

Before submit

  • I had searched in the issues and found no similar issues.

Environment (环境信息)

  • Server Version: v1.5.0
  • Toolchain Version: v1.5.0

Expected & Actual behavior (期望与实际表现)

调用‘kneighbor‘接口时,返回结果时,‘withPath‘为‘true‘与为‘false‘’的场景不兼容

com.qsdi.bigdata.multi.graph.common.exception.SdkException: (graph travel exception ):Failed to deserialize: {"kneighbor":["2:car1!2","2:car2!4"],"size":2,"paths":[{"objects":["1:zhangsan","2:car1!2"]},{"objects":["1:zhangsan","2:car2!4"]}],"vertices":[{"id":"2:car2!4","label":"car","type":"vertex","properties":{"age":4,"qsdi_task_id":"car2_task_id_test","qsdi_record_id":"test_record_id","name":"car2","qsdi_data_source":"1"}},{"id":"1:zhangsan","label":"people","type":"vertex","properties":{"age":55,"qsdi_record_id":"926106078160666624","name":"zhangsan","qsdi_data_source":"1"}},{"id":"2:car1!2","label":"car","type":"vertex","properties":{"age":2,"qsdi_task_id":"car1_task_id_test","qsdi_record_id":"car1_log_id_test","name":"car1","qsdi_data_source":"1"}}],"edges":["S1:zhangsan>3>3>>S2:car2!4","S1:zhangsan>3>3>>S2:car1!2"]}

at com.qsdi.bigdata.multi.graph.api.graph.DefaultGraphBusinessApi.kneighbor(DefaultGraphBusinessApi.java:2123)
at com.qsdi.bigdata.multi.graph.api.graph.DefaultGraphBusinessApi$$EnhancerByCGLIB$$7d86a3a5.CGLIB$kneighbor$10(<generated>)
at com.qsdi.bigdata.multi.graph.api.graph.DefaultGraphBusinessApi$$EnhancerByCGLIB$$7d86a3a5$$FastClassByCGLIB$$e8249271.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
at com.qsdi.bigdata.multi.graph.api.handler.GraphApiHandler.intercept(GraphApiHandler.java:24)
at com.qsdi.bigdata.multi.graph.api.graph.DefaultGraphBusinessApi$$EnhancerByCGLIB$$7d86a3a5.kneighbor(<generated>)
at com.qsdi.ipbd.multi.graph.test.hugegraph.GraphApiTest.testKneighbor(GraphApiTest.java:3149)
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:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:74)
at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:84)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:232)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:55)

Caused by: org.apache.hugegraph.rest.SerializeException: Failed to deserialize: {"kneighbor":["2:car1!2","2:car2!4"],"size":2,"paths":[{"objects":["1:zhangsan","2:car1!2"]},{"objects":["1:zhangsan","2:car2!4"]}],"vertices":[{"id":"2:car2!4","label":"car","type":"vertex","properties":{"age":4,"qsdi_task_id":"car2_task_id_test","qsdi_record_id":"test_record_id","name":"car2","qsdi_data_source":"1"}},{"id":"1:zhangsan","label":"people","type":"vertex","properties":{"age":55,"qsdi_record_id":"926106078160666624","name":"zhangsan","qsdi_data_source":"1"}},{"id":"2:car1!2","label":"car","type":"vertex","properties":{"age":2,"qsdi_task_id":"car1_task_id_test","qsdi_record_id":"car1_log_id_test","name":"car1","qsdi_data_source":"1"}}],"edges":["S1:zhangsan>3>3>>S2:car2!4","S1:zhangsan>3>3>>S2:car1!2"]}
at org.apache.hugegraph.rest.RestResult.readObject(RestResult.java:76)
at org.apache.hugegraph.api.traverser.KneighborAPI.post(KneighborAPI.java:63)
at org.apache.hugegraph.driver.TraverserManager.kneighbor(TraverserManager.java:471)
at com.qsdi.bigdata.multi.graph.hugegraph.api.HugeGraphApi.kneighbor(HugeGraphApi.java:595)
at com.qsdi.bigdata.multi.graph.api.graph.DefaultGraphBusinessApi.kneighbor(DefaultGraphBusinessApi.java:2116)
... 39 more
Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of org.apache.hugegraph.structure.graph.Edge (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('S1:zhangsan>3>3>>S2:car2!4')
at [Source: (String)"{"kneighbor":["2:car1!2","2:car2!4"],"size":2,"paths":[{"objects":["1:zhangsan","2:car1!2"]},{"objects":["1:zhangsan","2:car2!4"]}],"vertices":[{"id":"2:car2!4","label":"car","type":"vertex","properties":{"age":4,"qsdi_task_id":"car2_task_id_test","qsdi_record_id":"test_record_id","name":"car2","qsdi_data_source":"1"}},{"id":"1:zhangsan","label":"people","type":"vertex","properties":{"age":55,"qsdi_record_id":"926106078160666624","name":"zhangsan","qsdi_data_source":"1"}},{"id":"2:car1!2","label"[truncated 225 chars]; line: 1, column: 667] (through reference chain: org.apache.hugegraph.structure.traverser.Kneighbor["edges"]->java.util.HashSet[0])
at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:63)
at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1588)
at com.fasterxml.jackson.databind.DeserializationContext.handleMissingInstantiator(DeserializationContext.java:1213)
at com.fasterxml.jackson.databind.deser.std.StdDeserializer._deserializeFromString(StdDeserializer.java:311)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromString(BeanDeserializerBase.java:1495)
at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeOther(BeanDeserializer.java:207)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:197)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer._deserializeFromArray(CollectionDeserializer.java:355)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:244)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:28)
at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:138)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:324)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:187)
at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:322)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4593)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3548)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3516)
at org.apache.hugegraph.rest.RestResult.readObject(RestResult.java:74)
... 43 more

Vertex/Edge example (问题点 / 边数据举例)

No response

Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构)

No response

The issue you're encountering seems to be related to the deserialization of the 'edges' field in the 'kneighbor' API response. The error message indicates that there is no String-argument constructor or factory method available to deserialize the edge data from a String value like 'S1:zhangsan>3>3>>S2:car2!4'.

The HugeEdge class in the HugeGraph codebase does not have a constructor that directly takes a String as an argument. However, there are factory methods like constructEdge and constructEdgeWithoutGraph that take a String argument named sortValues, which might be relevant for constructing edges from string representations [1].

To resolve this issue, you may need to implement a custom deserialization logic or modify the existing deserialization process to handle the string format of the edges. This could involve creating a factory method or constructor in the Edge class that can parse the string representation of an edge and create an Edge object accordingly.

To continue talking to Dosu, mention @dosu.