Add explicit cloning to query2
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
Direzione di ricerca
Inizia individuando l’implementazione di query2 e verificando in che modo i suoi transforms clonano o consumano i valori, quindi confronta questo comportamento con l’implementazione Python. Il lavoro è completo quando la semantica della clonazione o della gestione dei riferimenti è concordata, implementata in modo coerente e coperta da test per i casi descritti nell’issue.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
Currently every time we reference a variable we are cloning the whole value to guarantee that the value of the variable cannot be modified in some function without re-assigning it.
If we had explicit cloning built-in to the language so cloning is only done when necessary querying would probably be insanely faster.
The python implementation seems to be inconsistent as some transforms consumes the data and others don't and the query2 language doesn't seem to clone variables so things can get very complicated. Will have to investigate further on this though.
Suggestions on how it could be solved
1. New default is to assume mutable reference
clone(data) returns cloned data
*data to specify that variable will be consumed and undefined after this. Needed to avoid unnecessary cloning
Will not work because here the same value can be in multiple variables, breaks ownership rules.
events1 = query_bucket("bucket");
events2 = filter_keyvals(events1, "key", ["val"]);
# OK, BUT this will modify events1 so it might be unclear to the user what is occuring
events3 = filter_keyvals(clone(events1), "key", ["val"]);
# OK, at this point both events1 and events2 are defined
events4 = filter_keyvals(*events1, "key", ["val"]);
# OK, at this point events1 is undefined as it was consumed by *events1
2. New default is to assume immutable reference
clone(data) returns cloned data
*data to specify that variable will be consumed and undefined after this. Needed to avoid unnecessary cloning.
Will not work because here the same value can be in multiple variables, breaks ownership rules.
events1 = query_bucket("bucket");
events2 = filter_keyvals(events1, "key", ["val"]);
# Error: Not possible to pass events1 into filter_keyvals as it needs mutable data
events3 = filter_keyvals(clone(events1), "key", ["val"]);
# OK, at this point both events1 and events2 are defined
events4 = filter_keyvals(*events1, "key", ["val"]);
# OK, at this point events1 is undefined as it was consumed by *events1
3. New default is to assume consume
clone(data) returns cloned data
&data to specify that variable will be used as a reference
events1 = query_bucket("bucket");
events2 = filter_keyvals(events1, "key", ["val"]);
# OK as it is consumed by default, but after this line it will be consumed so we need to either fist clone it or query the bucket again
events1 = query_bucket("bucket");
events3 = filter_keyvals(clone(events1), "key", ["val"]);
# OK, at this point both events1 and events2 are defined
events4 = filter_keyvals(*events1, "key", ["val"]);
# OK, at this point events1 is undefined as it was consumed by *events1
4. Keep as is, but introduce some pre-processing step which does reference counting before executing
Since we don't have any loops or non-transform function support this would be possible to do, but still a bit messy to get working. The result might not be perfect either.
- Lingua principale
- Rust
- Stelle
- 315
- Fork
- 97
- Merge medio
- 1g 10h
- PR unite (30g)
- 61
Preparare l'ambiente
Non abbiamo ancora controllato i file di configurazione di questo progetto. Parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
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 ActivityWatch/aw-server-rust
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
ActivityWatch/aw-server-rust#763 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
ActivityWatch/aw-server-rust#724 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
ActivityWatch/aw-server-rust#717 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 68/100
ActivityWatch/aw-server-rust#714 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
aw-sync: no stored cursor — resume-from-destination silently never syncs late-arriving eventsApertabug
Difficoltà 5/5 Più di una settimana Idoneità per principianti 45/100
ActivityWatch/aw-server-rust#696 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di ActivityWatch/aw-server-rust
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
linebender/parley#849 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
boxlite-ai/boxlite#1729 ·
I maintainer di solito rispondono entro 1 giorno
-
external
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
langchain-ai/docs#6255 ·
I maintainer di solito rispondono entro 1 giorno
-
P2 testing
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
I maintainer di solito rispondono entro 1 giorno