Fork me on GitHub
#datomic
<
2022-10-28
>
Daniel Jomphe14:10:00

Is our IDE's pretty-printing shortening what we see of what Datomic stores about these floats? Or are they really rounded up like this by Datomic?

Daniel Jomphe15:10:57

• The rounding up is normal (pic below), but is there also some truncation, or • is there no truncation and only the IDE's pretty-printing fooling us (pic above)?

favila15:10:42

datomic has both double and float types, but clojure literals and math functions only use doubles (floats will be widened to doubles).

favila15:10:52

It looks to me like the input is a double but the schema type is float

favila15:10:59

(float -72.72186717063904)
=> -72.72187

favila15:10:37

so what is being printed in the datom is likely a float

favila15:10:12

that datom value will probably be widened at some point if you manipulate it at all, and will look like this:

favila15:10:16

(double (float -72.72186717063904))
=> -72.72187042236328

favila15:10:00

I strongly suspect you used :db.type/float but you actually wanted :db.type/double

Daniel Jomphe15:10:53

Yeah, this is what my IDE prints, gonna look if it's true that our tx value was a double, not a float

Daniel Jomphe15:10:20

Yes, our schema

favila15:10:44

yeah, so the double value in the transaction was narrowed to float to fit into the datom

favila15:10:14

and what you are printing in the datom is a float (a boxed Float object)

favila15:10:01

You can confirm with (-> mydatom :v class)

Daniel Jomphe15:10:01

Ok, so the browser client lib gives us a Number, which is a 64 bit floating point, which we converted to float, a 32 bit floating point, due to our schema being float instead of double...

Daniel Jomphe15:10:28

And some areas of our code also convert it to float explicitly. We'll have to remodel, I suppose.

Daniel Jomphe15:10:46

I knew Datomic was doing what it should. phew! 😅 Thanks a lot Francis!

favila15:10:21

That’s a good point, if this value gets into a browser it’s going to be widened no matter what.

favila15:10:56

you probably just want doubles all the way through

☺️ 2
Daniel Jomphe15:10:57

• The rounding up is normal (pic below), but is there also some truncation, or • is there no truncation and only the IDE's pretty-printing fooling us (pic above)?

dogenpunk17:10:07

Sorry for the cross post, but this is probably the better forum. Does Datomic Cloud not run Clojure 1.11? I’m getting “Unable to resolve symbol: parse-uuid in this context” when deploying an Ion system. I’ve tried adding an explicit dependency on 1.11 with the same results.

dogenpunk17:10:16

Ok. Weird. I just created this stack yesterday.

onetom01:12:05

how was this issue solved, btw? i usually see this kind of behaviour, if i have some .class files getting into the bundled ion code, which are older, than their corresponding source code. the bundle is a zip file and somehow all the file creation and modification dates can become the same date-time, which is the creation time of the zip file itself. in such case, clojure would prefer to load the *.class file, instead of compiling its corresponding source file. to debug this, u should try to clojure -M:ion-dev "{:op :push :uname whatever :creds-profile <your-aws-profile> :region <your-region>}", then look at unzip -l .datomic-ions/datomic/apps/<:app-name from ion-config.edn>/unrepro/whatever.zip| less` it shouldn't have any *.class files in it

dogenpunk17:12:35

@U086D6TBN The issue is that creating a new stack from the AWS Marketplace page results in a stack using an older template. If memory serves, updating the Marketplace page is a slow process. I haven’t gotten around to updating my system yet, but I’m relatively confident that updating the system will resolve this.

onetom04:12:52

ah, i see. i haven't used the marketplace facilities for a long time. we built some clojure tooling (using the cognitect aws lib) to drive cloudformation create/delete/update operations. this is how our cloudformation "control center" looks like a in a REPL NS:

;; Common stack operations
(comment
  (defn $stack [] ($env cfg/dcs))       ;; Storage
  (defn $stack [] ($env cfg/dcs-xxx))  ;; Compute
  (defn $stack [] ($env cfg/apigw))
  ...

  (-> ($stack) (grep> "aud") #_sort)
  (-> ($stack) create-stack req!)
  (-> ($stack) update-stack req!)
  (-> ($stack) (stack-completed? 10))
  (-> ($stack) describe-stack req! :StackStatus)
  (-> ($stack) stack-outputs req!)
  (-> ($stack) stack-outputs req! (grep> "node"))
  (-> ($stack) stack-resources req! #_(resources-with-status "PROGRESS"))
  (-> ($stack) stack-resources req! (grep> "instance"))

  (-> ($stack) stack-resources req! vals (->> (grep #"endpoint" :LogicalResourceId))
      (set/project [:LogicalResourceId :PhysicalResourceId]) print-table)

  (-> ($stack) (merge DescribeStackEvents) req! stack-events-summary
      (->> (take 20)) print-table)

  ;; (-> ($stack) delete-stack req!)

  )