我在SparkConf中设置参数spark.cassandra.output.batch.size.rows,如下所示:
val conf = new SparkConf(true)
.set("spark.cassandra.connection.host", "host")
.set("spark.cassandra.auth.username", "cassandra")
.set("spark.cassandra.auth.password", "cassandra")
.set("spark.cassandra.output.batch.size.rows", "5120")
.set("spark.cassandra.output.concurrent.writes", "10")
Run Code Online (Sandbox Code Playgroud)
但是当我表演的时候
saveToCassandra( "数据", "ten_days")
我继续在我的system.log中看到警告
NFO [FlushWriter:7] 2014-11-20 11:11:16,498 Memtable.java (line 395) Completed flushing /var/lib/cassandra/data/system/hints/system-hints-jb-76-Data.db (5747287 bytes) for commitlog position ReplayPosition(segmentId=1416480663951, position=44882909)
INFO [FlushWriter:7] 2014-11-20 11:11:16,499 Memtable.java (line 355) Writing Memtable-ten_days@1656582530(32979978/329799780 serialized/live bytes, 551793 ops)
WARN [Native-Transport-Requests:761] 2014-11-20 11:11:16,499 BatchStatement.java (line 226) Batch of prepared statements for [data.ten_days] is of size 36825, exceeding specified threshold of 5120 by 31705.
WARN [Native-Transport-Requests:777] 2014-11-20 11:11:16,500 BatchStatement.java …Run Code Online (Sandbox Code Playgroud) 我试图用PreparedStatement与solr_query使用下面的代码:
PreparedStatement preparedStatement = cassandraSession.prepare(
"SELECT * FROM users WHERE solr_query = 'username:? OR email:?';"
);
BoundStatement boundStatement = new BoundStatement(preparedStatement);
ResultSet results = cassandraSession.execute(
boundStatement.bind(
username,
email
)
);
Run Code Online (Sandbox Code Playgroud)
当我执行上面的代码时,我得到以下异常:
java.lang.IllegalArgumentException: Prepared statement has only 0 variables, 2 values provided
如何正确使用solr_query的预准备语句?
我使用的是DataStax Enterprise 4.5.3,它使用Cassandra 2.0.11.82和Solr 4.6.0.2.8.我正在使用DataStax Java驱动程序.
我在 Linux Ubuntu 机器上设置了 DataStax Enterprise 4.6.6。OpsCenter 和 DevCenter 工作正常。我可以毫无问题地写入数据库等。
然而,许多演示和命令行工具返回以下错误:
无法确定 DSE_ENV
发生这种情况的一个例子是:
节点工具状态
我找到了一个名为的文件DSE_ENV.sh,它似乎设置了一些环境变量,例如DSE_HOME. 但是当我echo $DSE_HOME例如未设置变量时。我不知道这个文件是否永远不会被调用,或者是什么导致了这个问题。
我发现这篇文章专门针对dse未启动的服务,而我的情况并非如此:https :
//support.datastax.com/hc/en-us/articles/204226189-DSE-fails-to-start-有错误-DSE-ENV-无法确定
然而,我尝试运行它提到的权限命令,但没有运气。
我的列族结构是:
create table mykeyspc."test" (
id int PRIMARY KEY,
val set<frozen<map<text,text>>>
);
Run Code Online (Sandbox Code Playgroud)
当我通过CQL shell插入数据时
insert into "test" JSON '{"id":1,"val":{"ab","bc"}}';
Error: INVALIDREQUEST: code=2200 [Invalid query] message="Counld not decode JSon string as
map:org.codehaus.jackson.jsonParseException: Unexpected character{'{'{ code 123})
Run Code Online (Sandbox Code Playgroud)
要么
insert into "test" (id,val) values (1,{{'ab','bc'},{'sdf','name'}});
Error: INVALIDREQUEST: code=2200 [Invalid query] message="INVALID SET LITERAL FOR
VAL:value{'a','b'} is not of type frozen<map<text,text>>"
Run Code Online (Sandbox Code Playgroud) 我们正在为我们的社交网络使用 Datastax Cassandra,我们正在设计/数据建模我们需要的表,这让我们感到困惑,我们不知道如何设计一些表,我们有一些小问题!
正如我们对每个查询的理解,我们必须有不同的表,例如用户 A 跟随用户 C 和 B。
现在,在 Cassandra 中,我们有一个表posts_by_user:
user_id | post_id | text | created_on | deleted | view_count
likes_count | comments_count | user_full_name
Run Code Online (Sandbox Code Playgroud)
我们有一个根据用户关注者的表,我们将帖子的信息插入到表中,称为user_timeline当关注者用户访问第一个网页时,我们从user_timeline表中的数据库中获取帖子。
这是user_timeline表:
follower_id | post_id | user_id (who posted) | likes_count |
comments_count | location_name | user_full_name
Run Code Online (Sandbox Code Playgroud)
首先,这个数据建模对于关注基础(关注者,关注行为)社交网络是否正确?
现在我们要计算帖子的点赞数,正如您看到的,我们在两个表中都有点赞数( user_timeline, posts_by_user),并假设一个用户有 1000 个关注者,然后通过每个点赞操作,我们必须更新所有 1000 行user_timeline和 1 行posts_by_users; 这不合逻辑!
然后,我的第二个问题是它应该如何?我的意思是(最喜欢的)桌子应该如何?
当我尝试使用DataStax Java Driver从Java连接到Cassandra时,我收到此错误.关于SO我几乎没有回答.在这里它说com.google.common.util.concurrent.FutureFallback is deprecated在番石榴19.0,自20.0番石榴取出.因此,不要使用Guava 20.0或更高版本.
此外,我正在使用需要Guava 20.0的Pmml-Evaluator.如果我删除连接到Cassandra的代码,我的代码工作正常.那么,我现在如何解决这个问题呢?
Pom.xml依赖项:
<dependencies>
<dependency>
<groupId>org.jpmml</groupId>
<artifactId>pmml-model</artifactId>
<version>1.3.4</version>
</dependency>
<dependency>
<groupId>com.beust</groupId>
<artifactId>jcommander</artifactId>
<version>1.48</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jpmml</groupId>
<artifactId>pmml-evaluator</artifactId>
<version>1.3.4</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
<version>4.1.8.Final</version>
</dependency>
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
<version>3.1.4</version>
</dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)
课程:
package com.cw.predictive;
import com.datastax.driver.core.Session;
import com.datastax.driver.core.Cluster;
public class CassandraSession {
private static Session session; …Run Code Online (Sandbox Code Playgroud) java guava datastax-enterprise datastax-java-driver datastax
我有一张Cassandra表: -
create table test(imei text,dt_time timestamp, primary key(imei, dt_time)) WITH CLUSTERING ORDER BY (dt_time DESC);
Partition Key is: imei
Clustering Key is: dt_time
Run Code Online (Sandbox Code Playgroud)
现在,我想在每个分区键中仅存储此表中的最新条目(按时间).假设我在表中插入条目,每个imei都会有单个条目
现在让我们说一个imei 98838377272 dt_time是2017-12-23 16.20.12现在对于相同的imei,如果dt_time像2017-12-23 15.20.00那么这个条目不应该插入那个Cassandra表中.
但是如果时间到了2017-12-23 17.20.00那么它应该得到插入,前一行应该被这个dt_time取代.
根据这篇文章:https://docs.datastax.com/en/storage-attached-index/6.8/sai/saiFaqs.html,TEXT类型支持CONTAINS操作。但我收到这样的错误:com.datastax.driver.core.exceptions.InvalidQueryException: Cannot use CONTAINS on non-collection column
谁能解释一下如何在 TEXT 列上使用 SAI 索引以便可以使用 CONTAINS 操作(如 SQL LIKE 操作)在此列中进行搜索?
PS 如果在包含 TEXT 值列表的列上创建 SAI 索引,我就能够使用 CONTAINS 操作。但不想自己生成子字符串的所有组合。至少根据文档,应该可以在 TEXT 上使用 CONTAINS ...
数据库架构:
CREATE TABLE IF NOT EXISTS some_table (
id text,
data text,
list_for_search list<text>,
PRIMARY KEY (id))
WITH CLUSTERING ORDER BY (id ASC);
CREATE CUSTOM INDEX IF NOT EXISTS some_table_search_idx
ON some_table (data)
USING 'StorageAttachedIndex' WITH OPTIONS = {'case_sensitive': 'false'};
Run Code Online (Sandbox Code Playgroud)
文凭试 6.8.3
我一直在阅读有关 datastax 的 Cassandra Db 文档以及 Apache 文档。到目前为止,我了解到我们不能在一张表上创建多个索引(一个主索引,一个辅助索引)。每个查询都应该有一个单独的表。将此与 SQL 表进行比较,例如我们要查询 4 个字段的 SQL 表,对于 Cassandra 的该表,我们应该将该表拆分为 4 个表,对吧?(如果我错了,请纠正我)。在这 4 个表上我可以拥有索引并进行查询,我的问题是我们如何将数据插入到这 4 个表中,我应该发出 4 个连续的插入请求吗?
我的首要任务是避免二级索引
database cassandra datastax-enterprise cassandra-2.0 cassandra-3.0