Indexes on vectors return surprising results
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
Direzione di ricerca
Inizia eseguendo i due snippet di riproduzione e tracciando la ricerca d/datoms :avet per l’attributo :path indicizzato. Confronta gli input di tipo vettore, lista e sequenza con e senza il datom :children aggiuntivo; il lavoro è completato quando la ricerca si comporta in modo coerente e corrisponde solo ai valori indicizzati previsti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
I'm seeing some odd behavior with indexed vectors. I thought this might have been introduced in 1.6.4, but it was also happening in 1.6.3. Given
(let [db (-> (d/empty-db {:path {:db/index true}})
(d/db-with [{:path [1 2]}
{:path [1 2 3]}]))]
(for [v [;; variations on 1, 2
[1 2]
(list 1 2)
(butlast [1 2 3])
;; variations on 1, 2, 3
[1 2 3]
(list 1 2 3)
(butlast [1 2 3 4])]]
[v
(->> (d/datoms db :avet :path v)
(mapv :e))]))
I'd expect this to only find entity ids for the first and fourth values of v, i.e. for the vectors, not the lists or sequences. However, this is what is returned.
;; => ([[1 2] [1]]
;; [(1 2) [1]]
;; [(1 2) []]
;; [[1 2 3] [2]]
;; [(1 2 3) []]
;; [(1 2 3) [2]])
It's particularly odd that first list, (list 1 2) returns an entity id but (list 1 2 3) doesn't. And contrarily that the first sequence (butlast [1 2 3]) doesn't return an entity id but (butlast [1 2 3 4]) does.
As I was playing with this I also ran across another odd variation. The presence of other datoms seems to affect the result.
(let [db (-> (d/empty-db {:path {:db/index true}
;; this attribute is new
:children {:db/valueType :db.type/ref
:db/cardinality :db.cardinality/many}})
(d/db-with [{:db/id "a"
:path [1 2]}
{:db/id "b"
:path [1 2 3]}
;; this datom is new
[:db/add "a" :children "b"]]))]
(for [v [;; variations on 1, 2
[1 2]
(list 1 2)
(butlast [1 2 3])
;; variations on 1, 2, 3
[1 2 3]
(list 1 2 3)
(butlast [1 2 3 4])]]
[v
(->> (d/datoms db :avet :path v)
(mapv :e))]))
;; => ([[1 2] [1]]
;; [(1 2) [1]]
;; this result has changed
;; [(1 2) [1 2]]
;; [[1 2 3] [2]]
;; [(1 2 3) []]
;; [(1 2 3) [2]])
Here the result is almost the same, except that whereas before when v was (list 1 2), d/datoms returned nothing. Now, with the other datom, it returns both entity ids. Very odd!
The easiest fix is, on the calling side, to be careful to pass vectors not sequences. That's what we'll do in our project, but I wanted to report the issue anyway.
- Lingua principale
- Clojure
- Stelle
- 5.8k
- Fork
- 318
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di tonsky/datascript
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 42/100
tonsky/datascript#498 · 1 commento ·
-
Datascript MCP Server Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 10/100
tonsky/datascript#489 ·
-
Stack overflow when transacting :db.type/tupleAttrs with a :db.type/ref attr through :db.fn/call Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
tonsky/datascript#483 · 2 commenti ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
tonsky/datascript#441 · 1 commento · 3 reazioni ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
tonsky/datascript#434 · 2 commenti ·
Tutte le issue di tonsky/datascript
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
-
.Team/Metabot Priority:P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
needs triage
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
scalar-labs/scalar-jepsen#222 · 1 commento ·