Java Snippet:Bugs/feature request

Hi,

I am using Java snippet quite often and observed following bugs/feature request-

1) If I am creating lets say 5 new output cols using some calculations on few input cols; 

if any calculation has missing value, then "ALL" new cols shows missing value even though inputs for other 4 calculation are totally valid. (Bug)

2) Need to explicitly mention output col. For input I need not to mention it explicitly as I can use getCell method. (feature request for setCell)

3) As we need to mention output cols explicitly, if we have more than ~100 output cols then KNIME sometimes hangs and needed to restart.

 

Java Snippet is such a wonderful node, if above things are handled it will be much more versatile.

 

Regards,

Nikhil

 

 

 

 

Any views or suggestions?

Regards,

Nikhil Mane

Hi Nikhil!

Thank you for your suggestions!

Regarding 1:

I tried this snippet:

out_col1 = null;
out_col2 = "KNIME";

Which only shows missing values in out_col1. Hence, you will have to provide more information about what you mean... can you try to create a minimal example from your snippet that I could use to reproduce this bug?

Regarding 2:

That is indeed inconsistent! I will check with the other developers to see what they think about this and tell you once I know something.

Regarding 3:

You have 100 columns mentioned with 100 variables? That's pretty cool! But cumbersome... I guess we really need 2) for that.
Where does KNIME hang here? During execution? During the dialog? Maybe you could share your workflow (jonathan.hale@knime.com). I would probably suggest not using the JavaSnippet for this all together, or maybe iterating through the columns with a loop?

 


Cheers, Jonathan.

 

Hi Jonathan,

Please find attached workflow for point 1.

Regarding 3- Workflow hangs if I try to open it for reconfiguration, F6 (never hangs during execution :)) 

I think its because large number of 'out' variable declarations. I think setCell() will solve the issue.

Regards,

Nikhil

 

 

Hi Nikhil!

I just had a look at the workflow and, as there is a NullPointerException thrown on one of those lines, the entire row will be output as missing and this is intended. We cannot recover from that exception from outside of your code, hence you will have to check for null before using the input yourself.

As for the setCell(), I will see what I can do! :)
The dialog should not hang one way or another, so I will probably look into that, too.

Thanks again!
Jonathan.

Hi Jonathan,

Thanks for the review.

Can you suggest any way to handle this before JS.

I am using 'Missing Value' node and changing Double > Fixed Value > 0.0

But its not great idea as op4=0+?+? should give me op4=? But with Missing value node it will give me op4=0 which is actually wrong output.

i.e. If any of inputs for particular output is missing, then that output should be Missing !

Regards,

Nikhil

Any Suggestion?

Regards,

Nikhil

I am sorry that this completty slipped off my radar! I hope you were able to solve the problem in the meanwhile, for anyone else who comes accross this problem:

If you try {} catch (NullPointerException e) {} around the relevant pieces of code, you can avoid the the abort of processing for the row. All outputs that are null will result in empty cells, others would still keep their value this way.

Cheers, Jonathan.

PS: Regarding the execution hanging with many output rows, there is a fix coming up which should hopefully fix that. It does not apply to the dialog, though.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.