h2oai / h2o-3

H2O is an Open Source, Distributed, Fast & Scalable Machine Learning Platform: Deep Learning, Gradient Boosting (GBM) & XGBoost, Random Forest, Generalized Linear Modeling (GLM with Elastic Net), K-Means, PCA, Generalized Additive Models (GAM), RuleFit, Support Vector Machine (SVM), Stacked Ensembles, Automatic Machine Learning (AutoML), etc.
http://h2o.ai
Apache License 2.0
6.94k stars 2k forks source link

Icer does not support generics #14822

Open exalate-issue-sync[bot] opened 1 year ago

exalate-issue-sync[bot] commented 1 year ago

Example:

class Grid extends Iced { private MP[] params; MP[] getParams() { return params; } public addParam(MP param) { / .. / } }

Then the code: Grid grid = DKV.getGet("myGrid") for (GBMParameters param : grid.getParams()) { / ... / }

Will throw exception if Grid is fetched from remote node: java.lang.ClassCastException: [Lhex.Model$Parameters; cannot be cast to [Lhex.tree.gbm.GBMModel$GBMParameters;

The problem is that, Icer code does not reflect generics parameters and generates common code for generics' upper bound: class hex.grid.Grid$Icer extends water.Lockable$Icer { protected final water.AutoBuffer write79(water.AutoBuffer ab, hex.grid.Grid ice) { write49(ab,ice); ab.putA((hex.Model.Parameters[])_unsafe.getObject(ice,40L)); // _failed_params return ab; } }

It affects only generics used in array definition.

Workaround is to: 1) create a specific classes - e.g., GBMGrid - GBMGrid extends Grid or 2) modify code of Grid to use in calls returning arrays the generics upper bound

DinukaH2O commented 1 year ago

JIRA Issue Migration Info

Jira Issue: PUBDEV-1863 Assignee: New H2O Bugs Reporter: Michal Malohlava State: Open Fix Version: N/A Attachments: N/A Development PRs: N/A