我有一个密钥空间填充了生成成本高昂的数据.我希望在我的集群中有两个这样的数据副本.我想有两个keyspaces落得:让叫他们mydata和mydatabackup,都含有相同的数据(我不介意卡桑德拉时间戳不同).
是否有捷径可寻?我能找到答案的最近的事情是使用sstable2json和json2sstable 作为对类似问题的回应?有没有更好的办法?
简短版:是否可以查询与特定日期对应的所有timeuuid列?
更多细节:
我有一个表定义如下:
CREATE TABLE timetest(
key uuid,
activation_time timeuuid,
value text,
PRIMARY KEY(key,activation_time)
);
Run Code Online (Sandbox Code Playgroud)
我用一行填充了这一行,如下所示(f0532ef0-2a15-11e3-b292-51843b245f21是与日期对应的timeuuid 2013-09-30 22:19:06+0100):
insert into timetest (key, activation_time, value) VALUES (7daecb80-29b0-11e3-92ec-e291eb9d325e, f0532ef0-2a15-11e3-b292-51843b245f21, 'some value');
Run Code Online (Sandbox Code Playgroud)
我可以按如下方式查询该行:
select activation_time,dateof(activation_time) from timetest where key=7daecb80-29b0-11e3-92ec-e291eb9d325e
Run Code Online (Sandbox Code Playgroud)
结果如下(使用cqlsh)
activation_time | dateof(activation_time)
--------------------------------------+--------------------------
f0532ef0-2a15-11e3-b292-51843b245f21 | 2013-09-30 22:19:06+0100
Run Code Online (Sandbox Code Playgroud)
现在让我们假设我的表中有很多数据,我想要检索activation_time与特定日期相对应的所有行2013-09-30 22:19:06+0100.
我本来期望能够查询之间的所有timeuuids的范围minTimeuuid('2013-09-30 22:19:06+0100')和maxTimeuuid('2013-09-30 22:19:06+0100')但这似乎并不可能(下面的查询返回零行):
select * from timetest where key=7daecb80-29b0-11e3-92ec-e291eb9d325e and activation_time>minTimeuuid('2013-09-30 22:19:06+0100') and activation_time<=maxTimeuuid('2013-09-30 22:19:06+0100');
Run Code Online (Sandbox Code Playgroud)
似乎我需要使用一个hack,我在查询中增加第二个日期(一秒钟)以捕获行,即,
select * from timetest where key=7daecb80-29b0-11e3-92ec-e291eb9d325e …Run Code Online (Sandbox Code Playgroud) 我刚观看了Patrick McFadin关于cassandra数据模型的YouTube视频.
有一张表,如下:
create table user_activity_history {
username varchar,
interaction_date varchar,
activity_code varchar,
detail varchar,
PRIMARY KEY((username,interaction_date),interaction_time)
);
Run Code Online (Sandbox Code Playgroud)
为什么是主键((username,interaction_date),interaction_time).这有什么不同(username,interaction_date,interaction_time).
我想在Cassandra 1.2.8中插入一行包含50,000列的单行.在插入之前,我已准备好整个行的所有数据(在内存中):
+---------+------+------+------+------+-------+
| | 0 | 1 | 2 | ... | 49999 |
| row_id +------+------+------+------+-------+
| | text | text | text | ... | text |
+---------+------+------+------|------+-------+
Run Code Online (Sandbox Code Playgroud)
列名是整数,允许切片进行分页.列值是该特定索引处的值.
CQL3表定义:
create table results (
row_id text,
index int,
value text,
primary key (row_id, index)
)
with compact storage;
Run Code Online (Sandbox Code Playgroud)
由于我已经在内存中拥有row_id和所有50,000个名称/值对,我只想在单个请求/操作中向Cassandra中插入一行,以便尽可能快.
我似乎唯一能找到的是执行以下50,000次:
INSERT INTO results (row_id, index, value) values (my_row_id, ?, ?);
Run Code Online (Sandbox Code Playgroud)
第一个?是索引计数器(i),第二个?是要存储在位置的文本值i.
这需要很多时间.即使我们将上述INSERT放入批处理中,也需要花费很多时间.
我们完整地拥有了我们需要的所有数据(完整的行),我认为很容易说"这里,Cassandra,将这些数据作为一行存储在一个请求中",例如:
//EXAMPLE-BUT-INVALID CQL3 SYNTAX:
insert into results …Run Code Online (Sandbox Code Playgroud) 我正在尝试解析SVG Path元素中的d属性,到目前为止我发现fabric.js可以解析SVG,但直到现在我仍然不知道如何。
我需要解析路径以获得其中的形状(线弧)并在它们上绘制正方形,最重要的是返回这些正方形的属性。
知道如何使用fabric.js 做到这一点吗?或任何其他图书馆?或者有没有人有不同的方法?
下图有一个矩形和一条线,它们都有我在边界上画的正方形,我正在尝试在路径元素上做同样的事情
我使用ruby-build安装了ruby-1.9.2-p290.我用了这个命令ruby-build 1.9.2-p290 ~/.rbenv/versions/1.9.2-p290
现在,如何卸载此版本的ruby?
谢谢.
我正在尝试为Cassandra DB 使用Datastax Java驱动程序API,并且我有一个具有getList函数的行对象:
public <T> List<T> getList(String name,
Class<T> elementsClass)
Returns the value of column name as a list.
Parameters:
name - the name of the column to retrieve.
elementsClass - the class for the elements of the list to retrieve.
Returns:
the value of the ith column in this row as a list of elementsClass objects. If the value is NULL, an empty list is returned (note that Cassandra makes no difference between an empty list …Run Code Online (Sandbox Code Playgroud) 我正在使用Datastax Java Driver.有一个使用相同的教程.
我不明白的是如何关闭与cassandra的连接?没有可用的密切方法,我认为我们不希望关闭会话,因为它预期是每个应用程序一个.
关心高拉夫
使用maxTimeuuid和minTimeuuid的查询的Java API是什么?我在QueryBuilder或其他任何地方找不到任何内容.我正在使用DataStax客户端
<artifactId>cassandra-driver-core</artifactId>
<version>1.0.3</version>
Run Code Online (Sandbox Code Playgroud)
表"a"有2列:1.类型为String的id 2.类型为TimeUuid的LMD
这就是我在做什么,似乎不对,当然不起作用
Query q = QueryBuilder
.select()
.all()
.from("test","a")
.where().and(QueryBuilder.gt("LMD", "minTimeUUid('2013-11-03 14:33:50')"))
.and(QueryBuilder.lt("LMD", "maxTimeUUId('2013-11-03 14:45:50')"));
Run Code Online (Sandbox Code Playgroud)
任何指针都非常感谢
谢谢
我需要在cassandra中向表中添加其他列.但是现有的表并不是空的.有没有办法以简单的方式更新它?否则,将其他列添加到非空表的最佳方法是什么?thx提前.