You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "C. Scott Andreas (JIRA)" <ji...@apache.org> on 2018/12/10 21:54:00 UTC
[jira] [Commented] (CASSANDRA-14923) Java8 forEach cannot be used
in UDF
[ https://issues.apache.org/jira/browse/CASSANDRA-14923?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16715623#comment-16715623 ]
C. Scott Andreas commented on CASSANDRA-14923:
----------------------------------------------
Thanks for filing, [~lapo@lapo.it]! This is tracked underĀ [CASSANDRA-11052|https://issues.apache.org/jira/browse/CASSANDRA-11052].
> Java8 forEach cannot be used in UDF
> -----------------------------------
>
> Key: CASSANDRA-14923
> URL: https://issues.apache.org/jira/browse/CASSANDRA-14923
> Project: Cassandra
> Issue Type: Bug
> Environment: FreeBSD 11.2
> Cassandra 3.11.3
> OpenJDK 8.181.13
> Reporter: Lapo Luchini
> Priority: Major
>
> I get the following error:
> {noformat}
> cqlsh:test> CREATE OR REPLACE FUNCTION sumMap (state map<text, int>, val map<text, int>)
> ... RETURNS NULL ON NULL INPUT
> ... RETURNS map<text, int>
> ... LANGUAGE java AS
> ... $$
> ... val.forEach((k, v) -> {
> ... Integer cur = state.get(k);
> ... state.put(k, (cur == null) ? v : cur + v);
> ... });
> ... return state;
> ... $$;
> InvalidRequest: Error from server: code=2200 [Invalid query] message="Java source compilation failed:
> Line 2: The type java.util.function.BiConsumer cannot be resolved. It is indirectly referenced from required .class files
> Line 2: The method forEach(BiConsumer<? super String,? super Integer>) from the type Map<String,Integer> refers to the missing type BiConsumer
> Line 2: The target type of this expression must be a functional interface
> "
> {noformat}
> on the other hand, this compiles correctly:
> {noformat}
> CREATE OR REPLACE FUNCTION sumMap (state map<text, int>, val map<text, int>)
> RETURNS NULL ON NULL INPUT
> RETURNS map<text, int>
> LANGUAGE java AS
> $$
> for (Map.Entry<String, Integer> e : val.entrySet()) {
> String k = e.getKey();
> Integer v = e.getValue();
> Integer cur = state.get(k);
> state.put(k, (cur == null) ? v : cur + v);
> };
> return state;
> $$;
> {noformat}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org