I think get/put are pretty fast but there is also the possibility of slicing arrays in and out of nio buffers on the java side which maybe could be faster if you want to modify many values and have some memory to spare.
For example if you have a nio buffer several hundred megabytes big and you want to change every value on the java/clojure side then you could use a java array that's one or a few megs in size and continously fill that upp from the buffer, change it's values and then write it back. Don't know if it's actually faster but it sounds reasonable since it will save you millions of method calls. On the native side you should be able to get a direct pointer to the memory in the buffer so you can just go crazy and do whatever you like (hello segfault) ;) On Mar 24, 3:17 pm, Konrad Hinsen <konrad.hin...@fastmail.net> wrote: > On 24.03.2010, at 11:22, mac wrote: > > > With regards to copying of data, clj-native expects nio buffers to be > > used as input where a native function requires a typed pointer. These > > buffers can be allocated outside of the JVM heap specifically to avoid > > copying. For example (ByteBuffer/allocateDirect 1000) will allocate > > 1000 bytes outside of the JVM heap, which means it does not have to be > > copied during native interop because the GC will never move it. > > OK, that clarifies how it works, thanks! > > The essential question thus is how fast get and put operations to a direct > buffer are, compared to an access to an array element. If the difference is > not important, one could indeed use direct buffers for storing big data > objects and access them efficiently from both sides of the interface. > > Konrad. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en To unsubscribe from this group, send email to clojure+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.