Custom output type in Java Snippet

Hi,

I’m trying to use a Java Snippet to perform a custom distance calculation. Following I want the Distance Matrix Pair Extractor to work with the calculated distances. How do I use the data type the Distance Matrix Pair Extractor expects?

Hi Maximilian,
Do you calculate the distance between individual rows or cells in a single row? Maybe it makes sense to use the Java Distance node instead? Otherwise I think the distance information KNIME usually produces is a collection cell with distances to all previous rows in the table. That collection cell can be created by returning a double array. I am not sure if the Matrix Pair Extractor node can handle that, though.
Kind regards
Alexander

Hey, thanks for the reply!

I’m trying to calculate the distance between individual rows.
I’ve already tried to calculate the distances with a combination of Java Distance -> Distance Matrix Calculate -> Distance Pair Extractor but the computing time is extrem high and unsatisfying due to a table containing alot more than 1.000.000 rows.
Therefore I created a Java Snippet to reduce the calculation time. The Java Snippet is working really efficient, generating a double array with the calculated distances. The Distance Pair Extractor just can’t handle the array. It needs a “DistanceVectorDataValue”. How can use this data type as an output in the Java Snippet?

Kind regards
Maximilian

Hi Maximilian,
I don’t think there is a direct way, but you could write your distance matrix as a CSV file in a format like the Distance Matrix Writer produces and then read that file using the Distance Matrix Reader.
Kind regards
Alexander