Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] HugeGraph could not process Inifnity/NaN value in float/double #1575

Closed
1 task done
zhengyingying opened this issue Aug 16, 2021 · 7 comments · Fixed by #1578
Closed
1 task done

[Bug] HugeGraph could not process Inifnity/NaN value in float/double #1575

zhengyingying opened this issue Aug 16, 2021 · 7 comments · Fixed by #1578
Labels
bug Something isn't working

Comments

@zhengyingying
Copy link

Bug Type (问题类型)

gremlin (结果不合预期)

Before submit

  • 我已经确认现有的 IssuesFAQ 中没有相同 / 重复问题

Environment (环境信息)

  • Server Version: v0.11.2
  • Backend: Memory
  • OS: 10 CPUs, 125 G RAM, Centos 7.x
  • Data Size: 100 vertices, 200 edges

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

Expected Behavior
We expected to write Double.Infinity value into HugeGraph.

Current Behavior

An exception was thrown.

class java.lang.IllegalArgumentException: Invalid property value 'Infinity' for key 'price', expect a value of type Double, actual type String
at com.baidu.hugegraph.exception.ServerException.fromResponse(ServerException.java:47)
at com.baidu.hugegraph.client.RestClient.checkStatus(RestClient.java:93)
at com.baidu.hugegraph.rest.AbstractRestClient.post(AbstractRestClient.java:198)
at com.baidu.hugegraph.rest.AbstractRestClient.post(AbstractRestClient.java:178)
at com.baidu.hugegraph.api.graph.VertexAPI.create(VertexAPI.java:58)
at com.baidu.hugegraph.driver.GraphManager.addVertices(GraphManager.java:96)

Steps to Reproduce

hugegraph.schema().propertyKey("name").asText().ifNotExist().create();
hugegraph.schema().propertyKey("price").asDouble().ifNotExist().create();

// vertex
hugegraph.schema().vertexLabel("person").properties("name").nullableKeys("name").create();
hugegraph.schema().indexLabel("personbyname").onV("person").by("name").shard().ifNotExist().create();
hugegraph.schema().vertexLabel("product").properties("name","price").nullableKeys("name","price").create();
hugegraph.schema().indexLabel("productbyname").onV("product").by("name").shard().ifNotExist().create();
hugegraph.schema().indexLabel("productbyprice").onV("product").by("price").shard().ifNotExist().create();

GraphManager graph = hugegraph.graph();

/** create graph data */
Vertex nancy = new Vertex("person").property("name", "nancy");
Vertex product1 = new Vertex("product").property("name", "product1").property("price", 3.254615);
Vertex product2 = new Vertex("product").property("name", "product2").property("price", new Double(1029.98 / 0));

graph.addVertices(Arrays.asList(nancy, product1, product2));

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

No response

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

No response

@zhengyingying zhengyingying added the bug Something isn't working label Aug 16, 2021
@imbajin
Copy link
Member

imbajin commented Aug 16, 2021

u define a pk price with Double type, however what dose Double.Infinity mean?

or u can paste the phrase like xx.property("price", 3.254615) for us to understand

@zhengyingying
Copy link
Author

Thanks for your advice. Double.Infinity value means an infinite value of type Double. It is a special constant which is equal to the value returned by Double.longBitsToDouble (0x7ff0000000000000L). When the divisor is equal to 0, the result returns the Double.Infinity value.

In our case, new Double(1029.98 / 0) is the Double.Infinity value. We can do this in both JanusGraph and Neo4j-Gremlin but not in HugeGraph. That’s why we think HugeGraph could not process Double.Inifnity value.

@imbajin
Copy link
Member

imbajin commented Aug 17, 2021

Get it, the reason is we skip infinite & NaN value before, and consider support it soon.

Another question: after the support, u'll get a price value "Infinity"(string) in json, seems u need also handle it in upper logic?

@imbajin imbajin changed the title HugeGraph could not process Double.Inifnity value. [Bug] HugeGraph could not process Double.Inifnity value. Aug 17, 2021
@imbajin imbajin changed the title [Bug] HugeGraph could not process Double.Inifnity value. [Bug] HugeGraph could not process Inifnity/NaN value in float/double Aug 17, 2021
@imbajin
Copy link
Member

imbajin commented Aug 18, 2021

@zhengyingying, hi, I submit a PR for this issues, u can cherry-pick it or copy the DataType code directly, then test in client & your cases to check if it's suitable.

Hope to get your reply & suggestion. THX

@zhengyingying
Copy link
Author

@imbajin Thanks for your reply. We will test it in our cases.

@imbajin
Copy link
Member

imbajin commented Aug 23, 2021

Any response for the linked PR? (Need to ensure it's suitable for user to use)

Wait for your test result, THX ~ ⏲️

@imbajin
Copy link
Member

imbajin commented Sep 16, 2021

Due to long time with no response, we merge the linked pr first.

Looking forward to your follow-up feedback on this issue (and reopen it if need)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants