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

更新节点前如何避免写前读?

Open qingchengliu opened this issue 6 years ago • 3 comments

Expected behavior 期望表现

更新节点时,避免写前读

Steps to reproduce the problem 复现步骤

User = graph.schema().vertexLabel("User").properties("uid", "is_black", "is_frozen", "lmtime").primaryKeys("uid").nullableKeys("is_black", "is_frozen").ifNotExist().create()
Merchant = graph.schema().vertexLabel("Merchant").properties("mch_name", "mch_no", "lmtime").primaryKeys("mch_no", "mch_name").ifNotExist().create()

u = graph.addVertex(T.label, "User", "uid", 10086, "lmtime", "2020-02-04 00:00:00", "is_black", 1, "is_frozen", 0)
m = graph.addVertex(T.label, "Merchant", "mch_no", "10001", "lmtime", "2020-06-03 00:00:00", "mch_name", "测试2")
m.addEdge("MCH_CONN", u, "lmtime", "2020-02-03 00:00:00")
g.V().has("User", "uid", 10086).union(bothE(), bothE().bothV()).dedup()

此时我想更新 uid = 10086的lmtime,使用的是覆盖写

u = graph.addVertex(T.label, "User", "uid", 10086, "lmtime", "2020-07-04 00:00:00")

如果我使用覆盖写,原节点的is_black、is_frozen属性将会丢失 我应该怎么避免写前读且更新节点信息时不会丢失原有属性

qingchengliu avatar Jul 06 '20 04:07 qingchengliu

@qingchengliu 属性更新包括:

javeme avatar Jul 06 '20 08:07 javeme

@qingchengliu 属性更新包括:

我知道节点的id,但我不知道改id在不在数据库中(使用的是自定义id)。 如果按上述的方式,我需要先调用client的 appendVertexProperty,再根据返回的状态码(NoSuchElementException)来判断是否需要执行 addVertex。 这种方式会在发生写之前执行多了一次读操作(发生了多一次http请求)。 请问是否有类似于 insertOrUpdate 的接口(或者后续会不会开发此接口)

qingchengliu avatar Jul 09 '20 08:07 qingchengliu

Due to the lack of activity, the current issue is marked as stale and will be closed after 20 days, any update will remove the stale label

github-actions[bot] avatar Jul 22 '21 21:07 github-actions[bot]