不要在cassandra工作udf javascripts

时间:2017-12-14 06:17:34

标签: cassandra

  • 创建密钥空间:
CREATE KEYSPACE testkeyspace WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };
  • 在testkeyspace中创建函数:
CREATE OR REPLACE FUNCTION first_int(input set) RETURNS NULL ON NULL INPUT RETURNS int LANGUAGE javascript AS '(function(){var result = 2;return result;})();';
  • 创建表并插入:
create table A (id int primary key, val set);
insert into A  (id, val) values (1, {3,5,7,1});
  • 选择
select first_int(val) from A where id = 1;
Traceback (most recent call last):
  File "/usr/bin/cqlsh.py", line 1044, in perform_simple_statement
    result = future.result()
  File "/usr/share/cassandra/lib/cassandra-driver-internal-only-3.10.zip/cassandra-driver-3.10/cassandra/cluster.py", line 3826, in result
    raise self._final_exception
FunctionFailure: Error from server: code=1400 [User Defined Function failure] message="execution of 'testkeyspace.first_int[set]' failed: java.security.AccessControlException: access denied: ("java.lang.RuntimePermission" "accessClassInPackage.java.io")"

原始日志:

exports.seed = function (knex, Promise) {
  var promises = seeds.map(function (seed) {
    // Check for an existing definition. More recently
    // you can use `whereNotExists` but you always need
    // an id here whatever the case
    return knex('definitions')
      .select('id')
      .where('definition', seed.definition)
      .then(function (definition_id) {
        if (definition_id.length === 1) return definition_id[0]
        return knex('definitions')
          .insert({ definition: definition })
      })
      .then(function (definition_id) {
        // Use the definition once it exists
        return knex('words')
          .insert({ word: seed.word, definition_id: definition_id })
          .then(function (word_id) {
            return { word_id: word_id, definition_id: definition_id }
          });
      })
      .then(function (join_ids) {
        // Finally, update the join table
        return knex('definitions_words')
          .insert({
            definition_id: join_ids.definition_id,
            word_id: join_ids.word_id
          })
      })

  return Promise.all(promises);
};

0 个答案:

没有答案