incubator-hugegraph icon indicating copy to clipboard operation
incubator-hugegraph copied to clipboard

addV() returns wrong vertex ID

Open kfirdado opened this issue 7 years ago • 4 comments

Expected behavior 期望表现

Using JavaScript Gremlin client, I run a simple addVertex query:

const test = await g.addV('Test')
  .property('foo', 123)
  .property('bar', 456)
  .next();
  
console.log(test.value.id);

I expect the returned ID to be the same as the vertex ID.

Actual behavior 实际表现

The returned ID is different from the actual ID of the vertex: Returned: 259663873303379970 Actual: 259663873303379968

Steps to reproduce the problem 复现步骤

Run the above query.

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

graph.schema().propertyKey('foo').asInt().ifNotExist().create()
graph.schema().propertyKey('bar').asInt().ifNotExist().create()
graph.schema().vertexLabel('Test').properties('foo', 'bar').ifNotExist().create()

Specifications of environment 环境信息

  • hugegraph version: v0.10.4
  • operating system: Ubuntu 18.04.3 LTS
  • hugegraph backend: RocksDB

kfirdado avatar Nov 14 '19 13:11 kfirdado

The root cause is that javascript does not support long variables.

If you have to use javascript, you can use the primary key id or a custom id (non-long). If you can try other ways, hugegraph-client or hugegraph-studio is an alternative. The hugegraph-client is a java driver, which supports long type. The hugegraph-studio is a front-end display platform, we convert long to string when returning it to the front end.

Linary avatar Nov 15 '19 07:11 Linary

I cannot use custom or primary key IDs in my project. I also find it strange that the root cause is javascript support for long, as I do get a "long" number, just not the correct one.

However, I figured out that setting snowflake.force_string=true in hugegraph.properties does convert all IDs to strings, and it is now working as expected.

Would be great if you could also support UUID and not just long IDs.

kfirdado avatar Nov 17 '19 15:11 kfirdado

Yeap! The config option snowflake.force_string=true will convert all id to string. HugeGraph support UUID, but need use customizedUUID() that you may cannot use it.

Linary avatar Nov 19 '19 07:11 Linary

I mean that UUIDs will be automatically manages, same as long, but with UUID. something like: gremlin.tinkergraph.vertexIdManager=UUID

kfirdado avatar Nov 19 '19 10:11 kfirdado