Skip to content

type-pointer fails when called with class#2

Open
orb wants to merge 1 commit intouncomplicate:masterfrom
orb:patch-1
Open

type-pointer fails when called with class#2
orb wants to merge 1 commit intouncomplicate:masterfrom
orb:patch-1

Conversation

@orb
Copy link
Copy Markdown

@orb orb commented May 6, 2026

In neanderthal, map-vector calls this function with a java class such as Byte/TYPE, however the case function here effectively is comparing the class type passed in with (effectively) (symbol "BYTE/Type") and returns null, causing map-vector to fail in all cases for me.

Adding the cond at the end, a pattern I copied from similar comparisons in neanderthal, fixes this so that map-vector works as intended.

I left the symbol comparisons in because maybe there is actually a use case I'm not aware of in which that is desirable, but I have to imagine we would want to remove them.

@orb
Copy link
Copy Markdown
Author

orb commented May 6, 2026

Here's` an example before:

> (uncomplicate.clojure-cpp/type-pointer :byte)
#function[uncomplicate.clojure-cpp/fn--8695/G--8571--8704]

> (uncomplicate.clojure-cpp/type-pointer Byte/TYPE)
nil

> (uncomplicate.clojure-cpp/type-pointer (symbol "Byte/TYPE"))
#function[uncomplicate.clojure-cpp/fn--8695/G--8571--8704]

And here is the output with this fix:

> (uncomplicate.clojure-cpp/type-pointer :byte)
#function[uncomplicate.clojure-cpp/fn--8695/G--8571--8704]

> (uncomplicate.clojure-cpp/type-pointer Byte/TYPE)
#function[uncomplicate.clojure-cpp/fn--8695/G--8571--8704]

> (uncomplicate.clojure-cpp/type-pointer (symbol "Byte/TYPE"))
#function[uncomplicate.clojure-cpp/fn--8695/G--8571--8704]

@orb
Copy link
Copy Markdown
Author

orb commented May 6, 2026

For reference, this is how it's affecting map-vector.

❯ dd if=/dev/random of=/tmp/test-data bs=1024 count=1
1+0 records in
1+0 records out
1024 bytes (1.0 kB, 1.0 KiB) copied, 0.000791044 s, 1.3 MB/s

Before:

> (dim (map-vector native-byte (random-access "/tmp/test-data")))
Execution error (NullPointerException) at uncomplicate.neanderthal.internal.cpp.structures/map-channel (structures.clj:2901).
Cannot invoke "clojure.lang.IFn.invoke(Object)" because the return value of "clojure.lang.IFn.invoke(Object)" is null> (dim (map-vector native-byte (random-access "/tmp/test-data")))
Execution error (NullPointerException) at uncomplicate.neanderthal.internal.cpp.structures/map-channel (structures.clj:2901).
Cannot invoke "clojure.lang.IFn.invoke(Object)" because the return value of "clojure.lang.IFn.invoke(Object)" is null

After:

> (dim (map-vector native-byte (random-access "/tmp/test-data")))
1024

In neanderthal, `map-vector` calls this function with a java class such as Byte/TYPE, however the case function here effectively is comparing the class type passed in with (effectively) `(symbol "BYTE/Type")` and returns null, causing map-vector to fail in all cases for me.

Adding the cond at the end, a pattern I copied from similar comparisons in neanderthal, fixes this so that `map-vector` works as intended.

 I left the symbol comparisons in because maybe there is actually a use case I'm not aware of in which that is desirable, but I have to imagine we would want to remove them.
@blueberry
Copy link
Copy Markdown
Member

Thank you. This was already on my list and will be included in the next update in about two weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants