-
Notifications
You must be signed in to change notification settings - Fork 587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Use sun.misc.Unsafe in pointers and not in indexers #408
base: master
Are you sure you want to change the base?
WIP: Use sun.misc.Unsafe in pointers and not in indexers #408
Conversation
This is merely duplicating what we already have in Indexer. If this is all the functionality you need, please use Indexer instead. |
I'm using Indexer as you suggested, but maybe I'm missing something: isn't it the Indexers just a layer on top of array/buffer/pointer? Why are they accessing internal pointer structures using Unsafe, shouldn't the Indexers just call pointer.get()/pointer.put()? |
Another example: I'm using the HDF5 JavaCPP preset and it takes and returns pointers objects, why I should wrap the pointer in an Indexer to access its data? I would like just to consider the pointer as a basic data storage (just like array or buffers), not a Indexer with a shape and indexing. |
Yes, Indexer is basically a wrapper for arrays, buffers, and pointers, and we need to use |
I cannot find where Unsafe is used to access arrays or buffers: I'm looking at |
That's what If you can do everything you need with
https://github.com/bytedeco/javacpp/blob/master/src/main/java/org/bytedeco/javacpp/indexer/ByteArrayIndexer.java and we would also need it for |
4abc7de
to
0d92845
Compare
OK, I see: for primitive pointers (whose element is a primitive in Java) we can actually use Unsafe for get() and put(), but for more complicated pointers (for any struct for example |
Right, the definition of classes like If you're just worried about creating an instance of |
I was actually more concerned from an architecture point of view: I see now Pointers in general have been created for the JavaCPP bridge purposes, so to account for structs/classes/unions in C++. And have Indexers just a layer on top of arrays/Buffers/Pointers/MemoryHandles/etc. for shaping and indexing purposes. |
I'm repeating myself, but we need |
Also, don't forget to consider what to do when |
sun.misc.Unsafe
is used in raw indexer, but it should be really used in Pointers: the indexers are just a layer on top of array/buffer/pointers.Still unfinished as it is not clear how to handle bool, clong, size_t pointers.