Allow non-numbers as entity ids
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 25/100
Hướng nghiên cứu
Bắt đầu bằng cách xem xét hàm entid và các giao thức IDB, ISearch và IIndexAccess được triển khai một phần trong adapter MapToDatascript được mô tả trong issue. Kiểm tra pull request được liên kết và phần thảo luận của issue trước đó trước khi quyết định liệu các ID thực thể linh hoạt có phù hợp với mô hình dữ liệu hay không; để hoàn tất, cần giải quyết thiết kế và kiểm thử mọi hệ quả trên tất cả các nguồn dữ liệu được hỗ trợ.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
This has come up in a couple of issues before, both by developers being against it and for it. To wit: https://github.com/tonsky/datascript/pull/8#issue-32457706 https://github.com/tonsky/datascript/issues/56#issuecomment-73641241
Here's my case for a dynamic entity id type, rather than enforcing number?, as is done in the entid function.
I tried to integrate the high churn real-time data stream that my process receives and updates a in-memory map with. This map has something like the following, pretty common structure:
{ "key1"
{ "attrA" "foo", "attrB" "bar", ... }
"key2"
{ "attrB" "foo", "attrX" "bar", ... }
}
It was easy enough to hook this map up to Datascript (Spossiba Tonsky, you ЯOCK! Datomic in contrast doesn't have published protocols...) by creating a MapToDatascript adapter, just implementing (partially, for the time being) IDB, ISearch, and IIndexAccess, and then query it like so, joining it with a real datascript DB:
(ds/q '[
:find (pull $ ?e [*]) (pull $m ?attr-x [*])
:in $ $m
:where [$ ?e :attr-x ?attr-x]]
@ds-db my-map-adapter)
Except, I had to tweak datascript's entid function - in fact simplifying it - in order to allow string eids, or just any type, for that matter.
Now I can of course create some number out of thin air and attach it to the entity to serve as the entity id, but that is another level of mapping that has to go on on every change of my data, which is thousands per second. What's worse, I now have another id that I need to keep consistent in the face of a machine going down and some failover machine taking over. That complicates things quite a bit.
So why not keep entity ids as flexible - for non-datascript data sources at least - as the datalog queries themselves, that don't care if your patterns are shaped [?e ?a ?v] or something completely different.
That way, integrating datascripts datalog engine with arbitrary data sources will be a lot easier, and depending on the case, more performant.
Is this a route you'd like to go in Datascript? Or is the datascript data model you want other sources to adhere to? In the former case, I'd have a more closed look at the sources and wrap this in a proper pull request, after checking and testing all the ramifications.
- Ngôn ngữ chính
- Clojure
- Star
- 5.8k
- Fork
- 318
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của tonsky/datascript
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
tonsky/datascript#498 · 1 bình luận ·
-
Datascript MCP Server Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 10/100
tonsky/datascript#489 ·
-
Stack overflow when transacting :db.type/tupleAttrs with a :db.type/ref attr through :db.fn/call Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
tonsky/datascript#483 · 2 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
tonsky/datascript#470 · 1 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
tonsky/datascript#441 · 1 bình luận · 3 reaction ·
Tất cả issue của tonsky/datascript
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
-
.Team/Metabot Priority:P3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
needs triage
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
scalar-labs/scalar-jepsen#222 · 1 bình luận ·