Skip to content

Commit

Permalink
Improved support for map values expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
vruusmann committed Sep 28, 2024
1 parent 9b924c3 commit 4ad3b70
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,18 @@ public <V> void _return(JExpression valueExpr, Map<?, V> resultMap, V defaultRes
block._return(PMMLObjectUtil.createExpression(defaultResult, this));
} else

if((resultMap.size() > 64) && JBinaryFileInitializer.isExternalizable(resultMap.keySet())){
JBinaryFileInitializer resourceInitializer = new JBinaryFileInitializer(IdentifierUtil.create(Map.class.getSimpleName(), Collections.singletonList(resultMap)) + ".data", this);

JFieldVar mapField = resourceInitializer.initNumbersMap("map$" + System.identityHashCode(Collections.singletonList(resultMap)), (Map)resultMap);

JBlock thenBlock = block._if(mapField.invoke("containsKey").arg(valueExpr))._then();

thenBlock._return(mapField.invoke("get").arg(valueExpr));

block._return(PMMLObjectUtil.createExpression(defaultResult, this));
} else

{
boolean stringKeys = true;

Expand Down

0 comments on commit 4ad3b70

Please sign in to comment.