dtype-next icon indicating copy to clipboard operation
dtype-next copied to clipboard

Structs with pointer array field throws exception in `dt-struct/define-datatype!`

Open phronmophobic opened this issue 1 year ago • 0 comments

dt-struct/define-datatype! will throw an Exception if any of the fields has :datatype :pointer and :n-elems is greater than one.

Below is a minimal repro:

> (dt-struct/define-datatype! ::HasPointerArray
  [{:n-elems 10, :datatype :pointer, :name :ptrs}])
Execution error (AssertionError) at tech.v3.datatype.struct/create-accessors$fn (struct.clj:332).
Assert failed: Datatype :pointer created invalid acccessr
(and (instance? IFn$OOLO read-fn) (instance? IFn$OOLOO write-fn))
> (prn *e)
#error {
 :cause "Assert failed: Datatype :pointer created invalid acccessr\n(and (instance? IFn$OOLO read-fn) (instance? IFn$OOLOO write-fn))"
 :trace
 [[tech.v3.datatype.struct$create_accessors$fn__16140 invoke "struct.clj" 332]
  [clojure.lang.PersistentVector reduce "PersistentVector.java" 418]
  [clojure.core$reduce invokeStatic "core.clj" 6964]
  [clojure.core$reduce invoke "core.clj" 6947]
  [tech.v3.datatype.struct$create_accessors invokeStatic "struct.clj" 226]
  [tech.v3.datatype.struct$create_accessors invoke "struct.clj" 222]
  [tech.v3.datatype.struct$define_datatype_BANG_ invokeStatic "struct.clj" 369]
  [tech.v3.datatype.struct$define_datatype_BANG_ invoke "struct.clj" 347]
  ...]}
nil

Workaround: Using :int64 instead of :pointer is a sufficient workaround for my use case. I don't actually need to access the pointer array field on this struct for my use case anyway.

phronmophobic avatar Sep 24 '24 21:09 phronmophobic