如何将2个Cassandra表保留在同一分区中 [英] How to keep 2 Cassandra tables within same partition

查看:71
本文介绍了如何将2个Cassandra表保留在同一分区中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试阅读datastax博客和文档,但找不到任何具体信息

I tried reading up on datastax blogs and documentation but could not find any specific on this

有没有办法让Cassandra中的2个表属于同一分区?
例如:

Is there a way to keep 2 tables in Cassandra to belong to same partition? For example:

CREATE TYPE addr (
  street_address1 text,
  city text,
  state text,
  country text,
  zip_code text,
);

CREATE TABLE foo (
  account_id timeuuid,
  data text,
  site_id int,
  PRIMARY KEY (account_id)
};

CREATE TABLE bar (
  account_id timeuuid,
  address_id int,
  address frozen<addr>,
  PRIMARY KEY (account_id, address_id)
);

在这里,我需要确保这两个表/ CF都将以这种方式位于同一分区上可以从同一节点获取这两个数据集的相同account_id

Here I need to ensure that both of these tables/CF will live on same partition that way for the same account_id both of these set of data can be fetched from the same node

任何指针都受到高度赞赏。

Any pointers are highly appreciated.

此外,如果某人在使用UDT(用户定义类型)方面有一定经验,我想了解向后兼容性的工作原理。如果我修改 addr UDT以具有更多其他属性(例如zip_code2 int ,以及名称文本),具有这些属性的旧行如何工作?甚至兼容吗?

Also, if someone has some experience in using UDT (User Defined Types), I would like to understand how the backward compatibility would work. If I modify "addr" UDT to have a couple of more attributes (say for example zip_code2 int, and name text), how does the older rows that does have these attribute work? Is it even compatible?

谢谢

推荐答案

如果有两个表具有相同的复制策略和相同的分区键,它们将共同定位其分区。因此,只要两个表位于相同的键空间中并且它们的分区键匹配

If two table share the same replication strategy and same partition key they will colocate their partitions. So as long as the two tables are in the same keyspace AND their partition keys match

PRIMARY KEY( account_id )== PRIMARY KEY( account_id ,address_id)

PRIMARY KEY (account_id) == PRIMARY KEY (account_id, address_id)

任何给定的account_id都将位于(并复制到)同一台计算机上。

Any given account_id will be on (and replicated to) the same machines.

这篇关于如何将2个Cassandra表保留在同一分区中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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