Fork me on GitHub
#datomic
<
2017-09-26
>
mkvlr08:09:29

is there a way to use datomic/entity and add additional computed data on the “map”? We noticed that assoc throws. We can merge a new map with the attributes with the entity but then we lose the laziness that datomic/entity provides.

dimovich09:09:49

@hmaurer @dominicm @benha thanks for the tips regarding the invitation code generation

benh10:09:17

@mkvlr you could reify IAssoc to allow local assoc calls, but pass through gets to underlying EntityMap

benh10:09:03

but be aware that this does not transact the new data to datomic

benh10:09:24

which is likely to cause confusion

mkvlr10:09:16

sure, I’m aware it doesn’t transact

mkvlr10:09:50

any other best practices to add computed data to an entity? Not put it on the entity at all but use another thing?

hmaurer10:09:27

@mkvlr silly question, but do you really need to keep the map lazy?

hmaurer10:09:02

and do you need to add computed data deep inside the map, or only at the top level?

mkvlr10:09:11

@hmaurer only at the top level. I’m new to datomic, so I’m asking for best practices

mkvlr10:09:34

what if I touch the entity, will I still be able to lazily load relations reachable from it?

hmaurer10:09:31

mmh I am not sure, but let’s try it

hmaurer10:09:32

just a sec

hmaurer11:09:37

mmh no, it looks like touching loads the whole thing

hmaurer11:09:53

> Touches all of the attributes of the entity, including any component entities recursively.

hmaurer11:09:02

for components at least

hmaurer11:09:44

I am new to Datomic too so I am just trying things out, but it looks like (into {} your-entity) will return a PersistentArrayMap at the top level, but leave EntityMaps for nested entities (which are lazy)

mkvlr11:09:30

@hmaurer thanks! that’s great then, I’ll just touch 🙏

tengstrand13:09:12

@favila yes, I realized my mistake, thanks!

hmaurer13:09:05

@favila do you know if datomic will attempt to optimise queries, and if yes, how? e.g. are clauses re-ordered on datalog queries?

favila13:09:42

Datomic does some optimizations, but clause reordering is not one of them. I think they may never add that optimization for philosophical reasons

pbostrom15:09:55

is anyone familiar with this stack trace, and what the cause might be? I see it when I transact my schema using datomic.api

11:16:24 ERROR         nREPL-worker-0 core.client                        AMQ214016: Failed to create netty connection
java.nio.channels.UnresolvedAddressException
        at sun.nio.ch.Net.checkAddress(Net.java:101)
        at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:622)
        at io.netty.channel.socket.nio.NioSocketChannel.doConnect(NioSocketChannel.java:208)
        at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.connect(AbstractNioChannel.java:203)
        at io.netty.channel.DefaultChannelPipeline$HeadContext.connect(DefaultChannelPipeline.java:1226)
        at io.netty.channel.AbstractChannelHandlerContext.invokeConnect(AbstractChannelHandlerContext.java:549)
        at io.netty.channel.AbstractChannelHandlerContext.connect(AbstractChannelHandlerContext.java:534)
        at io.netty.handler.ssl.SslHandler.connect(SslHandler.java:438)
        at io.netty.channel.AbstractChannelHandlerContext.invokeConnect(AbstractChannelHandlerContext.java:549)
        at io.netty.channel.AbstractChannelHandlerContext.connect(AbstractChannelHandlerContext.java:534)
        at io.netty.channel.ChannelDuplexHandler.connect(ChannelDuplexHandler.java:50)
        at io.netty.channel.AbstractChannelHandlerContext.invokeConnect(AbstractChannelHandlerContext.java:549)
        at io.netty.channel.AbstractChannelHandlerContext.connect(AbstractChannelHandlerContext.java:534)
        at io.netty.channel.AbstractChannelHandlerContext.connect(AbstractChannelHandlerContext.java:516)
        at io.netty.channel.DefaultChannelPipeline.connect(DefaultChannelPipeline.java:970)
        at io.netty.channel.AbstractChannel.connect(AbstractChannel.java:215)
        at io.netty.bootstrap.Bootstrap$2.run(Bootstrap.java:166)
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:408)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:402)
        at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:140)
        at java.lang.Thread.run(Thread.java:745)

favila15:09:31

You sure it is datomic.api and not datomic.client?

favila15:09:43

looks like it can't resolve an address

favila15:09:50

hostname somewhere is wrong

pbostrom15:09:18

yes, datomic.api. it's coming from ActiveMQ, there should be no hostname resolution required for the transaction (uri is DDB which looks up the transactor IP in Dynamo)

favila15:09:30

what is in transactor host= and alt-host= ?

pbostrom15:09:06

ah, alt-host has some garbage, thanks for the tip

phillipc17:09:15

does anyone know if the :string type for an attribute has any sort of character limit? I cannot seem to find anything in the documentation that would suggest there is. Thanks

favila17:09:29

@phillipc AFAIK no intrinsic limit. you will probably run into platform limits first (e.g. string too long for java or fressian)

favila17:09:46

but it's not a good idea to put big values into a datomic db

favila17:09:47

consider writing a uuid-named file to a blob store (e.g. s3) and storing the reference in the db as the value

phillipc17:09:53

I doubt it will be large enough for a blob, I'm just converting some sql data stores and was making sure that :string could handle it Thank you for the quick response!

favila17:09:21

oh, yeah it will handle that fine