如何使用自定义Java类在Cassandra中创建用户定义函数? [英] How can I create User Defined Functions in Cassandra with Custom Java Class?

查看:107
本文介绍了如何使用自定义Java类在Cassandra中创建用户定义函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网上找不到任何东西。如何在cassandra中创建自定义用户定义的函数?。

I couldn't find this anywhere online. How can I create a custom user defined function in cassandra?.

对于Ex:

CREATE OR REPLACE FUNCTION customfunc(custommap map<text, int>)
CALLED ON NULL INPUT
RETURNS map<int,bigint> 
LANGUAGE java AS 'return MyClass.mymethod(custommap);';

MyClass是可以在类路径中注册的类吗?

Where "MyClass" is a class that I can register in the Classpath?

推荐答案

我也有同样的问题。 UDF中的自定义类在 cassandra 2.2.14 中受支持,但在 cassandra 3.11.4 中不受支持。

I have the same issue, too. The custom class in UDF is support in cassandra 2.2.14, but not in cassandra 3.11.4.

遍历源代码, cassandra 3.11.4 ,在没有父类加载器的情况下设置UDF类加载器,以便它可以完全控制什么UDF使用的类/资源。在 org.apache.cassandra.cql3.functions.UDFunction.java 中,白名单和黑名单用于控制可以访问的类/包。

Go through the source codes, cassandra 3.11.4 setup the UDF class loader with no parent class loader so that it have full control about what class/resource UDF uses. In org.apache.cassandra.cql3.functions.UDFunction.java, a whitelist and blacklist is used to control which class/package can be access.

对于您的问题,应将 MyClass 的全名添加到白名单中,然后重新构建cassandra。

For your issue, you should add the full name of MyClass into whitelist, and re-build the cassandra.

这篇关于如何使用自定义Java类在Cassandra中创建用户定义函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆