2 questions: Multidimensional array and JNI


I'm working with the team of Jean-Francois Boulicaut (LIRIS, INSA Lyon) to implement their algorithms in Knime.

One of this (d-peeler) deals with multidimensional boolean matrix in input.

Multi-array is not implement as basic type in Knime. So I first wanted to make my own type, but Java don't really implement multi-array effenciently !
So do you now how I can implement multi-array in Knime ? Does a good library exist ?

Second question. The algorithm has been developed in C++, so we plan tu use JNI and launch the c++ algorithm executable in Java.
Periodically, 'exec.checkCancelled' is checked, and if necessary, the c++ executable is "destroy".
Does this method be a good way if we don't want to rewrite the algorithm (especially if that's no way to use correctly multidimensional array).


Rémi Thévenoux

Hi Rémi,

regarding the multi-dimensional boolean matrix: What's wrong with boolean[][]...[]? Are you concerned about memory efficiency? (Not sure how that's realized in a JVM). Anyway, as another source of reference I suggest to have a look at java.util.Bitset, which is flexible length bit container. It has many convenience methods (for instance for masking). If you then look for multi-dimensional arrays, you will probably have to write this yourself (wrapping arrays of BitSets, also to ensure size constraints).

I'm not sure what's the best way of canceling an JNI invocation, but I'd like to add that you should not only consider exec.checkCanceled but also progress information (that's probably harder to implement - it pays off though).


Hi Bernd,

I can't use boolean[][]...[] because i don't now the number of dimension (it depend on the data set).
Moreover I saw on some discussion (old but certainly not out of date) that Java is very slow with standard multi-array (type[][]...).
But I found something which look like very nice for me :
I will see if I can use this easily.

For the progress information, yes it's hard to implement because actually we can't know how long the process will take (nor exactly, nor approximately), but that maybe an interesting thing to search !

Rémi Thévenoux

Interesting article (although I didn't read all of it). And good luck with the netcdf library. Let us know if the java implementation takes longer than twice as long as the C++ implementation ;-)