Allow non-numbers as entity ids
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 25/100
Línea de trabajo
Comienza revisando la función entid y los protocolos IDB, ISearch e IIndexAccess parcialmente implementados en el adaptador MapToDatascript descrito en el issue. Revisa el pull request enlazado y la discusión del issue anterior antes de decidir si los IDs de entidad flexibles encajan en el modelo de datos; para darlo por terminado, hay que resolver el diseño y probar todas las ramificaciones en todas las fuentes de datos compatibles.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Clojure
- Estrellas
- 5.8k
- Forks
- 318
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de tonsky/datascript
-
Dificultad 4/5 3-5 días Aptitud para principiantes 42/100
tonsky/datascript#498 · 1 comentario ·
-
Datascript MCP ServerAbierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 10/100
tonsky/datascript#489 ·
-
Stack overflow when transacting :db.type/tupleAttrs with a :db.type/ref attr through :db.fn/callAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
tonsky/datascript#483 · 2 comentarios ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
tonsky/datascript#470 · 1 comentario ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
tonsky/datascript#441 · 1 comentario · 3 reacciones ·
Todos los issues de tonsky/datascript
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100