Cassandra 2.1.8上的非冻结集合和用户定义类型 [英] Non frozen collections and user defined types on Cassandra 2.1.8

查看:92
本文介绍了Cassandra 2.1.8上的非冻结集合和用户定义类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从此处运行以下示例>

I'm trying to run the following example from here

  CREATE TYPE address (
          street text,
          city text,
          zip int
      );

 CREATE TABLE user_profiles (
      login text PRIMARY KEY,
      first_name text,
      last_name text,
      email text,
      addresses map<text, address>
  );

但是,当我尝试创建 user_profiles 表,出现以下错误:

However, when I try to create the user_profiles table, I get the following error:

InvalidRequest: code=2200 [Invalid query] message="Non-frozen collections are not
allowed inside collections: map<text, address>

关于为什么可以这样做的任何想法

Any thoughts on why this could be happening?

推荐答案

我正在运行2.1.8,并且收到相同的错误消息。要解决此问题,您需要冻结关键字:

I am running 2.1.8 and I get the same error message. To fix this, you need the frozen keyword:

 CREATE TABLE user_profiles (
      login text PRIMARY KEY,
      first_name text,
      last_name text,
      email text,
      addresses map<text, frozen <address>>
  );

冻结对于UDT(目前而言)是必需的将它们重新组合为单个值。 用户定义的类型文档。试试看。

Frozen is necessary for UDTs (for now) as it serializes them into a single value. A similar, better example for you to follow might be the one in the User Defined Type documentation. Give that a try.

这篇关于Cassandra 2.1.8上的非冻结集合和用户定义类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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