如何通过 SPARQL 为更新生成 UUID [英] How to generate UUIDs for updates via SPARQL
问题描述
使用通过 SPARQL 端点访问的 RDF 数据库,生成新的 UUID IRI 并将它们用于新资源的最佳方法是什么?
Using an RDF database, accessed via a SPARQL endpoint, what's the best way of generating new UUID IRIs and using them for new resources?
以下是我尝试过的一些方法的概述.我分享这个是因为我希望找到这个问题的答案.我最喜欢的是最后一种方法,但我认为它仍有待讨论.
Here is an overview of some approaches I've tried. I am sharing this because I would have liked to find this question answered. My favourite is the last approach, but I'd say it's still up for debate.
- 亲:快
- con:您无法确定 UUID 在数据库中是唯一的.不过发生碰撞的可能性很小.
- pro:您可以合理地确定 UUID 在数据库中是唯一的(除了在并发更新中添加的)
- 缺点:很慢
查询:SELECT (UUID() as ?id) WHERE{}
- pro:UUID 保证在商店中是唯一的(即尚未使用)
- con:这是一个额外的请求(但它是一个快速的请求)
查询(返回 1000 个结果行):
Query (returns 1000 result rows):
SELECT (UUID() as ?id) WHERE {
VALUES ?index1 { 0 1 2 3 4 5 6 7 8 9 }
VALUES ?index2 { 0 1 2 3 4 5 6 7 8 9 }
VALUES ?index3 { 0 1 2 3 4 5 6 7 8 9 }
}
- pro:如果 >> 每个 UUID 可能最快需要 1 个
- pro:UUID 保证在商店中未使用
- 缺点:这种方法需要更多的客户端编程
- 并且:这是一个不寻常的查询,有没有更好的方法来实现这一点?
相关:
推荐答案
根据 AndyS 的评论,我决定再看一遍并调整我的期望:你必须每秒生成 10 亿个 UUID大约 85 年才能达到 50% 的一次或多次碰撞概率.因此,变体 1 是最好的:
Following AndyS's comment, I decided to look that up again and adjust my expectations: you have to generate 1 billion UUIDs per second for about 85 years to reach a 50% probability of one or more collisions. Therefore, Variant 1 is best:
在客户端生成一个 UUID 并在更新请求中使用它.
Generate a UUID in the client and use it in the update request.
这篇关于如何通过 SPARQL 为更新生成 UUID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!